summaryrefslogtreecommitdiffstats
path: root/crypto/x509
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@google.com>2017-09-18 16:51:56 -0400
committerAndy Polyakov <appro@openssl.org>2017-09-30 22:17:36 +0200
commit329a004f784e554ee7fbe2135e6617e784566c28 (patch)
tree6e5edbf7e598169f9ecbabd0ff760f4abe04e1f0 /crypto/x509
parent15ab3217799db508dec4c78cbfd185129f8fdfec (diff)
Guard against DoS in name constraints handling.
This guards against the name constraints check consuming large amounts of CPU time when certificates in the presented chain contain an excessive number of names (specifically subject email names or subject alternative DNS names) and/or name constraints. Name constraints checking compares the names presented in a certificate against the name constraints included in a certificate higher up in the chain using two nested for loops. Move the name constraints check so that it happens after signature verification so peers cannot exploit this using a chain with invalid signatures. Also impose a hard limit on the number of name constraints check loop iterations to further mitigate the issue. Thanks to NCC for finding this issue. Fix written by Martin Kreichgauer. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Andy Polyakov <appro@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4411) (cherry picked from commit 8545051c3652bce7bb962afcb6879c4a6288bc67) Resolved conflicts: crypto/x509v3/v3_ncons.c test/recipes/25-test_verify.t
Diffstat (limited to 'crypto/x509')
-rw-r--r--crypto/x509/x509_vfy.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c
index ebc4424005..3018c69ae4 100644
--- a/crypto/x509/x509_vfy.c
+++ b/crypto/x509/x509_vfy.c
@@ -216,7 +216,6 @@ static int verify_chain(X509_STORE_CTX *ctx)
if ((ok = build_chain(ctx)) == 0 ||
(ok = check_chain_extensions(ctx)) == 0 ||
(ok = check_auth_level(ctx)) == 0 ||
- (ok = check_name_constraints(ctx)) == 0 ||
(ok = check_id(ctx)) == 0 || 1)
X509_get_pubkey_parameters(NULL, ctx->chain);
if (ok == 0 || (ok = ctx->check_revocation(ctx)) == 0)
@@ -234,6 +233,9 @@ static int verify_chain(X509_STORE_CTX *ctx)
if (!ok)
return ok;
+ if ((ok = check_name_constraints(ctx)) == 0)
+ return ok;
+
#ifndef OPENSSL_NO_RFC3779
/* RFC 3779 path validation, now that CRL check has been done */
if ((ok = X509v3_asid_validate_path(ctx)) == 0)