Repository navigation
fix: validate OAuth state on the web-flow callback - #3444
Merged
Merged
Conversation
setchy
force-pushed
the
fix/validate-oauth-web-flow-state
branch
3 times, most recently
from
October 17, 2026 02:20
d1ea458 to
b9c6c73
Compare
Generate a per-attempt random `state` for the GitHub OAuth App web-flow login and accept a `gitify://oauth` callback only when it echoes that state. A callback carrying a missing or mismatched state is logged and ignored, so an injected callback can neither bind the client to another GitHub account (login-CSRF) nor tear down the pending login. Treat an unparseable `gitify://` callback URL the same way: log and ignore instead of rejecting, since a forged URL (e.g. `gitify://[`) passes the protocol handler's prefix check but cannot carry a valid state and would otherwise abort a legitimate login. Generate the state with `crypto.randomUUID()` and cover it with unit tests.
setchy
force-pushed
the
fix/validate-oauth-web-flow-state
branch
from
October 17, 2026 02:23
b9c6c73 to
b813909
Compare
|
Member
Author
|
After a little more thought, i think we can retire this whole OAuth flow completely. PR cooking 👨🍳 |
Member
Author
Contributor
|
🎉 This pull request is included in Gitify v7.10.0! 🎉 Downloads for macOS, Windows, and Linux are available on the release page. Thanks for helping make Gitify better! |
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.



What
Generate a per-attempt, cryptographically random OAuth
statefor the GitHub OAuth App web-flow login, and accept agitify://oauthcallback only when it echoes that state.The
gitify://custom-protocol handler is registered at the OS level and can be triggered from a webpage, an email, or another local app. PreviouslyperformGitHubWebOAuth()never sent astateandhandleCallback()never checked one, so any authorization code delivered throughgitify://oauth?code=...was accepted and exchanged for a token. An attacker could complete GitHub's authorize step for their own account and have the code delivered to a victim's running Gitify, silently binding the victim's client to the attacker's account (login-CSRF, CWE-352).Fixes #3425. Supersedes #3424 — thanks to @carfeii for reporting the issue and proposing the original fix; this branch re-implements that approach on
main.Changes
performGitHubWebOAuth()generates one randomstateper attempt (viagenerateOAuthState()) and passes it togetWebFlowAuthorizationUrl; it reads the state back from the result so the value compared on callback is exactly the one embedded in the authorization URL.handleCallback()compares the callback'sstatewith the attempt's: a missing or mismatched state is logged and ignored, so it does not resolve, reject, or tear down the still-pending legitimate login.gitify://…?error=…delivery can no longer abort a pending login.gitify://callback URL (e.g.gitify://[, which passes the protocol handler's prefix check) is likewise logged and ignored instead of rejecting, so it cannot abort a pending login before the state is compared.generateOAuthState()insrc/renderer/utils/auth/state.ts, backed bycrypto.randomUUID().Testing
pnpm test— 190 files, 1913 tests passpnpm lint:checkandpnpm check— cleanNot changed
The device flow, PAT login, CLI login, and non-GitHub forges are unchanged.