Skip to content

fix: pass JWT via URL fragment instead of query param in mobile redirect#146

Open
MehtabSandhu11 wants to merge 1 commit into
Dev-Card:mainfrom
MehtabSandhu11:fix/jwt-mobile-redirect-fragment
Open

fix: pass JWT via URL fragment instead of query param in mobile redirect#146
MehtabSandhu11 wants to merge 1 commit into
Dev-Card:mainfrom
MehtabSandhu11:fix/jwt-mobile-redirect-fragment

Conversation

@MehtabSandhu11
Copy link
Copy Markdown

Fixes the mobile OAuth redirect in auth.ts to pass the JWT token via a URL fragment (#) instead of a query parameter (?).
Problem
Both the GitHub and Google OAuth callbacks were redirecting mobile users with the JWT as a plain query parameter:
tsreturn reply.redirect(${mobileRedirect}?token=${token});
This meant the JWT (valid for 30 days) was:

Visible in server access logs
Stored in browser/webview history
Potentially captured by analytics or proxy tools
Exposed to any third-party JavaScript reading location.href

Fix
Changed ? to # so the token is passed as a URL fragment:
tsreturn reply.redirect(${mobileRedirect}#token=${token});
URL fragments are never sent to the server in HTTP requests, so the token won't appear in access logs or be forwarded to proxies.
Files Changed

apps/backend/src/routes/auth.ts

Related
Closes #122

@Harxhit Harxhit added the gssoc:approved Required label for every approved PR. Gives the base +50 points and enables contribution tracking. label May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved Required label for every approved PR. Gives the base +50 points and enables contribution tracking.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[security] JWT token exposed in mobile redirect URL — visible in logs and browser history

2 participants