Amazon Ergo 1.0 · 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
- 5 of 7
- Comments published
- 6
- Comments matching a bug
- 5
- Comments not matching
- 1
- Cost of this PR
- $2.572
Published comments (6)
Deterministic GitHub OAuth state defeats CSRF protection — Because `pipeline.signature` is identical across users and sessions, an attacker can supply a known `state` and bind their GitHub identity to a victim's pipeline. Generate a cryptographically random per-session value with `secrets.token_hex()`, store it via `pipeline.bind_state`, and validate it with `pipeline.fetch_state`, following `sentry/auth/providers/oauth2.py`.
New GitHub installations skip sender/authenticity verification — A victim's organization can be linked to an attacker's GitHub installation because the `Integration.DoesNotExist` branch skips the `github_authenticated_user` check. Verify the installer/sender in this branch too, or defer linking until that identity can be checked. **Also found in:** - `src/sentry/integrations/github/integration.py:493-498`
OAuth state uses a timing-unsafe comparison — A timing leak on this security token can reveal a valid `state` byte by byte. Replace the `!=` check with `django.utils.crypto.constant_time_compare`, matching the existing convention for token validation.
Missing sender metadata raises KeyError instead of showing error page — An existing integration without sender metadata raises `KeyError` and returns a 500 instead of the intended error page. Use safe `dict.get` lookups on `integration.metadata` and fail closed when `sender` or `login` is absent, matching `GitHubIntegrationsInstallationEndpoint` in `installation.py`.
GitHub token request failures escape the OAuth error handling — Token-endpoint failures can escape as unhandled exceptions and return a 500 instead of the intended error page. Move `safe_urlopen()` inside the `try` so connection and HTTP failures fall through to `error()`.
test_installation_not_found uses an invalid OAuth state — The hard-coded callback `state` is rejected before installation lookup, so the test can pass even if installation-not-found handling is broken. Extract `state` from the OAuth redirect and assert the specific installation-not-found error.