Skip to content

Commit e96d224

Browse files
t8mbeldmit
authored andcommitted
apps/x509.c: Fix the -addreject option adding trust instead of rejection
Fixes CVE-2025-4575 Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> Reviewed-by: Paul Dale <ppzgs1@gmail.com> (Merged from #27672) (cherry picked from commit 0eb9acc)
1 parent 1b20579 commit e96d224

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

apps/x509.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ int x509_main(int argc, char **argv)
465465
prog, opt_arg());
466466
goto opthelp;
467467
}
468-
if (!sk_ASN1_OBJECT_push(trust, objtmp))
468+
if (!sk_ASN1_OBJECT_push(reject, objtmp))
469469
goto end;
470470
trustout = 1;
471471
break;

test/recipes/25-test_x509.t

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use OpenSSL::Test qw/:DEFAULT srctop_file/;
1616

1717
setup("test_x509");
1818

19-
plan tests => 134;
19+
plan tests => 138;
2020

2121
# Prevent MSys2 filename munging for arguments that look like file paths but
2222
# aren't
@@ -110,6 +110,16 @@ ok(run(app(["openssl", "x509", "-new", "-force_pubkey", $key, "-subj", "/CN=EE",
110110
&& run(app(["openssl", "verify", "-no_check_time",
111111
"-trusted", $ca, "-partial_chain", $caout])));
112112

113+
# test trust decoration
114+
ok(run(app(["openssl", "x509", "-in", $ca, "-addtrust", "emailProtection",
115+
"-out", "ca-trusted.pem"])));
116+
cert_contains("ca-trusted.pem", "Trusted Uses: E-mail Protection",
117+
1, 'trusted use - E-mail Protection');
118+
ok(run(app(["openssl", "x509", "-in", $ca, "-addreject", "emailProtection",
119+
"-out", "ca-rejected.pem"])));
120+
cert_contains("ca-rejected.pem", "Rejected Uses: E-mail Protection",
121+
1, 'rejected use - E-mail Protection');
122+
113123
subtest 'x509 -- x.509 v1 certificate' => sub {
114124
tconversion( -type => 'x509', -prefix => 'x509v1',
115125
-in => srctop_file("test", "testx509.pem") );

0 commit comments

Comments
 (0)