Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix test-https-ci-reneg-attack #25676

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions test/pummel/test-https-ci-reneg-attack.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,16 @@ function test(next) {
// Count handshakes, start the attack after the initial handshake is done
let handshakes = 0;
let renegs = 0;
let waitingToSpam = true;

child.stderr.on('data', function(data) {
handshakes += ((String(data)).match(/verify return:1/g) || []).length;
if (handshakes === 2) spam();
if (handshakes === 2 && waitingToSpam) {
waitingToSpam = false;
// See long comment in spam() function.
child.stdin.write('GET / HTTP/1.1\n');
spam();
}
renegs += ((String(data)).match(/RENEGOTIATING/g) || []).length;
});

Expand Down Expand Up @@ -105,7 +111,14 @@ function test(next) {
// simulate renegotiation attack
function spam() {
if (closed) return;
child.stdin.write('R\n');
// `R` at the start of a line will cause renegotiation but may (in OpenSSL
// 1.1.1a, at least) also cause `s_client` to send `R` as a HTTP header,
// causing the server to send 400 Bad Request and close the connection.
// By sending a `Referer` header that starts with a capital `R`, OpenSSL
// 1.1.1.a s_client sends both a valid HTTP header *and* causes a
// renegotiation. ¯\(ツ)/¯ (But you need to send a valid HTTP verb first,
// hence the `GET` in the stderr data callback.)
child.stdin.write('Referer: fhqwhgads\n');
setTimeout(spam, 50);
}
});
Expand Down
6 changes: 5 additions & 1 deletion test/pummel/test-tls-ci-reneg-attack.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,15 @@ function test(next) {
// Count handshakes, start the attack after the initial handshake is done
let handshakes = 0;
let renegs = 0;
let waitingToSpam = true;

child.stderr.on('data', function(data) {
if (seenError) return;
handshakes += ((String(data)).match(/verify return:1/g) || []).length;
if (handshakes === 2) spam();
if (handshakes === 2 && waitingToSpam) {
waitingToSpam = false;
spam();
}
renegs += ((String(data)).match(/RENEGOTIATING/g) || []).length;
});

Expand Down