DeepSeek V4.1 Flash · Balanced

github-oauth-security-enhancement-sentry

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

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

Gold bugs found
0 of 1
Comments published
5
Comments matching a bug
0
Comments not matching
5
Cost of this PR
$0.135

Published comments (5)

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

OAuth state uses pipeline signature instead of per-flow nonce — `pipeline.signature` is a constant md5 of the view class names, so it can't bind the callback to the browser that started the flow, leaving the login-CSRF open. Generate a per-flow nonce with `secrets.token_hex()`, bind it via `pipeline.bind_state`, and compare against `pipeline.fetch_state`.

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

OAuth token exchange omits redirect_uri and grant_type — The exchange omits `redirect_uri`, so it no longer matches the authorization request per RFC 6749 and relies on GitHub's registered callback; if `absolute_uri` differs there, users hit the generic failure page. Pass the same `redirect_uri` and `grant_type=authorization_code` into the exchange `data`.

highsecuritysrc/sentry/integrations/github/integration.py:448-455

GitHub install skips ownership check when Integration row is absent — When the webhook hasn't created the `Integration` yet, the `Integration.DoesNotExist` branch calls `next_step()` and `build_integration` without checking that the authenticated GitHub user owns the `installation_id`, letting an attacker link another account's installation. Resolve the installation's `sender` from the GitHub API, or require the webhook-created `Integration`, and run the comparison on both branches. **Also found in:** - `src/sentry/integrations/github/integration.py:481-482`

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

Missing sender metadata crashes GitHub installation pipeline — Pipeline-created integrations never get a `sender` key in `integration.metadata` (only `build_integration` sets it), so indexing `["sender"]["login"]` raises and returns a 500 instead of the failure page. Use `integration.metadata.get("sender", {}).get("login")` and treat a missing value as failed verification.

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

GitHub OAuth token and user-info errors cause 500 — `safe_urlopen` and `get_user_info` can raise (HTTP errors, connection errors, the 30s timeout) outside the guarded block, producing a 500 instead of the `github-integration-failed` page. Wrap both calls in try/except and return `error(...)` on failure.

Gold bugs found (0)

None.

Gold bugs missed (1)

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.