Skip to content

Potential fix for code scanning alert no. 364: Missing rate limiting - #87

Merged
mmeerrkkaa merged 1 commit into
masterfrom
alert-autofix-364
Oct 5, 2026
Merged

mmeerrkkaa merged 1 commit into
masterfrom
alert-autofix-364

Conversation

@mmeerrkkaa

@mmeerrkkaa mmeerrkkaa commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Potential fix for https://github.com/blockmineJS/blockmine/security/code-scanning/364

The best fix is to add an explicit route-level rate-limiting middleware and apply it to the flagged download endpoint (and optionally sibling expensive plugin install endpoints) before auth/authorization handlers. This preserves existing functionality while adding request throttling to reduce DoS risk.

In backend/src/api/routes/bots.js:

  1. Add import for express-rate-limit.
  2. Define a dedicated limiter (for plugin package operations) near router middleware definitions, e.g. 15-minute window with a conservative max request count.
  3. Insert this limiter into the middleware chain for:
    • router.get('/:botId/plugins/:pluginId/download', ...) (the flagged location),
    • and, to cover related variants/nearby expensive endpoints consistently, also apply to:
      • POST /:botId/plugins/install/local
      • POST /:botId/plugins/install/zip

This addresses the reported alert and reduces risk across similar high-cost routes without changing business logic.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Summary by Sourcery

Bug Fixes:

  • Add rate limiting to plugin package download and installation endpoints to reduce denial-of-service risk.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 58 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 6e7938df-23df-438e-b225-9c95d0a0fbb1
📥 Commits

Reviewing files that changed from the base of the PR and between 04b9f78 and 335518b.

📒 Files selected for processing (1)
  • backend/src/api/routes/bots.js
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR adds express-rate-limit to bots.js, defines a shared 15-minute/60-request limiter, and applies it ahead of existing auth checks on plugin download and installation routes to mitigate denial-of-service risk while preserving endpoint behavior.

Sequence diagram for rate-limited plugin package operations

sequenceDiagram
    participant Client
    participant Router
    participant Limiter as pluginPackageRateLimiter
    participant Auth as authenticateUniversal
    participant Access as checkBotAccess
    participant Handler as PluginEndpoint

    Client->>Router: Plugin install or download request
    Router->>Limiter: rateLimit(request)
    alt 60 requests reached in 15 minutes
        Limiter-->>Client: Rate limit response
    else request allowed
        Limiter->>Auth: authenticateUniversal(request)
        Auth->>Access: checkBotAccess(request)
        Access->>Handler: Execute plugin operation
        Handler-->>Client: Plugin response
    end
Loading

File-Level Changes

Change Details Files
Add a shared route-level limiter for expensive plugin package operations.
  • Configure a 15-minute window with a maximum of 60 requests.
  • Enable standard rate-limit headers and disable legacy headers.
  • Apply the limiter before authentication and authorization middleware.
backend/src/api/routes/bots.js
Protect plugin installation and download endpoints from excessive request volume.
  • Throttle local plugin installation.
  • Throttle ZIP plugin installation.
  • Throttle installed plugin package downloads without changing business logic.
backend/src/api/routes/bots.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@mmeerrkkaa
mmeerrkkaa marked this pull request as ready for review October 5, 2026 22:42

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Fixed security issues:

  • Remote code execution (RCE) from untrusted request data executed as code (link) · Dashboard

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@mmeerrkkaa
mmeerrkkaa merged commit 75bd3e1 into master Oct 5, 2026
6 checks passed
@mmeerrkkaa
mmeerrkkaa deleted the alert-autofix-364 branch October 5, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant