DeepSeek V4.1 Flash · 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 Haiku 5.5.
- Gold bugs found
- 1 of 1
- Comments published
- 6
- Comments matching a bug
- 1
- Comments not matching
- 5
- Cost of this PR
- $0.339
Published comments (6)
Active-only Integration lookup blocks reinstalling inactive integrations — Filtering by `status=ObjectStatus.ACTIVE` makes a non-ACTIVE Integration return "Invalid installation request" even though `ensure_integration` in src/sentry/integrations/pipeline.py resets `status` to ACTIVE on reinstall. Drop the status filter so retries reach `ensure_integration`.
Pipeline state mutated before OAuth state validation — A request with a forged or invalid state still overwrites the victim's Redis-backed `installation_id` via `pipeline.bind_state`, so a later legitimate completion resolves the wrong installation in `GitHubInstallation.dispatch`. Bind `installation_id` only on the first, state-less request so rejected requests cannot mutate pipeline state.
GitHub OAuth callback state uses constant pipeline signature — `pipeline.signature` is the same constant for every user and org, so the callback check accepts any attacker-computed value and gives no CSRF protection. Generate a per-request nonce with `secrets.token_hex()`, bind it via `pipeline.bind_state`, and compare the callback against the stored value as `OAuth2LoginView`/`OAuth2CallbackView` do in src/sentry/identity/oauth2.py.
Unhandled GitHub OAuth token and user info failures return HTTP 500 — An expired code, a 401 from GitHub, or a network error escapes as an unhandled HTTP 500 instead of the error page, because `raise_for_status` in src/sentry/identity/github/provider.py and `safe_urlopen` both raise. Wrap the token request and `get_user_info` in the existing try/except and fall through to `error(request, self.active_organization)`.
KeyError when GitHub integration metadata lacks sender — `integration.metadata["sender"]` only exists for webhook-created integrations, so pipeline-created ones raise `KeyError` (HTTP 500) instead of showing the failure page; `installation.py:44` guards this same key. Read it with `(integration.metadata.get("sender") or {}).get("login")` and return `error(...)` when missing.
test_installation_not_found no longer tests installation-not-found — The second request passes a wrong `state`, so `OAuthLoginView.dispatch` returns at the state-mismatch guard and the `Integration.DoesNotExist` path is never exercised. Complete the OAuth step with the correct `pipeline.signature` state and assert "The GitHub installation could not be found."
Gold bugs found (1)
Gold bugs missed (0)
None.