Skip to content

Commit 0ad0058

Browse files
committed
https: fix renegotation attack protection
Listen for the 'clientError' event that is emitted when a renegotation attack is detected and close the connection. Fixes test/pummel/test-https-ci-reneg-attack.js
1 parent 7394e89 commit 0ad0058

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

doc/api/http.markdown

+4-1
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,13 @@ sent to the server on that socket.
127127

128128
### Event: 'clientError'
129129

130-
`function (exception) { }`
130+
`function (exception, socket) { }`
131131

132132
If a client connection emits an 'error' event - it will forwarded here.
133133

134+
`socket` is the `net.Socket` object that the error originated from.
135+
136+
134137
### server.listen(port, [hostname], [backlog], [callback])
135138

136139
Begin accepting connections on the specified port and hostname. If the

doc/api/tls.markdown

+3-1
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,13 @@ SNI.
367367

368368
### Event: 'clientError'
369369

370-
`function (exception) { }`
370+
`function (exception, securePair) { }`
371371

372372
When a client connection emits an 'error' event before secure connection is
373373
established - it will be forwarded here.
374374

375+
`securePair` is the `tls.SecurePair` that the error originated from.
376+
375377

376378
### Event: 'newSession'
377379

lib/http.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1647,6 +1647,10 @@ function Server(requestListener) {
16471647
this.httpAllowHalfOpen = false;
16481648

16491649
this.addListener('connection', connectionListener);
1650+
1651+
this.addListener('clientError', function(err, conn) {
1652+
conn.destroy(err);
1653+
});
16501654
}
16511655
util.inherits(Server, net.Server);
16521656

@@ -1705,7 +1709,7 @@ function connectionListener(socket) {
17051709
}
17061710

17071711
socket.addListener('error', function(e) {
1708-
self.emit('clientError', e);
1712+
self.emit('clientError', e, this);
17091713
});
17101714

17111715
socket.ondata = function(d, start, end) {

lib/https.js

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ function Server(opts, requestListener) {
3939
if (requestListener) {
4040
this.addListener('request', requestListener);
4141
}
42+
43+
this.addListener('clientError', function(err, conn) {
44+
conn.destroy(err);
45+
});
4246
}
4347
inherits(Server, tls.Server);
4448

lib/tls.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ function Server(/* [options], listener */) {
11551155
}
11561156
});
11571157
pair.on('error', function(err) {
1158-
self.emit('clientError', err);
1158+
self.emit('clientError', err, this);
11591159
});
11601160
});
11611161

0 commit comments

Comments
 (0)