Kimi K3.1 Pro · 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
1 of 1
Comments published
7
Comments matching a bug
1
Comments not matching
6
Cost of this PR
$1.275

Published comments (7)

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

Predictable OAuth state allows cross-session pipeline injection — `pipeline.signature` is deterministic and publicly observable, so an attacker can reuse `state` with their own OAuth code to inject `github_authenticated_user` into another session's pipeline. Generate a random per-pipeline nonce, save it with `pipeline.bind_state`, and validate callbacks using `pipeline.fetch_state`.

mediumsecuritysrc/sentry/integrations/github/integration.py:500-505

Fresh GitHub integrations bypass installer identity verification — When the installation webhook is missing or delayed, the `Integration.DoesNotExist` branch reaches `build_integration` without checking the installer, letting any OAuth-authenticated GitHub user attach an installation by ID. Fail closed until sender metadata exists, or enforce equivalent installer validation before completing that branch.

mediumsecuritysrc/sentry/integrations/github/integration.py:438

GitHub installation identity check uses mutable usernames — Comparing GitHub's mutable `login` with `sender.login` lets a different account that later claims the old username pass after the original user renames their account. Persist `authenticated_user_info["id"]` and compare it with `integration.metadata["sender"]["id"]`, using GitHub's immutable account IDs.

mediumbugsrc/sentry/integrations/github/integration.py:501-504

Missing sender metadata raises KeyError during GitHub installation — An active integration from `build_integration` can lack sender state when no `OrganizationIntegration` exists, so indexing `integration.metadata["sender"]["login"]` raises `KeyError` and turns a retry into a 500. Use a guarded sender lookup and return the invalid-installation error when sender metadata is absent.

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

GitHub OAuth request failures escape dispatch and cause a 500 — Because `safe_urlopen` and `get_user_info` run outside the parsing `try`, connection, SSL, timeout, and `/user` non-2xx failures escape `dispatch` and produce a 500. Catch upstream request exceptions around both calls and return `error(request, self.active_organization)` instead.

mediumbugsrc/sentry/integrations/github/integration.py:416-420

OAuth token request omits the authorization redirect_uri — Omitting `redirect_uri` from `data` violates OAuth 2.0's requirement to repeat the authorization value and allows GitHub to reject the token exchange. Add the identical `redirect_uri` computed for the authorization request.

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

Wrong OAuth state prevents test_installation_not_found from exercising the 404 — `test_installation_not_found` exits at the state-mismatch branch because it uses `ddd023...`, so it passes without reaching the intended GitHub installation 404. Use the `9cae...` signature from `assert_setup_flow` and assert the `The GitHub installation could not be found.` response.

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.