Skip to content

security: bind recommendation limits to API credentials - #18

Merged
CoreyLeath-code merged 4 commits into
mainfrom
agent/security-rate-limit-identity
Aug 11, 2026
Merged

security: bind recommendation limits to API credentials#18
CoreyLeath-code merged 4 commits into
mainfrom
agent/security-rate-limit-identity

Conversation

@CoreyLeath-code

@CoreyLeath-code CoreyLeath-code commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Summary

Closes the rate-limit bypass identified in the audit: recommendation throttling no longer trusts caller-supplied user_id.

Architecture impact

The API derives the in-memory rate-limit key from an HMAC-SHA-256 pseudonym of the submitted API credential, with a fixed domain-separation message. This preserves the existing per-process limiter architecture, does not store the raw credential, and makes changing request payload fields ineffective for evading the bucket. Unauthenticated development traffic shares one bounded bucket.

Files changed

  • app/api/routes.py — adds a credential-derived, non-secret rate-limit identity, uses it after authorization, and uses HMAC rather than raw SHA-256 so a credential is not handled as a password hash.
  • tests/test_serving_controls.py — verifies that the same credential produces a stable non-secret key and remains limited across attempts.

Validation performed

  • Compared the branch with main: only the API route and its focused serving-control test changed.
  • The initial Code Scanning gate correctly found that raw SHA-256 was unsuitable for credential material. The follow-up HMAC patch is now verified by a passing Code Scanning / CodeQL check.
  • Passing GitHub checks on the current head: ingestion schema validation, code quality, SAST, security analysis, CodeQL, and performance benchmarking.
  • The verified bundle container smoke test remains in progress at the time of this update.
  • Local execution was unavailable because this environment cannot establish a Git clone and the local gh token is stale; no test result is fabricated.

Risks

  • This repository uses one configured API key, so all authenticated callers share the same process-local quota. Per-caller quotas require an authenticated gateway or distinct credentials.
  • The limiter remains replica-local; distributed enforcement belongs in the gateway or a shared store.

Future improvements

  1. Introduce a gateway-issued client identity or multiple managed credentials for per-client quotas.
  2. Add a distributed rate limiter before multi-replica internet-facing deployment.
  3. Persist a real popularity fallback ranking in each model bundle as the next separate reliability PR.

Refs #13

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@CoreyLeath-code, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 40 minutes

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

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f9254e27-1c39-40a0-bee5-60a12981f6b3

📥 Commits

Reviewing files that changed from the base of the PR and between 8184cbb and 205b1b2.

📒 Files selected for processing (2)
  • app/api/routes.py
  • tests/test_serving_controls.py

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.

Comment thread app/api/routes.py Fixed
@CoreyLeath-code
CoreyLeath-code marked this pull request as ready for review August 11, 2026 17:32
@CoreyLeath-code
CoreyLeath-code merged commit efbe5f4 into main Aug 11, 2026
12 of 13 checks passed
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