Skip to content

Commit e2c8f89

Browse files
committed
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/192 Reviewed-By: Beth Griggs <[email protected]>
1 parent 49f4220 commit e2c8f89

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
5+
// Test https://hackerone.com/reports/735748 is fixed.
6+
7+
const assert = require('assert');
8+
const http = require('http');
9+
const net = require('net');
10+
11+
const REQUEST_BB = `POST / HTTP/1.1
12+
Content-Type: text/plain; charset=utf-8
13+
Host: hacker.exploit.com
14+
Connection: keep-alive
15+
Content-Length: 10
16+
Transfer-Encoding: chunked, eee
17+
18+
HELLOWORLDPOST / HTTP/1.1
19+
Content-Type: text/plain; charset=utf-8
20+
Host: hacker.exploit.com
21+
Connection: keep-alive
22+
Content-Length: 28
23+
24+
I AM A SMUGGLED REQUEST!!!
25+
`;
26+
27+
const server = http.createServer(common.mustNotCall());
28+
29+
server.on('clientError', common.mustCall((err) => {
30+
assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH');
31+
server.close();
32+
}));
33+
34+
server.listen(0, common.mustCall(() => {
35+
const client = net.connect(
36+
server.address().port,
37+
common.mustCall(() => {
38+
client.end(REQUEST_BB.replace(/\n/g, '\r\n'));
39+
}));
40+
}));

0 commit comments

Comments
 (0)