Claude Opus 5.5 · 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
$2.608

Published comments (6)

highsecuritysrc/sentry/integrations/github/integration.py:481-482

Ownership check skipped when the installation's Integration row doesn't exist yet — An attacker who submits a victim's `installation_id` before the installation webhook creates the row skips the ownership check, and `build_integration` links the victim's installation to the attacker's org. Verify `github_authenticated_user` against the installation's sender via the app client, or fail closed when it can't be verified.

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

OAuth state is a predictable constant, enabling login CSRF on the GitHub callback — Since `pipeline.signature` is an md5 of view class names (see pipeline/base.py), an attacker can send a victim their own `code` with the known `state`, recording the attacker's login as `github_authenticated_user` and defeating the installer check. Generate a random state with `secrets.token_hex`, store it via `pipeline.bind_state`, and compare on callback.

highbugsrc/sentry/integrations/github/integration.py:501-505

KeyError when integration metadata lacks "sender" on reinstall — Since `build_integration` only writes `metadata["sender"]` when pipeline state has a sender, reinstalling such an integration after its `OrganizationIntegration` is removed raises `KeyError` and returns a 500. Read it with `integration.metadata.get("sender", {}).get("login")` and return `error()` when it's missing.

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

Unhandled token exchange and get_user_info failures return a 500 — A network error, or a 401/5xx from GitHub on a revoked `code`, escapes `safe_urlopen` or `get_user_info` (via `resp.raise_for_status()`) and returns a 500. Wrap both calls in try/except and return `error(request, self.active_organization)` on failure.

mediumbugtests/sentry/integrations/github/test_integration.py:388-396

test_installation_not_found never reaches the 404 installation lookup — With unstubbed OAuth endpoints and a `state` that differs from the pipeline signature, `test_installation_not_found` likely fails in `OAuthLoginView` and would still pass with broken 404 handling. Drive a valid OAuth step and assert on "The GitHub installation could not be found." again.

mediumbugtests/sentry/integrations/github/test_integration.py:448-454

User-mismatch test asserts only a generic error shared by other failures — State mismatch, OAuth failure and the missing ACTIVE `Integration` branch all return "Invalid installation request.", so `test_github_user_mismatch` passes even without the sender-login comparison. Assert the earlier steps succeed (`Integration` is ACTIVE with sender login 'attacker'), or give the mismatch its own message and assert on it.

Gold bugs found (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.

Gold bugs missed (0)

None.