Repository navigation
Description
Problem
src/app/auth/callback/CallbackClient.tsx handles the return leg of the GitHub OAuth redirect described in the README ("Connect GitHub button redirects to backend's OAuth endpoint"). OAuth callback handlers are a classic CSRF/open-redirect surface: if this client component reads a token or redirect target from URL query parameters without validating a state parameter round-trip, or if it trusts a redirect_to/next query param to send the user onward after login without an allowlist, it's vulnerable to an attacker crafting a link that completes a victim's real OAuth login but then redirects them to an attacker-controlled page (open redirect) or, worse, if state isn't verified, allows a CSRF login fixation where an attacker's OAuth session gets bound to a victim's browser.
Why this is hard
- You need to actually read
CallbackClient.tsxand trace exactly what it does with the URL (query params consumed, what's passed tologin()inAuthContext, whetherstateis checked at all) since none of this is documented, and OAuthstatevalidation might be entirely delegated to the backend (in which case the frontend's job is just to relay it correctly) or might be missing on both ends. - Testing this requires constructing realistic malicious callback URLs (missing state, mismatched state, absolute-URL redirect targets, javascript: URIs in a redirect param if one exists) and confirming the app rejects them — this is adversarial testing, not just a code read.
- If
redirect_tosupport exists (common pattern: "log in, then return to the bounty you were viewing"), it needs a strict allowlist (relative paths only, no protocol-relative//evil.comURLs, which are a frequently-missed open-redirect bypass) — you'll need to check whether Next.js'sredirect()/router.push()usage here is vulnerable to protocol-relative URL tricks. - The token handoff itself: does the backend put the JWT in the callback URL as a query param (visible in browser history, referrer headers, server logs — bad) or in a way
CallbackClient.tsxretrieves more safely? If it's in the URL, that's a separate hardening item to flag/fix (strip it from history viahistory.replaceStateat minimum, and note as a cross-repo issue if the backend should be doing this differently, e.g. a one-time code exchange instead).
Scope
- Audit
CallbackClient.tsxforstateparameter validation; add it if missing (client-side check, with backend coordination noted if the state must be verified server-side, i.e. issued and checked bymergefi-backend). - Add strict allowlisting for any post-login redirect target (relative-only, reject protocol-relative and absolute URLs).
- If the JWT arrives via URL query param, strip it from browser history immediately after reading it and flag the pattern as a cross-repo hardening item in the PR description.
- Add tests for malformed/malicious callback URLs.
Acceptance criteria
- A callback URL with a missing/mismatched
stateis rejected with a clear error, not silently logged in. - A callback URL with
redirect_to=//evil.comorredirect_to=https://evil.comdoes not redirect off-site. - No JWT persists in browser history after the callback completes.
Activity
thelight08 commentedon Aug 25, 2026
@thelight08 has applied to work on this issue as part of the Stellar Wave Program's 8th wave.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @thelight08 to this issue.
devgodfreytem commentedon Aug 25, 2026
@devgodfreytem has applied to work on this issue as part of the Stellar Wave Program's 8th wave.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @devgodfreytem to this issue.
drips-wave commentedon Aug 25, 2026
Congratulations, @devgodfreytem! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on August 31, 2026.
🧑💻 @devgodfreytem: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.
Warning
When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.
🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.
🌊 Happy Wave 🌊
fix: add Freighter network-mismatch guard and harden OAuth callback
drips-wave commentedon Aug 25, 2026
This issue has been completed by @devgodfreytem as part of the Stellar Wave Program's 8th Wave 🥳
😎 @devgodfreytem: You earned 200 Points for completing this issue! After the current Wave ends, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.
🧑💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.