fix: gate unauthenticated local routes behind ENV check#980
Open
Joshua-Medvinsky wants to merge 1 commit into
Open
Conversation
Local development routes in app/local/ have no authentication guards. Including them unconditionally in the production FastAPI app exposes unauthenticated CRUD on agents, chat threads, and autonomous tasks to any network-reachable client. Guard the local router registration behind a check on config.env so they are only included when ENV is explicitly set to a dev/test value. Production deployments (ENV=production) no longer expose these routes. Signed-off-by: FailSafe Researcher <joshua@getfailsafe.com>
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.
Problem
The production FastAPI app (
app/api.py) unconditionally includes eleven routers fromapp/local/that have zero authentication dependencies. The code comment explicitly documents these are 'designed for local development and debugging only' and 'should not be exposed to the public internet' — but there is no code guard enforcing this.Any network-reachable production instance exposes unauthenticated CRUD on agents, chat threads, and autonomous tasks. All hardcode
LOCAL_USER_ID = 'system'giving callers full system-level (owner) access.CVSS v3.1: AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H → Critical
PoC:
Fix
Gate the local router registration behind a
config.envcheck:When
ENV=production(or any non-dev value), the routes are not registered. Local development withENV=local(the default) continues to work unchanged.Test Plan
ENV=local:GET /agentsreturns 200ENV=production:GET /agentsreturns 404 (route not registered)/teams/{id}/agents) continues to work in all ENV modesSecurity Note
Severity: Critical. PVRA is enabled on this repo; this PR is filed as the companion to a private security advisory. We will coordinate disclosure timing with the maintainers.