Skip to content

fix: critical project storage endpoints (post /:proj... in index.js#7878

Closed
anupamme wants to merge 1 commit into
FlowFuse:mainfrom
anupamme:fix-repo-flowfuse-fix-storage-rate-limiting-v001
Closed

fix: critical project storage endpoints (post /:proj... in index.js#7878
anupamme wants to merge 1 commit into
FlowFuse:mainfrom
anupamme:fix-repo-flowfuse-fix-storage-rate-limiting-v001

Conversation

@anupamme

Copy link
Copy Markdown

Summary

Fix high severity security issue in forge/routes/storage/index.js.

Vulnerability

Field Value
ID V-001
Severity HIGH
Scanner multi_agent_ai
Rule V-001
File forge/routes/storage/index.js:26
Assessment Likely exploitable

Description: Critical project storage endpoints (POST /:projectId/flows, credentials, settings, sessions) lack rate limiting despite the @fastify/rate-limit dependency being available. The preHandler hooks only verify session ownership but do not throttle requests, allowing authenticated tokens to flood these endpoints.

Evidence

Exploitation scenario: An attacker with a compromised project token sends thousands of rapid POST requests with large JSON payloads to /storage/:projectId/flows, exhausting database connections and server memory through.

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

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

Threat Model Context

This route handler appears to be publicly accessible. This is a web service - vulnerabilities in request handlers are directly exploitable by remote attackers.

Changes

  • forge/routes/storage/index.js

Verification

  • Build passes
  • Scanner re-scan confirms fix
  • LLM code review passed

Security Invariant

Property: The security boundary is maintained under adversarial input

Regression test
import { describe, test, expect, beforeAll, afterAll } from 'vitest';
import { createServer } from 'fastify';
import storageRoutes from '../../forge/routes/storage/index.js';

describe("Storage endpoints maintain rate limiting under adversarial request patterns", () => {
  const payloads = [
    { description: 'exploit: rapid sequential POSTs', count: 100, delay: 0 },
    { description: 'boundary: moderate burst', count: 25, delay: 10 },
    { description: 'valid: single request', count: 1, delay: 100 }
  ];

  let app;
  let authToken;

  beforeAll(async () => {
    app = createServer();
    app.register(storageRoutes);
    await app.ready();
    // Simulate authenticated session token
    authToken = 'valid-session-token';
  });

  afterAll(async () => {
    await app.close();
  });

  test.each(payloads)("enforces request throttling: $description", async (payload) => {
    const projectId = 'test-project';
    const requests = [];
    const startTime = Date.now();

    for (let i = 0; i < payload.count; i++) {
      const req = app.inject({
        method: 'POST',
        url: `/${projectId}/flows`,
        headers: { authorization: `Bearer ${authToken}` },
        payload: { data: `flow-data-${i}` }
      });
      requests.push(req);
      if (payload.delay > 0) await new Promise(resolve => setTimeout(resolve, payload.delay));
    }

    const responses = await Promise.all(requests);
    const endTime = Date.now();
    const duration = endTime - startTime;

    // Security property: request rate must be constrained
    if (payload.count > 1 && payload.delay === 0) {
      // Exploit case: rapid requests should trigger throttling
      const rateLimited = responses.some(res => res.statusCode === 429);
      expect(rateLimited, `Rapid ${payload.count} requests must trigger rate limiting`).toBe(true);
    } else {
      // Valid/boundary cases: all requests should succeed or be reasonably paced
      const allSuccess = responses.every(res => res.statusCode === 200);
      expect(allSuccess, `Controlled requests should succeed`).toBe(true);
    }
  });
});

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


Automated security fix by OrbisAI Security

Automated security fix generated by OrbisAI Security

Signed-off-by: orbisai0security <mediratta@gmail.com>
@hardillb

Copy link
Copy Markdown
Contributor

Please follow the instructions in the SECURITY.md file to report security issues

@anupamme

Copy link
Copy Markdown
Author

You're right, and I apologise; I should have gone through SECURITY.md instead of opening this as a public PR with exploitation details in the description. I'll close this PR now and submit the report through the proper channel instead. If the fix itself is still useful once triaged, happy to resubmit it cleanly (without the vulnerability write-up) as a normal PR referencing whatever issue/report number comes out of the disclosure process.

@anupamme anupamme closed this Jul 21, 2026
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.

2 participants