Skip to content
Info disclosure Write-up Intermediate

When a Git Redirect Carries Your Credentials With It: Finding an

The go-git library rewrote its session endpoint to the redirect target after the initial info/refs discovery request and then reapplied the original HTTP credentials to later Git RPC requests. An attacker who controls or influences a redirect target could receive the victim's Basic or token credentials during an authenticated smart-HTTP clone or fetch.

Christopher Linke Follow

Published on medium.com

This is not a remote code execution bug. It is not a “clone this repo and your machine is owned” situation.

Christopher Linke, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

After a redirect on the info/refs discovery request, the library updates its stored endpoint to the new host, scheme and path without checking origin, then reattaches the original auth object to subsequent upload-pack and receive-pack requests.

Impact

A reusable credential such as a personal access token or automation credential could be disclosed to a host that should never have received it, though the impact depends on how broadly scoped and long-lived that credential is.

What the attacker needed

Victim uses go-git over HTTP(S) smart transport; victim supplies HTTP credentials; Git endpoint redirects during handshake; redirect target is attacker-controlled

The fix

The library should not forward authentication across a redirect when the scheme, host or port changes, for example by rejecting cross-origin redirects when auth is present or clearing auth before continuing.

How it was found

  1. Create a temporary bare Git repository for the test.
  2. Start a first server that redirects the info/refs discovery request to a second server.
  3. Start the second server with git-http-backend and record any inbound Authorization headers.
  4. Run a clone through go-git with explicit BasicAuth credentials.
  5. Observe that the redirect target receives the same Authorization value on both the discovery GET and the later upload-pack POST.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

When a program downloads a Git repository, it first asks the server where things are, and the server can reply 'look over there instead'. The go-git library followed that instruction but kept sending the username, password or token along to the new server, even when it was a completely different machine. That means someone who can arrange the redirect can collect credentials meant for the original server.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

More by Christopher Linke

View all

1 more disclosed report, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.