Skip to content

Ask before handing an app its sign-in code - #49

Merged
ssenerg merged 1 commit into
mainfrom
app-handoff-confirm
Nov 2, 2026
Merged

ssenerg merged 1 commit into
mainfrom
app-handoff-confirm

Conversation

@ssenerg

@ssenerg ssenerg commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Closes, as far as a custom scheme allows, the gap noted in #48: the server sent an app's code straight to io.github.ssenerg.gochat:/sso, which any app may claim.

The attack

Someone begins an app sign-in with their own PKCE challenge and sends the link /login/sso/<provider>?app=<challenge>. The victim opens it and is signed in at the provider without being asked. The server then redirects to the custom scheme with a code for the victim's account. If a malicious app on the victim's device claims the scheme, it forwards the code, and the sender redeems it with their verifier. PKCE doesn't help here, because the attacker began the flow. The same works for an app's link: it would link the victim's provider account to the sender's GoChat account.

The fix

The server no longer hands a code over by itself. This follows RFC 8252 §8.6: when a client's redirect can't prove which app it reaches, ask the person every time.

  • The callback now shows a page instead of redirecting. The page names the GoChat account and what the code does:
    • sign in to the app as @ann with ann@corp.test;
    • sign in to @ann with that account from now on (a link);
    • tell the app it's @ann so it can delete the account (a sign-in again).
  • The page warns against links someone sent. The code goes to the app only when the person taps Continue in the app, a plain link to the scheme.
  • For a link, the page names the account the link goes to. Someone sending you a link to their own account is plain to see.
  • Errors still go straight back to the app: they carry no code.
  • FinishSSOResponse gains app_code_use (a new AppCodeUse enum), app_username and email, so the web can say all this. The apps need no change: their browser sheet shows the page and comes back on the tap.

Why not claimed HTTPS redirects

App Links and Universal Links would close this for good, but they don't fit GoChat:

  • The apps connect to any server, so every server's domain would have to be built into the app.
  • Universal Links need an Apple team that can sign Associated Domains.
  • iOS needs 17.4 for HTTPS callbacks in ASWebAuthenticationSession, and the app supports 16.

Tests

  • go test -race ./..., golangci-lint v2.15.0 (0 issues), buf lint, buf breaking against main.
  • Web: the sign-in, link and sign-in-again pages each name the account and use, link the code, and don't redirect.
  • Accounts: each app code carries its use and account. A link begun by carol names carol even when the browser is signed in as dave.
  • :core:jvmTest passes. The iOS app builds (xcodebuild ... CODE_SIGNING_ALLOWED=NO).
  • Not checked: the page on a device, or tapping through it in a Custom Tab or ASWebAuthenticationSession.

A link anyone sends can begin an app's sign-in with their own PKCE challenge, and another app on the person's device may claim the apps' scheme, so the browser no longer goes straight back to the app with a code. The server's page names the GoChat account and what the code does (sign in, link, or sign in again to delete), warns against links someone sent, and gives the code to the app only when the person taps Continue. FinishSSO says what an app's code does, and for whom, with app_code_use, app_username and email.
@ssenerg
ssenerg merged commit df56527 into main Nov 2, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant