DeepSeek V4 Pro · Heavy

github-oauth-security-enhancement-sentry

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

The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. Judge: Claude Opus 5.5.

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

Published comments (5)

highsecuritysrc/sentry/integrations/github/integration.py:401-409

GitHub OAuth state uses constant signature instead of per-session CSRF token — A constant signature means the state check can be precomputed and reused by an attacker, defeating the CSRF protection it is meant to provide. Generate a per-request random token with `secrets.token_hex()` and validate it via `pipeline.fetch_state("state")` as `OAuth2LoginView`/`OAuth2CallbackView` do.

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

GitHub OAuth token exchange missing redirect_uri — Omitting `redirect_uri` from the token exchange causes GitHub to reject it with `error=redirect_uri_mismatch`, so every installation fails with a generic error page. Include the same `redirect_uri` used in the authorize URL, plus `grant_type`.

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

Unhandled GitHub OAuth callback network exceptions return 500 — A transient network or HTTP failure in `safe_urlopen` or `get_user_info` escapes as an unhandled 500 instead of the intended error page. Wrap both calls in the try block and return `error(request, self.active_organization)`.

mediumbugtests/sentry/integrations/github/test_integration.py:388-396

test_installation_not_found uses invalid state and does not test missing installation — The hardcoded `state` is rejected by `OAuthLoginView` before `GitHubInstallation.dispatch` runs, so this test no longer covers its namesake scenario. Use the valid pipeline signature and assert the actual missing-installation outcome, or rename the test to match what it checks.

mediumbugsrc/sentry/integrations/github/integration.py:501-505

KeyError when GitHub integration metadata lacks sender key — Integrations without a `sender` key exist, as `installation.py:44` guards against them; accessing it directly raises `KeyError` and returns a 500. Use `integration.metadata.get("sender", {}).get("login")` or guard the missing case.

Gold bugs found (4)

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.
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.

Gold bugs missed (3)

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.
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.