Kimi K3.1 Pro · 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
- 8
- Comments matching a bug
- 1
- Comments not matching
- 7
- Cost of this PR
- $2.105
Published comments (8)
Predictable OAuth state allows authorization code injection — Because `pipeline.signature` is a deterministic MD5 of static view class names, its OAuth `state` is shared across installations and users, enabling authorization-code injection into a victim's pipeline. Generate a random nonce per attempt, bind it in pipeline state, and validate the callback against it.
Installer verification is skipped when the integration does not yet exist — When `Integration.DoesNotExist` advances the pipeline, `build_integration` creates the integration from `installation_id` without consuming `github_authenticated_user`; a delayed or missing webhook then lets any authenticated GitHub user attach another user's installation. Require trusted installer evidence before either the new or existing integration path advances.
Variable-based gettext leaves short installation errors untranslated — Because `_(error_short)` translates a variable, gettext cannot extract its literals; `Invalid installation request.` remains untranslated, and existing translations can disappear when catalogs regenerate. Mark each literal for translation at its definition or call site, then pass the value without wrapping `error_short` in `_`.
OAuth state comparison leaks timing information — Normal string comparison can expose prefix-dependent timing for the OAuth `state` CSRF credential. Convert the request value to a string and use `django.utils.crypto.constant_time_compare` instead of `!=` when checking `pipeline.signature`.
Missing-installation test is short-circuited by invalid OAuth state — The invalid `state` makes `OAuthLoginView` reject the callback before `GitHubInstallation` handles the unknown `installation_id`, so this test passes even if missing-installation handling is broken. Complete OAuth with the pipeline's real signature and assert `The GitHub installation could not be found.`
Ownership verification uses mutable GitHub login instead of immutable user ID — Persisting only GitHub's mutable `login` lets another account claim an installer's old username after a rename and satisfy the ownership check, although `/user` and webhook `sender` both provide an immutable `id`. Bind the numeric user ID and compare it with `integration.metadata['sender']['id']`, keeping `login` only for display. **Also found in:** - `src/sentry/integrations/github/integration.py:500-505`
OAuth token request failures bypass installation error handling — With `safe_urlopen` outside the `try`, connection, DNS, TLS, and timeout failures escape `dispatch`, producing a 500 instead of the installation-error response. Move the token request into the handled path, catch the HTTP client's request exceptions, and return `error(request, self.active_organization)` when the exchange fails.
Missing sender metadata raises KeyError during GitHub reinstall — An active integration without `metadata.sender` raises `KeyError` on reinstall, although `build_integration` can legitimately omit it, producing a 500 instead of an installation-failure response. Read the sender defensively and reject or reconstruct the installation when trusted sender metadata is absent.
Gold bugs found (1)
Gold bugs missed (0)
None.