fix(security): restrict OAuth redirect_uri localhost bypass to local mode#4121
Open
0xcucumbersalad wants to merge 1 commit into
Open
fix(security): restrict OAuth redirect_uri localhost bypass to local mode#41210xcucumbersalad wants to merge 1 commit into
0xcucumbersalad wants to merge 1 commit into
Conversation
…mode The OAuth authorize endpoint allowed redirect_uri to any localhost URL regardless of environment. In production (cloud/container deployments), an attacker could set redirect_uri=http://localhost:8080/steal and intercept OAuth authorization codes if they can bind that port on the same host (shared environments, cloud VMs, browser extensions). Gate the localhost exception behind localMode so it only applies during development (bun run dev / --local-mode). Production deployments only allow redirect_uri matching the configured baseUrl origin. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.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.
Summary
The OAuth authorize endpoint at
app.ts:425-428allowedredirect_urito anylocalhostURL regardless of environment:In production (cloud/container deployments), an attacker could set
redirect_uri=http://localhost:8080/stealand intercept OAuth authorization codes if they can bind that port — possible on shared hosts, cloud VMs, or via browser extensions.Fix
Gate the localhost exception behind
localMode:Production only allows redirect_uri matching the configured
baseUrlorigin. Local dev (bun run dev/--local-mode) continues to allow localhost.Test plan
bun run fmt— passesbun run lint— passes (0 errors)redirect_urimatchingbaseUrlredirect_uri=http://localhost:8080/stealis rejected in production🤖 Generated with Claude Code
Summary by cubic
Restricts OAuth
redirect_urilocalhost allowance to local mode to close a production security gap. Prevents leaking authorization codes viahttp://localhost/...in cloud or container deployments.localhostredirects behindgetSettings().localMode; production now requires origin to matchbaseUrl.apps/mesh/src/api/app.tsand added clear comments on the risk and behavior.Written for commit 798c8f1. Summary will update on new commits.