🛡️ Sentinel: [CRITICAL] Fix hardcoded test secrets in responses API - #611
🛡️ Sentinel: [CRITICAL] Fix hardcoded test secrets in responses API#611sheepdestroyer wants to merge 4 commits into
Conversation
Co-authored-by: sheepdestroyer <1377479+sheepdestroyer@users.noreply.github.com>
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe PR removes hardcoded test tokens from production authorization by injecting them into the responses API allowlist only when pytest is loaded, while retaining environment-configured keys and documenting the vulnerability and prevention guidance. Sequence diagram for responses API token authorizationsequenceDiagram
participant Client
participant ResponsesAPI
participant Environment
participant Pytest
Client->>ResponsesAPI: POST /v1/responses with client_token
ResponsesAPI->>Environment: Read ROUTER_API_KEY, LITELLM_MASTER_KEY, GATEWAY_KEY
alt pytest is loaded
ResponsesAPI->>Pytest: Check pytest in sys.modules
ResponsesAPI->>ResponsesAPI: Add hardcoded test keys to valid_keys
else production runtime
ResponsesAPI->>ResponsesAPI: Exclude hardcoded test keys from valid_keys
end
alt client_token in valid_keys
ResponsesAPI-->>Client: Process request
else invalid or missing token
ResponsesAPI-->>Client: HTTP 401 Unauthorized
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 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. Comment |
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. This changes the authorization decision by allowing known hardcoded tokens whenever the running process has pytest loaded; if that condition occurs in a deployed service, anyone with those tokens could gain access. Reverting stops the behavior going forward, but any unauthorized access during the window cannot be undone.
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Co-authored-by: sheepdestroyer <1377479+sheepdestroyer@users.noreply.github.com>
Co-authored-by: sheepdestroyer <1377479+sheepdestroyer@users.noreply.github.com>
Co-authored-by: sheepdestroyer <1377479+sheepdestroyer@users.noreply.github.com>
🚨 Severity: CRITICAL
💡 Vulnerability: The
responses_apiendpoint allowed bypassing proper authorization in production using hardcoded development/test tokens likegateway-passortest-key.🎯 Impact: An attacker could use these known test tokens to access backend AI models unauthenticated, bypassing proper rate limits, and potentially inflating billing or exhausting rate limits for the service.
🔧 Fix: The test tokens have been restricted to only load into the valid_keys list if
pytestis currently running. Otherwise, in a production environment, they are safely excluded.✅ Verification: Ran the router's test suite to ensure no tests were broken since they continue to have access to these tokens.
PR created automatically by Jules for task 6072292353613489706 started by @sheepdestroyer
Summary by Sourcery
Restrict responses API test credentials to test environments to enforce production authentication.
Bug Fixes:
Enhancements:
Chores: