GLM-5.3 Flash · Balanced

github-oauth-security-enhancement-sentry

Sentry · Python · M · 100–299 lines · 2 files

The normal review, with one generalist agent. Judge: Claude Opus 5.5.

Gold bugs found
3 of 7
Comments published
4
Comments matching a bug
3
Comments not matching
1
Cost of this PR
$0.072

Published comments (4)

highbugsrc/sentry/integrations/github/integration.py:500-505

KeyError on missing metadata["sender"] in GitHub install check — Integrations built by the install pipeline never get a sender, so the whole install flow turns into a 500; installation.py already treats the key as optional. Switch to `integration.metadata.get("sender", {}).get("login")` so a missing sender lands on the error page.

highbugsrc/sentry/integrations/github/integration.py:415-423

Token exchange omits redirect_uri sent in authorize request — GitHub requires the token-step redirect_uri to match the authorize-step value, so real installations can fail at the exchange while tests pass because the endpoint is mocked in `_stub_github`. Add the same `absolute_uri` value the authorize leg builds to `data`.

mediumsecuritysrc/sentry/integrations/github/integration.py:401-413

CSRF state uses predictable pipeline signature instead of per-flow nonce — Because `pipeline.signature` is a deterministic md5 of class names, identical for every flow and derivable from source, this gate verifies nothing — any caller can supply the constant. Generate a random nonce, bind it with `pipeline.bind_state`, and compare against `pipeline.fetch_state`, as identity/oauth2.py does.

mediumbugsrc/sentry/integrations/github/integration.py:434-436

Unwrapped get_user_info call raises unhandled exception on GitHub API errors — A rate limit or transient 5xx makes `get_user_info` raise through `resp.raise_for_status()`, showing a 500 in the install dialog, unlike the guarded token exchange just above. Wrap it in try/except and return `error(request, self.active_organization)`.

Gold bugs found (3)

highThe GitHub OAuth state is pipeline.signature, a static md5 of the pipeline view names, instead of a per-attempt random nonce, so it gives no CSRF protection.
mediumThe new OAuth step's token exchange and user lookup are not wrapped in error handling, so GitHub/network failures surface as 500s instead of the installation-failed page.
highThe installer check indexes integration.metadata['sender']['login'] without checking that sender exists, raising KeyError for integrations created without sender metadata.

Gold bugs missed (4)

highWhen no Integration exists yet for the installation_id the pipeline advances without comparing the OAuth user to the installer, bypassing the new ownership check.
mediumtest_installation_not_found uses a wrong OAuth state, so it fails at the state check and never reaches the installation-not-found path it is meant to test.
mediumGitHubInstallation re-fetches the existing Integration filtered by status=ACTIVE and errors if not found; an Integration with this external_id that is not ACTIVE and has no OrganizationIntegration now gets the generic 'Invalid installation request' page instead of advancing so ensure_integration can reactivate it, blocking re-installs.
highThe new installer-ownership check stores and compares GitHub's mutable login (OAuth /user login vs metadata sender.login) instead of the immutable numeric id; after the installer renames, another account that claims the old login passes the check and can link the installation.