Summary
A URL parsing flaw in gitoxide's gix-url crate can cause gix-transport to misidentify the destination of an HTTP redirect. When an attacker controls a redirect response, the flaw may cause HTTP Basic Authorization credentials to be sent to an unintended host.
Affected context
The issue occurs in gitoxide deployments that use gix-transport for HTTP operations and follow attacker-influenced redirects. It is relevant when HTTP Basic Authorization credentials are available for reuse and the redirect target is parsed by the affected hand-rolled URL parser. The risk depends on whether an attacker can provide or influence an HTTP redirect response during a repository or remote interaction.
Exploit preconditions
- Attack surface: HTTP redirect handling in git transport operations
- Required access: Ability to control or influence a redirect response
- Credential condition: The client must have HTTP Basic Authorization credentials available for the request
- Trigger point: Processing a crafted
Locationheader during redirect evaluation - Why exploitation is possible: The parser does not treat
?or#as terminating the authority component, causing the identity-reuse check to compare the wrong host and fail open
Why this happens
The underlying bug is nonconforming authority parsing in a hand-rolled URL parser. Because query and fragment delimiters are not handled according to RFC 3986, a crafted redirect can make the parser derive an incorrect host identity. The transport layer then relies on that incorrect identity when deciding whether credentials may be reused, mapping to CWE-522 because authentication credentials can be disclosed to an unintended recipient.
Potential impact
- An attacker could receive HTTP Basic Authorization credentials
- Credentials could be reused against protected repositories or services
- Compromised credentials may enable unauthorized repository access
- Private source code or other protected resources could be exposed
- Downstream systems could be affected if the exposed credentials have broader privileges
General mitigation guidance
Mitigation generally focuses on using standards-compliant URL parsing and
making credential forwarding fail closed.
Common defensive patterns include:
- Use a well-maintained, RFC-conforming URL parser rather than hand-rolled authority parsing
- Revalidate the effective scheme, host, port, and user-information boundaries after redirects
- Forward credentials only when the redirect destination is explicitly trusted and equivalent under a clearly defined policy
- Avoid sending reusable credentials across host, scheme, or security-boundary changes
- Prefer short-lived, narrowly scoped credentials and minimize their privileges
- Disable automatic redirect credential reuse where it is not required
- Treat redirect responses and remote URL metadata as untrusted input
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis rules identifying hand-written URL authority parsing
- Code review checks for credential reuse decisions based on partially parsed URLs
- Tests covering
?,#, user-information, alternate ports, encoded delimiters, and cross-host redirects - Policy checks requiring standards-compliant URL libraries for security-sensitive destination validation
- Integration tests verifying that credentials are never forwarded to an untrusted redirect target
- Automated dependency and security review tools that flag vulnerable parser and transport components

