Skip to content

security: rate-limit route handlers that perform authorization#23

Merged
davidcrowe merged 1 commit intomainfrom
fix/codeql-missing-rate-limiting
Apr 14, 2026
Merged

security: rate-limit route handlers that perform authorization#23
davidcrowe merged 1 commit intomainfrom
fix/codeql-missing-rate-limiting

Conversation

@davidcrowe
Copy link
Copy Markdown
Owner

Closes two CodeQL js/missing-rate-limiting alerts.

Findings addressed

#51 — apps/gateway-server/src/app.ts:169 (regression from PR #21)

The /protected pipeline runs identifiabl → limitabl → transformabl. The per-identity limiter (limitabl) can't rate-limit invalid JWT attempts — it needs req.user.sub to derive its key, and unauth requests fall back to IP which partitions poorly. An attacker can flood the endpoint with garbage JWTs and exhaust the RSA verify path before limitabl sees them.

Fix: added a generic IP-keyed rateLimit in front of identifiabl. Ceiling is limit * 10 — well above normal traffic; the real per-user cap is still limitabl downstream. Same pattern the /tools pipeline in this file already uses (toolsRateLimiter).

#47 — packages/proxyabl/src/tool-gateway.ts:1237 (pre-existing)

The proxy catch-all route did verifyBearer with no rate limiter. Applied the existing toolLimiter that's already defined in the same file for other routes.

Test plan

  • npm run build — clean
  • npx vitest run — 159/159
  • gitleaks clean
  • CodeQL should re-scan after merge and drop both alerts

Notes

Closes two CodeQL js/missing-rate-limiting alerts:

#51 apps/gateway-server/src/app.ts — /protected pipeline had no pre-auth
rate limiter. Added a generic IP-keyed limiter in front of identifiabl
so an attacker cannot flood the endpoint with invalid JWTs and exhaust
the RSA verify path. The per-identity limiter (limitabl) still runs
behind it for the real per-user cap.

#47 packages/proxyabl/src/tool-gateway.ts — the proxy catch-all route
performed verifyBearer without any rate limiter middleware. Applied
the existing `toolLimiter` (already defined in the same file for other
routes).
@davidcrowe davidcrowe merged commit 4a048d0 into main Apr 14, 2026
5 checks passed
@davidcrowe davidcrowe deleted the fix/codeql-missing-rate-limiting branch April 14, 2026 22:39
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