Repository navigation
fix: validate redirects on integration requests to customer-supplied hosts - #1126
Merged
Merged
Conversation
Organisation listing looked for the API host under a different credential key than repository and environment listing, so it always used the GitHub.com API. Read the same key as the other two. The new test runs the three listing calls with the credentials the OAuth callback stores, for GitHub.com and for GitHub Enterprise.
nimish-ks
approved these changes
Nov 12, 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
Hardening for outbound requests that integrations make to a host the customer supplies (self-hosted GitHub, Vault, Nomad). On Phase Cloud the host is already checked before a request is made; that check now also applies to every redirect a request follows, so all hops are held to the same rule as the first.
💡 Proposed Changes
api/utils/safe_requests.py: a smallrequests.Sessionsubclass (plusget/put/delete/requesthelpers) that, on Phase Cloud, runsvalidate_url_is_safeon every request it sends, redirects included. Self-hosted deployments are unaffected.requests.RequestExceptionsubclass, so each provider's existing error handling reports it.🖼️ Screenshots or Demo
N/A — backend change, no UI surface.
📝 Release Notes
Hardened outbound request handling for integrations that connect to customer-supplied hosts.
Fixed: organisation listing for GitHub Enterprise credentials now calls the Enterprise host.
❓ Open Questions
N/A
🧪 Testing
requests' real redirect handling over a fake transport and fake DNS: redirects are checked on every hop on Phase Cloud, allowed redirects are still followed, self-hosted behaviour is unchanged, and each provider (GitHub Actions, Dependabot, Nomad, Vault, AWS IAM identity) is covered end to end.🎯 Reviewer Focus
backend/api/utils/safe_requests.py(SafeSession.send), then the call sites inapi/utils/syncing/{github,nomad,vault}andapi/views/identities/aws/iam.py. For the GitHub Enterprise fix:list_orgsinapi/utils/syncing/github/actions.py.➕ Additional Context
N/A
✨ How to Test the Changes Locally
docker compose -f dev-docker-compose.yml exec backend pytest \ tests/api/utils/test_safe_requests.py \ tests/utils/syncing/test_github_actions.py \ tests/utils/syncing/test_github_dependabot.py \ tests/api/views/identities/aws/test_iam_unit.py💚 Did You...