Skip to content

Commit d3aa574

Browse files
committedFeb 5, 2024
Merge pull request from GHSA-3787-6prv-h9w3
Signed-off-by: Matteo Collina <hello@matteocollina.com>
1 parent 9a14e5f commit d3aa574

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed
 

‎lib/fetch/index.js

+3
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,9 @@ function httpRedirectFetch (fetchParams, response) {
12031203
// https://fetch.spec.whatwg.org/#cors-non-wildcard-request-header-name
12041204
request.headersList.delete('authorization')
12051205

1206+
// https://fetch.spec.whatwg.org/#authentication-entries
1207+
request.headersList.delete('proxy-authorization', true)
1208+
12061209
// "Cookie" and "Host" are forbidden request-headers, which undici doesn't implement.
12071210
request.headersList.delete('cookie')
12081211
request.headersList.delete('host')

‎test/fetch/redirect-cross-origin-header.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ const { once } = require('events')
66
const { fetch } = require('../..')
77

88
test('Cross-origin redirects clear forbidden headers', async (t) => {
9-
t.plan(5)
9+
t.plan(6)
1010

1111
const server1 = createServer((req, res) => {
1212
t.equal(req.headers.cookie, undefined)
1313
t.equal(req.headers.authorization, undefined)
14+
t.equal(req.headers['proxy-authorization'], undefined)
1415

1516
res.end('redirected')
1617
}).listen(0)
@@ -39,7 +40,8 @@ test('Cross-origin redirects clear forbidden headers', async (t) => {
3940
const res = await fetch(`http://localhost:${server2.address().port}`, {
4041
headers: {
4142
Authorization: 'test',
42-
Cookie: 'ddd=dddd'
43+
Cookie: 'ddd=dddd',
44+
'Proxy-Authorization': 'test'
4345
}
4446
})
4547

0 commit comments

Comments
 (0)
Please sign in to comment.