Proxy-Authorization header not cleared on cross-origin redirect in undici.request
Undici's request() function did not strip the Proxy-Authorization header when following a redirect to a different origin, although it already stripped Authorization and Cookie. An attacker who controls a redirect target could receive the proxy credentials that the client sent to the original host.
- Triaged in 2 days
- Fixed in 22 days
- Paid in 22 days
- Disclosed after 52 days
Summary by the program
Proxy-Authorization header not cleared on cross-origin redirect for dispatch, request, stream, pipeline
Impact Undici cleared Authorization and Proxy-Authorization headers for fetch(), but did not clear them for undici.request().
Patches This has been patched in 6805746. Fixes has been released in v5.28.4 and v6.11.1.
Workarounds use fetch() or disable maxRedirections.
References Linzi Shang reported this.
GHSA: https://github.com/nodejs/undici/security/advisories/GHSA-m4v8-wqvr-p9f7
The report
Summary:: Undici already cleared Authorization and Cookie headers on cross-origin redirects, but did not clear Proxy-Authorization and x-auth-token headers.
Description: Like https://github.com/nodejs/undici/security/advisories/GHSA-3787-6prv-h9w3, this is a fixed security issue in v5.28.3, v6.6.1, but I have tested the new version(v6.7.0) and it has not been fixed yet.
Steps To Reproduce: POC:
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'
}
})
The http://127.0.0.1/ is a redirect server. Sourcecode:
<?php
header("Location: http://a.com:2333");
?>
Add the 1 record in the /etc/hosts file:
127.0.0.1 a.com
Listening on port 2333 and discovering that Proxy-Authorization headers has been passed.
Impact:
<[email protected]
Supporting Material/References:
https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Proxy-Authorization
Impact
Undici already cleared Authorization and Cookie headers on cross-origin redirects, but did not clear Proxy-Authorization headers.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the redirect handling code maintained a list of headers to strip on cross-origin redirects but omitted Proxy-Authorization (and x-auth-token) from that list.
Impact
Proxy credentials could be disclosed to a third-party origin when the client follows a cross-origin redirect.
What the attacker needed
Redirects enabled (maxRedirections); attacker controls redirect target
The fix
The issue was patched and fixes released in v5.28.4 and v6.11.1.
How it was found
- Set up a local server that responds with a redirect to a different host.
- Map that second host to the local machine and listen on the target port.
- Call undici.request with maxRedirections set to 1 and include a Proxy-Authorization header.
- Observe that the Proxy-Authorization header arrives at the redirect target.
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 report has not been written yet. The Original tab links to the source.
When a program follows a redirect to another website, it should drop sensitive login headers so the new site does not learn them. Undici removed some of these headers but forgot one, the Proxy-Authorization header, so the second site could see it. This means credentials meant for one place could leak to another.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.