security: fix critical issues (open proxy SSRF, weak default password, permissive CORS) - #3
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…rd, cookie flags, and bump vulnerable deps Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Security review of the RVG Gateway (
main.py, in-memory FastAPI app). Fixed the critical issues; remaining lower-severity items are listed below for follow-up.Fixed (critical / high)
Unauthenticated open proxy + SSRF —
/proxy/{target_url:path}had no auth and forwarded requests to any host. Anyone could use the server as an open forward proxy and reach internal services / cloud metadata (e.g.169.254.169.254,127.0.0.1). Now requires a valid session (Depends(require_auth)) and rejects non-public targets:Also set
follow_redirects=Falseon the proxied request so a redirect can't bounce into an internal address after the check.Weak default admin password —
AUTHdefaulted toADMIN_PASSWORDor the hardcoded"123456". Anyone could log in to an unconfigured deployment. Now a random one-time password is generated (and logged) whenADMIN_PASSWORDis unset; the guessable default is removed.Overly permissive CORS —
allow_origins=["*"]combined withallow_credentials=Truelets any website make credentialed cross-origin requests. Replaced with an explicit allow-list fromALLOWED_ORIGINS(comma-separated); credentials are only enabled when specific origins are configured. Default is no cross-origin access (the dashboard is same-origin).Session cookie missing
Secure— login cookie is now markedSecurewhen the request is HTTPS (honorsX-Forwarded-Protobehind Railway's proxy), so the session token isn't sent over plaintext.Vulnerable dependencies — bumped
fastapi 0.104.1 → 0.115.6(fixes the form-parsing ReDoS, PYSEC-2024-38),httpx 0.25.1 → 0.27.2,uvicorn 0.24.0 → 0.32.1.Verified
Ran the app locally: unauth
/proxy→ 401; login with123456→ 401; SSRF to169.254.169.254and127.0.0.1→ 403; authed proxy to a public host → 200; app imports and serves the dashboard/login normally.Findings NOT changed (need product decision)
check_quotareturnsTruefor an unknown UUID ("backward compatibility"), so any random/ws/{uuid}is an unlimited free tunnel, bypassing the link/limit system. Left as-is since it may be intentional — recommend denying unknown UUIDs.starletteadvisories require a starlette 1.x major upgrade that FastAPI does not yet support; not forced here to avoid a risky framework migration.docs_url=None).Link to Devin session: https://app.devin.ai/sessions/46a90eb393ff4a31af6d27cebcae374a
Requested by: @hmilan1366