Repository navigation
fix: authenticate and session-bind the GitHub integration OAuth callback - #981
Merged
Merged
Conversation
rohan-chaturvedi
force-pushed
the
fix/github-integration-callback-ssrf
branch
4 times, most recently
from
August 18, 2026 13:49
0d8c932 to
347ae3a
Compare
rohan-chaturvedi
force-pushed
the
fix/github-integration-callback-ssrf
branch
from
August 18, 2026 18:10
c463ce5 to
8935bf6
Compare
nimish-ks
approved these changes
Aug 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔍 Overview
Patches the GitHub secret-sync integration OAuth callback with various security hardening.
Full details are covered in a separate security advisory.
💡 Proposed Changes
github_integration_authorizeendpoint. It requires a logged-in user, checks the caller'sIntegrationCredentials: createpermission on the target org, generates a randomstatenonce, and binds the org / host / name / return URL to the server session before redirecting to GitHub.github_integration_callback. It validates thestateagainst the session nonce, reads all sensitive parameters from the session (never the request), consumes them (one-time use), and re-checks authentication + permission before exchanging the code. This is what closes the unauthenticated code path.github.com; on self-hosted, admin-configured GitHub Enterprise Server URLs (incl. internal hosts) continue to work unchanged.SetupGhAuth.tsxnow hands off to the backend authorize endpoint instead of building the OAuthstateclient-side.🖼️ Screenshots or Demo
N/A — no visible UI change; only the flow's initiation target and redirect handling change.
🧪 Testing
backend/tests/api/views/test_github_callback.py(13 tests): unauthenticated rejection, missing/forgedstate, permission enforcement (authorize + callback), cloud host-pinning +isEnterprisecoercion, self-hosted internal GHE allowed, bad-scheme rejection, session-sourced (not query-sourced) host/org, one-time-use state, and the open-redirect guard.tests/api/views/passes (247),python manage.py checkclean, frontendtsc --noEmitandeslintclean on the changed file.🎯 Reviewer Focus
Start in
backend/api/views/auth.py: the newgithub_integration_authorizeand the rewrittengithub_integration_callback— specifically that every trusted value comes fromrequest.sessionafter the nonce check, and the cloud vs. self-hosted host policy. Thenfrontend/components/syncing/GitHub/SetupGhAuth.tsxfor the initiation change.➕ Additional Context
Supersedes #806, which added
validate_url_is_safeonly — insufficient here (doesn't stop exfiltration to a public host, leaves the endpoint unauthenticated, and would reject legitimate internal GHE). Full security advisory published separately.✨ How to Test the Changes Locally
docker compose -f dev-docker-compose.yml up -d).IntegrationCredentials: create, connect a GitHub credential from an app's syncing/integrations screen — the flow should complete and store the credential.GET /service/oauth/github/callback?code=x&state=yshould redirect to?error=invalid_stateand perform no token exchange.💚 Did You...
django check+ frontendtscclean