forked from Tongsuo-Project/Tongsuo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Tongsuo-Project#690 from dongbeiouba/fix84/CVE-202…
…4-6119 Fix CVE-2024-6119 for 8.4 branch
- Loading branch information
Showing
6 changed files
with
144 additions
and
26 deletions.
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
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 |
---|---|---|
|
@@ -21,16 +21,18 @@ setup("test_eai_data"); | |
#./util/wrap.pl apps/openssl verify -nameopt utf8 -no_check_time -CAfile test/recipes/25-test_eai_data/utf8_chain.pem test/recipes/25-test_eai_data/ascii_leaf.pem | ||
#./util/wrap.pl apps/openssl verify -nameopt utf8 -no_check_time -CAfile test/recipes/25-test_eai_data/ascii_chain.pem test/recipes/25-test_eai_data/utf8_leaf.pem | ||
|
||
plan tests => 12; | ||
plan tests => 16; | ||
|
||
require_ok(srctop_file('test','recipes','tconversion.pl')); | ||
my $folder = "test/recipes/25-test_eai_data"; | ||
|
||
my $ascii_pem = srctop_file($folder, "ascii_leaf.pem"); | ||
my $utf8_pem = srctop_file($folder, "utf8_leaf.pem"); | ||
my $kdc_pem = srctop_file($folder, "kdc-cert.pem"); | ||
|
||
my $ascii_chain_pem = srctop_file($folder, "ascii_chain.pem"); | ||
my $utf8_chain_pem = srctop_file($folder, "utf8_chain.pem"); | ||
my $kdc_chain_pem = srctop_file($folder, "kdc-root-cert.pem"); | ||
|
||
my $out; | ||
my $outcnt = 0; | ||
|
@@ -56,10 +58,18 @@ SKIP: { | |
|
||
ok(run(app(["openssl", "verify", "-nameopt", "utf8", "-no_check_time", "-CAfile", $ascii_chain_pem, $ascii_pem]))); | ||
ok(run(app(["openssl", "verify", "-nameopt", "utf8", "-no_check_time", "-CAfile", $utf8_chain_pem, $utf8_pem]))); | ||
ok(run(app(["openssl", "verify", "-nameopt", "utf8", "-no_check_time", "-CAfile", $kdc_chain_pem, $kdc_pem]))); | ||
|
||
ok(!run(app(["openssl", "verify", "-nameopt", "utf8", "-no_check_time", "-CAfile", $ascii_chain_pem, $utf8_pem]))); | ||
ok(!run(app(["openssl", "verify", "-nameopt", "utf8", "-no_check_time", "-CAfile", $utf8_chain_pem, $ascii_pem]))); | ||
|
||
# Check an otherName does not get misparsed as an DNS name, (should trigger ASAN errors if violated). | ||
ok(run(app(["openssl", "verify", "-nameopt", "utf8", "-no_check_time", "-verify_hostname", 'mx1.example.com', "-CAfile", $kdc_chain_pem, $kdc_pem]))); | ||
# Check an otherName does not get misparsed as an email address, (should trigger ASAN errors if violated). | ||
ok(run(app(["openssl", "verify", "-nameopt", "utf8", "-no_check_time", "-verify_email", '[email protected]', "-CAfile", $kdc_chain_pem, $kdc_pem]))); | ||
# We expect SmtpUTF8Mailbox to be a UTF8 String, not an IA5String. | ||
ok(!run(app(["openssl", "verify", "-nameopt", "utf8", "-no_check_time", "-verify_email", '[email protected]', "-CAfile", $kdc_chain_pem, $kdc_pem]))); | ||
|
||
#Check that we get the expected failure return code | ||
with({ exit_checker => sub { return shift == 2; } }, | ||
sub { | ||
|
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,21 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIDbDCCAlSgAwIBAgIBAjANBgkqhkiG9w0BAQsFADAPMQ0wCwYDVQQDDARSb290 | ||
MCAXDTI0MDYyMDA2MTQxNVoYDzIxMjQwNjIwMDY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
0fTCOBEMjIETDsrA70OxAMu4V16nrWZdJdvzblS2qrt97Omkj+2kiPAJFB76RpwI | ||
oDQ9fKfUOAmUFth2/R/eGA== | ||
-----END CERTIFICATE----- |
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,16 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIICnDCCAYQCCQCBswYcrlZSHjANBgkqhkiG9w0BAQsFADAPMQ0wCwYDVQQDDARS | ||
b290MCAXDTI0MDYyMDA2MTQxNVoYDzIxMjQwNjIwMDYxNDE1WjAPMQ0wCwYDVQQD | ||
DARSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqRj8S4kBbIUj | ||
61kZfi6nE35Q38U140+qt4uAiwAhKumfVHlBM0zQ98WFt5zMHIBQwIb3yjc2zj+0 | ||
qzUnQfwm1r/RfcMmBPEti9Ge+aEMSsds2gMXziOFM8wd2aAFPy7UVE0XpEWofsRK | ||
MGi61MKVdPSbGIxBwY9VW38/7D/wf1HtJe7y0xpuecR7GB2XAs+qST59NjuF+7wS | ||
dLM8Hb3TATgeYbXXWsRJgwz+SPzExg5WmLnU+7y4brZ32dHtdSmkRVSgSlaIf7Xj | ||
3Tc6Zi7I+W/JYk7hy1zUexVdWCak4PHcoWrXe0gNNN/t8VfLfMExt5z/HIylXnU7 | ||
pGUyqZlTGQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQAHpLF1UCRy7b6Hk0rLokxI | ||
lgwiH9BU9mktigAGASvkbllpt+YbUbWnuYAvpHBGiP1qZtfX2r96UrSJaGO9BEzT | ||
Gp9ThnSjoj4Srul0+s/NArU22irFLmDzbalgevAmm9gMGkdqkiIm/mXbwrPj0ncl | ||
KGicevXryVpvaP62eZ8cc3C4p97frMmXxRX8sTdQpD/gRI7prdEILRSKveqT+AEW | ||
7rFGM5AOevb4U8ddop8A3D/kX0wcCAIBF6jCNk3uEJ57jVcagL04kPnVfdRiedTS | ||
vfq1DRNcD29d1H/9u0fHdSn1/+8Ep3X+afQ3C6//5NvOEaXcIGO4QSwkprQydfv8 | ||
-----END CERTIFICATE----- |
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,41 @@ | ||
#! /usr/bin/env bash | ||
|
||
# Create a root CA, signing a leaf cert with a KDC principal otherName SAN, and | ||
# also a non-UTF8 smtpUtf8Mailbox SAN followed by an rfc822Name SAN and a DNS | ||
# name SAN. In the vulnerable EAI code, the KDC principal `otherName` should | ||
# trigger ASAN errors in DNS name checks, while the non-UTF8 `smtpUtf8Mailbox` | ||
# should likewise lead to ASAN issues with email name checks. | ||
|
||
rm -f root-key.pem root-cert.pem | ||
openssl req -nodes -new -newkey rsa:2048 -keyout kdc-root-key.pem \ | ||
-x509 -subj /CN=Root -days 36524 -out kdc-root-cert.pem | ||
|
||
exts=$( | ||
printf "%s\n%s\n%s\n%s = " \ | ||
"subjectKeyIdentifier = hash" \ | ||
"authorityKeyIdentifier = keyid" \ | ||
"basicConstraints = CA:false" \ | ||
"subjectAltName" | ||
printf "%s, " "otherName:1.3.6.1.5.2.2;SEQUENCE:kdc_princ_name" | ||
printf "%s, " "otherName:1.3.6.1.5.5.7.8.9;IA5:[email protected]" | ||
printf "%s, " "email:[email protected]" | ||
printf "%s\n" "DNS:mx1.example.com" | ||
printf "[kdc_princ_name]\n" | ||
printf "realm = EXP:0, GeneralString:TEST.EXAMPLE\n" | ||
printf "principal_name = EXP:1, SEQUENCE:kdc_principal_seq\n" | ||
printf "[kdc_principal_seq]\n" | ||
printf "name_type = EXP:0, INTEGER:1\n" | ||
printf "name_string = EXP:1, SEQUENCE:kdc_principal_components\n" | ||
printf "[kdc_principal_components]\n" | ||
printf "princ1 = GeneralString:krbtgt\n" | ||
printf "princ2 = GeneralString:TEST.EXAMPLE\n" | ||
) | ||
|
||
printf "%s\n" "$exts" | ||
|
||
openssl req -nodes -new -newkey rsa:2048 -keyout kdc-key.pem \ | ||
-subj "/CN=TEST.EXAMPLE" | | ||
openssl x509 -req -out kdc-cert.pem \ | ||
-CA "kdc-root-cert.pem" -CAkey "kdc-root-key.pem" \ | ||
-set_serial 2 -days 36524 \ | ||
-extfile <(printf "%s\n" "$exts") |