-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: using TE to smuggle reqs is not possible
See: https://hackerone.com/reports/735748 PR-URL: https://github.com/nodejs-private/node-private/pull/199 Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
- Loading branch information
1 parent
8f41e83
commit eea3a74
Showing
2 changed files
with
41 additions
and
1 deletion.
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,40 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
|
||
// Test https://hackerone.com/reports/735748 is fixed. | ||
|
||
const assert = require('assert'); | ||
const http = require('http'); | ||
const net = require('net'); | ||
|
||
const REQUEST_BB = `POST / HTTP/1.1 | ||
Content-Type: text/plain; charset=utf-8 | ||
Host: hacker.exploit.com | ||
Connection: keep-alive | ||
Content-Length: 10 | ||
Transfer-Encoding: chunked, eee | ||
HELLOWORLDPOST / HTTP/1.1 | ||
Content-Type: text/plain; charset=utf-8 | ||
Host: hacker.exploit.com | ||
Connection: keep-alive | ||
Content-Length: 28 | ||
I AM A SMUGGLED REQUEST!!! | ||
`; | ||
|
||
const server = http.createServer(common.mustNotCall()); | ||
|
||
server.on('clientError', common.mustCall((err) => { | ||
assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH'); | ||
server.close(); | ||
})); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
const client = net.connect( | ||
server.address().port, | ||
common.mustCall(() => { | ||
client.end(REQUEST_BB.replace(/\n/g, '\r\n')); | ||
})); | ||
})); |