fix(auth): validate mobile OAuth redirect URI against scheme allowlist#390
Open
Ridanshi wants to merge 2 commits into
Open
fix(auth): validate mobile OAuth redirect URI against scheme allowlist#390Ridanshi wants to merge 2 commits into
Ridanshi wants to merge 2 commits into
Conversation
Contributor
Author
|
Hi, could someone please review this PR when convenient? I've completed the implementation and tested it locally. Happy to make any required changes. Thanks! |
Harxhit
reviewed
Jun 7, 2026
Harxhit
left a comment
Collaborator
There was a problem hiding this comment.
Please fix linting errors.
7322cca to
f58b2a7
Compare
|
@Ridanshi is attempting to deploy a commit to the Prashantkumar Khatri's projects Team on Vercel. A member of the Team first needs to authorize it. |
CI — Checks FailedBackend — PASS
Mobile — PASS
Web — FAIL
Last updated: |
66c3108 to
a661f17
Compare
Collaborator
|
It looks like this PR still uses the previous |
Add isSafeMobileRedirectUri() to validate the embedded redirect URI against an explicit scheme allowlist before embedding in or extracting from OAuth state. Resolves lint and typecheck errors in cards route and auth service.
The repository migrated from pnpm workspaces to npm in 4071cbc but several files were not updated at that time: - .github/pull_request_template.md: checklist items still referenced `pnpm -r run lint/typecheck/test`; replaced with the npm --prefix equivalents used by CI. - .gitignore: removed pnpm-debug.log* (pnpm is no longer installed). - apps/web/.gitignore: same pnpm-debug.log* removal. - apps/mobile/jest.config.js: removed the \.pnpm/ virtual-store branch from the transformIgnorePatterns regex (dead code under npm).
a661f17 to
b307e32
Compare
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.
Closes #185
Problem
The GitHub and Google OAuth initiation endpoints accept a
mobile_redirect_uriquery parameter and embed it into the OAuth state without validation. During the callback flow, the value is decoded and used as the redirect destination for the user's JWT.This allows an attacker to supply an arbitrary redirect URI and receive a victim's authentication token after a successful OAuth login flow.
Example:
In this scenario, a victim who completes authentication could be redirected to an attacker-controlled destination containing their JWT.
Root Cause
mobile_redirect_uriwas accepted directly from user-controlled input and embedded into the OAuth state. The callback flow later trusted and used the decoded value without validating whether it was a legitimate mobile application redirect target.Solution
Introduce explicit allowlist validation for mobile redirect URIs.
Allowed schemes:
devcard://exp://The validation is applied in two places for defense in depth:
If a supplied URI does not match the allowlist, it is ignored and the flow falls back to
MOBILE_REDIRECT_URI.Changes
isSafeMobileRedirectUri()helper.Tests
Added 19 unit tests covering:
http,https,javascript, malformed values)All existing and new tests pass successfully.
Impact
Low risk.
The change only affects untrusted redirect URIs supplied through
mobile_redirect_uri. Existing valid mobile authentication flows continue to function normally, while unsafe redirect destinations are rejected.Security Benefit
Prevents authentication token leakage through attacker-controlled redirect destinations and ensures OAuth tokens are only delivered to trusted mobile application schemes.