Summary
An improper authorization vulnerability in GitHub Enterprise Server's scoped user-to-server (ghu_) token handling can allow an authenticated attacker to access private repositories outside the intended installation scope, including performing write operations.
Under specific revocation and fallback conditions, a revoked or deleted installation could be treated as a global context, enabling unauthorized access and potential reuse of a victim's scoped token.
Affected context
This vulnerability arises in GitHub Enterprise Server environments that:
- Use scoped user-to-server (ghu_) tokens for app or automation integrations
- Rely on installation-bound scopes to restrict repository access
- Experience installation revocation or deletion events where token usage continues briefly
The issue manifests when the authorization system falls back to a broader, effectively global installation context after an installation is revoked or deleted, causing scoped tokens to be evaluated against an unintended access boundary.
Exploit preconditions
- Attack surface: GitHub Enterprise Server API and Git operations where ghu_ tokens are accepted (including SSH push when attribution and token binding apply).
- Required access: An authenticated attacker capable of interacting with the GitHub Enterprise Server instance and participating in flows where scoped ghu_ tokens are issued or observed.
- Trigger point: Authorization checks performed for ghu_ tokens after an associated installation has been revoked or deleted, causing a fallback to a global-like context.
- Why exploitation is possible: The authorization layer fails to strictly enforce installation scoping once the original installation context is removed, treating certain requests as if they were globally scoped and enabling access to private repositories outside the intended scope.
Why this happens
The underlying issue stems from improper access control logic associated with scoped user-to-server tokens and their installation context.
Instead of failing closed or strictly denying access when an installation is revoked or deleted, the system performs an authorization fallback that interprets the token in a broader, effectively global context.
This maps to CWE-639: Authorization Bypass Through User-Controlled Key, where identifiers or context keys (in this case, installation and token scope) are not correctly enforced, allowing a token bound to a narrow scope to be used for broader access.
The combination of this fallback behavior, token revocation timing, and SSH push attribution workflows makes it possible for an attacker to obtain or reuse a token with more privileges than intended.
Potential impact
- Unauthorized read access to private repositories outside the original installation scope
- Unauthorized write or push operations to private repositories, potentially modifying source code
- Contamination of codebases with malicious changes (backdoors, data exfiltration logic, or sabotage)
- Exposure of proprietary source code, secrets stored in repositories, or internal tooling definitions
- Lateral movement across projects via tampering with automation, CI/CD configs, or dependency definitions
General mitigation guidance
Effective mitigation focuses on ensuring strict, non-fallback access control and defensive token lifecycle management:
- Enforce a fail-closed model where any token linked to a revoked or deleted installation is treated as invalid, without attempting to reinterpret it in a broader context.
- Ensure that authorization checks always bind ghu_ tokens to a concrete, existing installation context and repository set, rejecting any request if that context cannot be resolved.
- Implement rigorous token lifecycle policies, including immediate invalidation and revocation propagation, to minimize timing gaps where a token can be reused.
- Reduce token privilege by default (least privilege), granting the minimum repository access necessary, and prefer narrowly scoped tokens for automation.
- Strengthen controls around SSH push attribution and token linkage so that identity and scope cannot be repurposed or inferred in ways that broaden access.
- Apply defense-in-depth with monitoring, approvals, and branch protections so that a single token misuse cannot easily result in undetected code compromise.
How teams detect issues like this
Organizations can look for this class of authorization flaws and their symptoms through a combination of code-centric and operational techniques:
- Static analysis & code review:
- Inspect authorization modules for fallback logic that changes or widens scope when the primary installation or context is missing.
- Flag any patterns where a missing or revoked installation is handled by defaulting to a global or less restrictive policy instead of failing closed.
- Review token validation code to ensure tokens are always tied to existing, strictly-defined scopes (e.g., explicit repository lists or organization IDs).
- Policy enforcement:
- Enforce internal secure coding guidelines that prohibit permissive fallbacks in access control and require explicit handling of revoked contexts.
- Integrate automated security checks into CI/CD that look for dangerous patterns such as "on failure, allow" or "if not found, treat as global."
- Runtime monitoring & logging:
- Monitor audit logs for ghu_ token usage accessing repositories not normally associated with a given installation or integration.
- Alert on anomalous write operations from tokens that historically performed only read or narrowly scoped actions.
- Track token revocation events and subsequent activity to identify any suspicious continued use or scope changes.

