-
Notifications
You must be signed in to change notification settings - Fork 562
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Merge pull request from GHSA-wqq4-5wpv-mx2g
* fix: delete 'cookie' and 'host' headers on cross-origin redirect * apply suggestion
- v7.2.0
- v7.1.1
- v7.1.0
- v7.0.0
- v7.0.0-alpha.9
- v7.0.0-alpha.8
- v7.0.0-alpha.7
- v7.0.0-alpha.6
- v7.0.0-alpha.5
- v7.0.0-alpha.4
- v7.0.0-alpha.3
- v7.0.0-alpha.2
- v6.21.0
- v6.20.1
- v6.20.0
- v6.19.8
- v6.19.7
- v6.19.6
- v6.19.5
- v6.19.4
- v6.19.3
- v6.19.2
- v6.19.1
- v6.19.0
- v6.18.2
- v6.18.1
- v6.18.0
- v6.17.0
- v6.16.1
- v6.16.0
- v6.15.0
- v6.14.1
- v6.14.0
- v6.13.0
- v6.12.0
- v6.11.1
- v6.11.0
- v6.10.2
- v6.10.1
- v6.10.0
- v6.9.0
- v6.8.0
- v6.7.1
- v6.7.0
- v6.6.2
- v6.6.1
- v6.6.0
- v6.5.0
- v6.4.0
- v6.3.0
- v6.2.1
- v6.2.0
- v6.1.0
- v6.0.1
- v6.0.0
- v5.28.4
- v5.28.3
- v5.28.2
- v5.28.1
- v5.28.0
- v5.27.2
- v5.27.1
- v5.27.0
- v5.26.5
- v5.26.4
- v5.26.3
- v5.26.2
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use strict' | ||
|
||
const { test } = require('tap') | ||
const { createServer } = require('http') | ||
const { once } = require('events') | ||
const { fetch } = require('../..') | ||
|
||
test('Cross-origin redirects clear forbidden headers', async (t) => { | ||
t.plan(5) | ||
|
||
const server1 = createServer((req, res) => { | ||
t.equal(req.headers.cookie, undefined) | ||
t.equal(req.headers.authorization, undefined) | ||
|
||
res.end('redirected') | ||
}).listen(0) | ||
|
||
const server2 = createServer((req, res) => { | ||
t.equal(req.headers.authorization, 'test') | ||
t.equal(req.headers.cookie, 'ddd=dddd') | ||
|
||
res.writeHead(302, { | ||
...req.headers, | ||
Location: `http://localhost:${server1.address().port}` | ||
}) | ||
res.end() | ||
}).listen(0) | ||
|
||
t.teardown(() => { | ||
server1.close() | ||
server2.close() | ||
}) | ||
|
||
await Promise.all([ | ||
once(server1, 'listening'), | ||
once(server2, 'listening') | ||
]) | ||
|
||
const res = await fetch(`http://localhost:${server2.address().port}`, { | ||
headers: { | ||
Authorization: 'test', | ||
Cookie: 'ddd=dddd' | ||
} | ||
}) | ||
|
||
const text = await res.text() | ||
t.equal(text, 'redirected') | ||
}) |
e041de3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good