Summary
An open redirect vulnerability in GitHub Enterprise Server's repository_pages API allowed attacker-controlled URLs to receive HTTP requests that still included privileged authorization headers.
When artifact URLs followed untrusted redirects, the server preserved a high-privilege JWT, enabling an authenticated attacker with redirect control to exfiltrate the token and potentially achieve remote code execution.
Affected context
This vulnerability occurs in GitHub Enterprise Server when the repository_pages API fetches artifact URLs and automatically follows HTTP redirects.
In affected configurations, redirect targets were not adequately constrained to trusted domains, and the HTTP client preserved authorization headers across redirects.
The issue is relevant where:
- Repository Pages artifacts are fetched via URLs that can be influenced by users
- Legacy or misconfigured redirects can point to attacker-controlled domains
- High-privilege JWTs (such as Actions.ManageOrgs) are attached to outgoing artifact fetch requests
Exploit preconditions
- Attack surface: Internal to the GitHub Enterprise Server instance, exposed via the repository_pages API behavior when fetching artifacts.
- Required access: Authenticated access to the target GitHub Enterprise Server instance, with the ability to trigger artifact fetches that follow redirects.
- Redirect control: Ability to exploit or configure a legacy redirect so that an artifact URL ultimately points to an attacker-controlled domain.
- Trigger point: An artifact fetch initiated by repository_pages that follows an HTTP redirect chain while retaining the authorization header.
- Why exploitation is possible: The HTTP client used by the API did not strip or constrain authorization headers on cross-origin redirects, allowing JWT-bearing requests to be sent to untrusted domains.
Why this happens
The core issue stems from improper handling of HTTP redirects combined with sensitive authorization headers.
When following redirects, the repository_pages API reused the same HTTP authorization header, including a privileged JWT, even when the redirect target pointed to a different, potentially attacker-controlled origin.
This aligns with CWE-601: URL Redirection to Untrusted Site, in which unvalidated or insufficiently constrained redirects lead users or server-side requests to attacker-owned domains.
In this case, the insecure pattern is a server-side HTTP client that:
- Accepts redirect responses without restricting the final destination to a trusted host or scheme
- Preserves sensitive headers across redirect boundaries instead of stripping or re-evaluating them
This combination turns an open redirect into a token exfiltration channel rather than a simple navigation flaw.
Potential impact
- Theft of a privileged Actions.ManageOrgs JWT via attacker-controlled redirect endpoints
- Privilege escalation inside the GitHub Enterprise Server environment using the stolen JWT
- Potential remote code execution through abuse of high-privilege Actions or organization management capabilities
- Unauthorized changes to repositories, organizations, or CI/CD pipelines
- Lateral movement and further compromise of source code, secrets, and build artifacts
General mitigation guidance
Effective mitigation centers on constraining redirects and protecting sensitive headers:
- Restrict redirect handling so that server-side HTTP clients only follow redirects to a vetted set of trusted domains or exact hostnames.
- Implement strict validation of redirect targets (scheme, host, and port) before following them; deny or log any redirects to untrusted origins.
- Strip or re-compute sensitive headers (such as Authorization, cookies, or custom auth tokens) on any redirect that crosses origin or domain boundaries.
- Use context-scoped, least-privilege tokens for server-to-server requests, minimizing the blast radius if a token is exposed.
- Architect internal APIs so that artifact resolution uses internal, authenticated endpoints rather than arbitrary external URLs where possible.
- Prefer secure-by-default HTTP client libraries or wrappers that disable automatic redirect following or enforce header-dropping policies across redirects.
How teams detect issues like this
Detection typically combines code-level analysis and behavioral monitoring:
- Static analysis and code review:
- Search for HTTP client usages that enable automatic redirect following (e.g.,
followRedirects = true, or equivalent). - Flag patterns where Authorization headers are attached to requests whose URLs are derived from user-controlled or indirectly controlled inputs.
- Review redirect validation logic to ensure hosts, schemes, and ports are explicitly whitelisted before being followed.
- Security testing:
- Implement automated tests that simulate redirects from internal endpoints to external domains and verify that sensitive headers are removed.
- Use dynamic application security testing (DAST) to probe redirect behavior of internal API clients for header leakage.
- Runtime monitoring:
- Monitor outbound HTTP requests from the GitHub Enterprise Server instance for calls that include high-privilege tokens to unexpected domains.
- Create alerts when requests with Authorization headers target domains outside the approved list.
- Automated code review tools and SAST platforms can be configured to detect unvalidated redirects and header persistence across redirects as policy violations.

