DeepSeek V4 Pro · 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
- 4 of 7
- Comments published
- 4
- Comments matching a bug
- 4
- Comments not matching
- 0
- Cost of this PR
- $0.436
Published comments (4)
OAuth state uses deterministic pipeline signature, enabling CSRF — A deterministic state provides no CSRF protection: an attacker can precompute it and inject their own authorization code into a victim's active pipeline. Generate a per-session token with `secrets.token_hex()`, bind it via `pipeline.bind_state("state", ...)`, and validate with `pipeline.fetch_state("state")` on return, as `OAuth2LoginView` and `OAuth2CallbackView` already do.
KeyError when GitHub integration metadata lacks sender — Integrations without `sender` exist and crash this path with a 500. Use `integration.metadata.get("sender", {}).get("login")` and return `error(...)` when the login is absent instead of indexing directly.
GitHub sender validation is skipped when Integration row does not exist — When the Integration row does not exist, the `except Integration.DoesNotExist` branch returns `pipeline.next_step()` before this validation, so the user match is never enforced if the webhook loses the race against the redirect. Move the sender check before that early return, or enforce it in `build_integration` before the integration is created.
get_user_info call can raise unhandled exceptions during OAuth — `get_user_info` can raise on 401/403/5xx via `raise_for_status()` and on invalid JSON via `resp.json()`, surfacing as an unhandled 500 rather than the user-facing error page. Wrap the call in try/except and return `error(request, self.active_organization)` on failure.