|
 |
6f47c0 |
diff -up openssl-1.1.1g/ssl/statem/extensions.c.sig-alg-null-dereference openssl-1.1.1g/ssl/statem/extensions.c
|
|
 |
6f47c0 |
--- openssl-1.1.1g/ssl/statem/extensions.c.sig-alg-null-dereference 2021-03-25 15:04:24.781522476 +0100
|
|
 |
6f47c0 |
+++ openssl-1.1.1g/ssl/statem/extensions.c 2021-03-25 15:04:24.792522584 +0100
|
|
 |
6f47c0 |
@@ -1136,6 +1136,7 @@ static int init_sig_algs(SSL *s, unsigne
|
|
 |
6f47c0 |
/* Clear any signature algorithms extension received */
|
|
 |
6f47c0 |
OPENSSL_free(s->s3->tmp.peer_sigalgs);
|
|
 |
6f47c0 |
s->s3->tmp.peer_sigalgs = NULL;
|
|
 |
6f47c0 |
+ s->s3->tmp.peer_sigalgslen = 0;
|
|
 |
6f47c0 |
|
|
 |
6f47c0 |
return 1;
|
|
 |
6f47c0 |
}
|
|
 |
6f47c0 |
@@ -1145,6 +1146,7 @@ static int init_sig_algs_cert(SSL *s, un
|
|
 |
6f47c0 |
/* Clear any signature algorithms extension received */
|
|
 |
6f47c0 |
OPENSSL_free(s->s3->tmp.peer_cert_sigalgs);
|
|
 |
6f47c0 |
s->s3->tmp.peer_cert_sigalgs = NULL;
|
|
 |
6f47c0 |
+ s->s3->tmp.peer_cert_sigalgslen = 0;
|
|
 |
6f47c0 |
|
|
 |
6f47c0 |
return 1;
|
|
 |
6f47c0 |
}
|
|
 |
6f47c0 |
diff -up openssl-1.1.1g/test/recipes/70-test_renegotiation.t.sig-alg-null-dereference openssl-1.1.1g/test/recipes/70-test_renegotiation.t
|
|
 |
6f47c0 |
--- openssl-1.1.1g/test/recipes/70-test_renegotiation.t.sig-alg-null-dereference 2021-03-25 15:59:52.226408743 +0100
|
|
 |
6f47c0 |
+++ openssl-1.1.1g/test/recipes/70-test_renegotiation.t 2021-03-25 16:07:25.528618852 +0100
|
|
 |
6f47c0 |
@@ -38,7 +38,7 @@ my $proxy = TLSProxy::Proxy->new(
|
|
 |
6f47c0 |
$proxy->clientflags("-no_tls1_3");
|
|
 |
6f47c0 |
$proxy->reneg(1);
|
|
 |
6f47c0 |
$proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
|
|
 |
6f47c0 |
-plan tests => 3;
|
|
 |
6f47c0 |
+plan tests => 4;
|
|
 |
6f47c0 |
ok(TLSProxy::Message->success(), "Basic renegotiation");
|
|
 |
6f47c0 |
|
|
 |
6f47c0 |
#Test 2: Client does not send the Reneg SCSV. Reneg should fail
|
|
 |
6f47c0 |
@@ -77,6 +77,20 @@ SKIP: {
|
|
 |
6f47c0 |
"Check ClientHello version is the same");
|
|
 |
6f47c0 |
}
|
|
 |
6f47c0 |
|
|
 |
6f47c0 |
+SKIP: {
|
|
 |
6f47c0 |
+ skip "TLSv1.2 disabled", 1
|
|
 |
6f47c0 |
+ if disabled("tls1_2");
|
|
 |
6f47c0 |
+
|
|
 |
6f47c0 |
+ #Test 4: Test for CVE-2021-3449. client_sig_algs instead of sig_algs in
|
|
 |
6f47c0 |
+ # resumption ClientHello
|
|
 |
6f47c0 |
+ $proxy->clear();
|
|
 |
6f47c0 |
+ $proxy->filter(\&sigalgs_filter);
|
|
 |
6f47c0 |
+ $proxy->clientflags("-tls1_2");
|
|
 |
6f47c0 |
+ $proxy->reneg(1);
|
|
 |
6f47c0 |
+ $proxy->start();
|
|
 |
6f47c0 |
+ ok(TLSProxy::Message->fail(), "client_sig_algs instead of sig_algs");
|
|
 |
6f47c0 |
+}
|
|
 |
6f47c0 |
+
|
|
 |
6f47c0 |
sub reneg_filter
|
|
 |
6f47c0 |
{
|
|
 |
6f47c0 |
my $proxy = shift;
|
|
 |
6f47c0 |
@@ -95,4 +109,24 @@ sub reneg_filter
|
|
 |
6f47c0 |
$message->repack();
|
|
 |
6f47c0 |
}
|
|
 |
6f47c0 |
}
|
|
 |
6f47c0 |
+}
|
|
 |
6f47c0 |
+
|
|
 |
6f47c0 |
+sub sigalgs_filter
|
|
 |
6f47c0 |
+{
|
|
 |
6f47c0 |
+ my $proxy = shift;
|
|
 |
6f47c0 |
+ my $cnt = 0;
|
|
 |
6f47c0 |
+
|
|
 |
6f47c0 |
+ # We're only interested in the second ClientHello message
|
|
 |
6f47c0 |
+ foreach my $message (@{$proxy->message_list}) {
|
|
 |
6f47c0 |
+ if ($message->mt == TLSProxy::Message::MT_CLIENT_HELLO) {
|
|
 |
6f47c0 |
+ next if ($cnt++ == 0);
|
|
 |
6f47c0 |
+
|
|
 |
6f47c0 |
+ my $sigs = pack "C10", 0x00, 0x08,
|
|
 |
6f47c0 |
+ # rsa_pkcs_sha{256,384,512,1}
|
|
 |
6f47c0 |
+ 0x04, 0x01, 0x05, 0x01, 0x06, 0x01, 0x02, 0x01;
|
|
 |
6f47c0 |
+ $message->set_extension(TLSProxy::Message::EXT_SIG_ALGS_CERT, $sigs);
|
|
 |
6f47c0 |
+ $message->delete_extension(TLSProxy::Message::EXT_SIG_ALGS);
|
|
 |
6f47c0 |
+ $message->repack();
|
|
 |
6f47c0 |
+ }
|
|
 |
6f47c0 |
+ }
|
|
 |
6f47c0 |
}
|
|
 |
6f47c0 |
diff -up openssl-1.1.1g/util/perl/TLSProxy/Message.pm.sig-alg-null-dereference openssl-1.1.1g/util/perl/TLSProxy/Message.pm
|
|
 |
6f47c0 |
--- openssl-1.1.1g/util/perl/TLSProxy/Message.pm.sig-alg-null-dereference 2021-03-25 15:59:19.648106296 +0100
|
|
 |
6f47c0 |
+++ openssl-1.1.1g/util/perl/TLSProxy/Message.pm 2021-03-25 16:04:25.623947880 +0100
|
|
 |
6f47c0 |
@@ -1,4 +1,4 @@
|
|
 |
6f47c0 |
-# Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved.
|
|
 |
6f47c0 |
+# Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
|
|
 |
6f47c0 |
#
|
|
 |
6f47c0 |
# Licensed under the OpenSSL license (the "License"). You may not use
|
|
 |
6f47c0 |
# this file except in compliance with the License. You can obtain a copy
|
|
 |
6f47c0 |
@@ -448,7 +448,7 @@ sub ciphersuite
|
|
 |
6f47c0 |
}
|
|
 |
6f47c0 |
|
|
 |
6f47c0 |
#Update all the underlying records with the modified data from this message
|
|
 |
6f47c0 |
-#Note: Only supports re-encrypting for TLSv1.3
|
|
 |
6f47c0 |
+#Note: Only supports TLSv1.3 and ETM encryption.
|
|
 |
6f47c0 |
sub repack
|
|
 |
6f47c0 |
{
|
|
 |
6f47c0 |
my $self = shift;
|
|
 |
6f47c0 |
@@ -490,15 +490,38 @@ sub repack
|
|
 |
6f47c0 |
# (If a length override is ever needed to construct invalid packets,
|
|
 |
6f47c0 |
# use an explicit override field instead.)
|
|
 |
6f47c0 |
$rec->decrypt_len(length($rec->decrypt_data));
|
|
 |
6f47c0 |
- $rec->len($rec->len + length($msgdata) - $old_length);
|
|
 |
6f47c0 |
- # Only support re-encryption for TLSv1.3.
|
|
 |
6f47c0 |
- if (TLSProxy::Proxy->is_tls13() && $rec->encrypted()) {
|
|
 |
6f47c0 |
- #Add content type (1 byte) and 16 tag bytes
|
|
 |
6f47c0 |
- $rec->data($rec->decrypt_data
|
|
 |
6f47c0 |
- .pack("C", TLSProxy::Record::RT_HANDSHAKE).("\0"x16));
|
|
 |
6f47c0 |
+ # Only support re-encryption for TLSv1.3 and ETM.
|
|
 |
6f47c0 |
+ if ($rec->encrypted()) {
|
|
 |
6f47c0 |
+ if (TLSProxy::Proxy->is_tls13()) {
|
|
 |
6f47c0 |
+ #Add content type (1 byte) and 16 tag bytes
|
|
 |
6f47c0 |
+ $rec->data($rec->decrypt_data
|
|
 |
6f47c0 |
+ .pack("C", TLSProxy::Record::RT_HANDSHAKE).("\0"x16));
|
|
 |
6f47c0 |
+ } elsif ($rec->etm()) {
|
|
 |
6f47c0 |
+ my $data = $rec->decrypt_data;
|
|
 |
6f47c0 |
+ #Add padding
|
|
 |
6f47c0 |
+ my $padval = length($data) % 16;
|
|
 |
6f47c0 |
+ $padval = 15 - $padval;
|
|
 |
6f47c0 |
+ for (0..$padval) {
|
|
 |
6f47c0 |
+ $data .= pack("C", $padval);
|
|
 |
6f47c0 |
+ }
|
|
 |
6f47c0 |
+
|
|
 |
6f47c0 |
+ #Add MAC. Assumed to be 20 bytes
|
|
 |
6f47c0 |
+ foreach my $macval (0..19) {
|
|
 |
6f47c0 |
+ $data .= pack("C", $macval);
|
|
 |
6f47c0 |
+ }
|
|
 |
6f47c0 |
+
|
|
 |
6f47c0 |
+ if ($rec->version() >= TLSProxy::Record::VERS_TLS_1_1) {
|
|
 |
6f47c0 |
+ #Explicit IV
|
|
 |
6f47c0 |
+ $data = ("\0"x16).$data;
|
|
 |
6f47c0 |
+ }
|
|
 |
6f47c0 |
+ $rec->data($data);
|
|
 |
6f47c0 |
+ } else {
|
|
 |
6f47c0 |
+ die "Unsupported encryption: No ETM";
|
|
 |
6f47c0 |
+ }
|
|
 |
6f47c0 |
} else {
|
|
 |
6f47c0 |
$rec->data($rec->decrypt_data);
|
|
 |
6f47c0 |
}
|
|
 |
6f47c0 |
+ $rec->len(length($rec->data));
|
|
 |
6f47c0 |
|
|
 |
6f47c0 |
#Update the fragment len in case we changed it above
|
|
 |
6f47c0 |
${$self->message_frag_lens}[0] = length($msgdata)
|