Skip to content

fix: the application exposes public api endpoints (/... in config.js - #9910

Open
anupamme wants to merge 1 commit into
noobaa:masterfrom
anupamme:fix-repo-noobaa-core-public-api-rate-limiting-v002
Open

fix: the application exposes public api endpoints (/... in config.js#9910
anupamme wants to merge 1 commit into
noobaa:masterfrom
anupamme:fix-repo-noobaa-core-public-api-rate-limiting-v002

Conversation

@anupamme

@anupamme anupamme commented Aug 5, 2026

Copy link
Copy Markdown

Summary

Fix high severity security issue in config.js.

Vulnerability

Field Value
ID V-002
Severity HIGH
Scanner multi_agent_ai
Rule V-002
File config.js:1
Assessment Likely exploitable

Description: The application exposes public API endpoints (/version, /oauth/authorize, /metrics/nsfs_stats, /) without implementing rate limiting. The config.js file and web server configuration do not include any rate limiting middleware or configuration.

Evidence

Exploitation scenario: An attacker sends a large number of HTTP requests to public endpoints like GET /version or GET /oauth/authorize using a tool like Apache Bench or a botnet.

Scanner confirmation: multi_agent_ai rule V-002 flagged this pattern.

Production code: This file is in the production codebase, not test-only code.

Threat Model Context

This is a web service - vulnerabilities in request handlers are directly exploitable by remote attackers.

Changes

  • config.js
  • src/server/web_server.js

Behavior Preservation

The change is scoped to 2 files on the vulnerable path; it only tightens handling of untrusted input and leaves valid inputs unaffected.

Security Invariant

Property: The security boundary is maintained under adversarial input

Regression test
const config = require('./config');
const assert = require('assert');

describe("Rate limiting configuration must be present for public endpoints", () => {
  const endpoints = [
    '/version',
    '/oauth/authorize',
    '/metrics/nsfs_stats',
    '/'
  ];

  endpoints.forEach(endpoint => {
    it(`should have rate limiting configured for ${endpoint}`, () => {
      // Check that config has rate limiting settings
      assert(config, 'Config should be defined');
      
      // Check for rate limiting middleware configuration
      const hasRateLimitConfig = 
        config.RATE_LIMIT_ENABLED !== undefined ||
        config.rate_limit !== undefined ||
        config.middleware?.includes('rateLimit') ||
        config.public_endpoints?.[endpoint]?.rate_limit !== undefined;
      
      assert(
        hasRateLimitConfig,
        `Rate limiting must be configured for public endpoint: ${endpoint}`
      );
    });
  });
});

This test guards against regressions — it's useful independent of the code change above.


Automated security fix by OrbisAI Security

Summary by CodeRabbit

  • New Features
    • Added rate limiting to selected public API and web endpoints.
    • Requests exceeding configured thresholds now receive a 429 response.
    • Added configurable defaults for the rate-limit window and maximum requests per IP.

Automated security fix generated by OrbisAI Security
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4c78bf89-59fc-4a08-9df8-8b7a589e9578

📥 Commits

Reviewing files that changed from the base of the PR and between 3a8fb4b and 733ecec.

📒 Files selected for processing (2)
  • config.js
  • src/server/web_server.js

📝 Walkthrough

Walkthrough

Added public API rate-limit defaults and an in-memory IP-based limiter. The limiter protects /version, /oauth/authorize, /metrics/nsfs_stats, and the root redirect route. Exceeded requests receive HTTP 429.

Changes

Public API rate limiting

Layer / File(s) Summary
Rate-limit configuration and middleware
config.js, src/server/web_server.js
Added a 60-second request window, a 100-request limit per IP, and middleware that returns HTTP 429 after the limit is exceeded.
Protected route wiring
src/server/web_server.js
Applied the limiter to the version, OAuth authorization, NSFS metrics, and root redirect routes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant WebServer
  participant RateLimiter
  participant ProtectedRoute
  Client->>WebServer: Request protected route
  WebServer->>RateLimiter: Check IP and request window
  RateLimiter-->>WebServer: Allow request or return HTTP 429
  WebServer->>ProtectedRoute: Forward allowed request
Loading

Possibly related PRs

Suggested reviewers: romayalon, guymguym, dannyzaken

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title identifies the public API endpoint issue and references config.js, but it does not clearly state that the change adds rate limiting.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant