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