openssl/crypto/x509
Matt Caswell 692f07c3e0 Reject calls to X509_verify_cert that have not been reinitialised
The function X509_verify_cert checks the value of |ctx->chain| at the
beginning, and if it is NULL then it initialises it, along with the value
of ctx->untrusted. The normal way to use X509_verify_cert() is to first
call X509_STORE_CTX_init(); then set up various parameters etc; then call
X509_verify_cert(); then check the results; and finally call
X509_STORE_CTX_cleanup(). The initial call to X509_STORE_CTX_init() sets
|ctx->chain| to NULL. The only place in the OpenSSL codebase  where
|ctx->chain| is set to anything other than a non NULL value is in
X509_verify_cert itself. Therefore the only ways that |ctx->chain| could be
non NULL on entry to X509_verify_cert is if one of the following occurs:
1) An application calls X509_verify_cert() twice without re-initialising
in between.
2) An application reaches inside the X509_STORE_CTX structure and changes
the value of |ctx->chain| directly.

With regards to the second of these, we should discount this - it should
not be supported to allow this.

With regards to the first of these, the documentation is not exactly
crystal clear, but the implication is that you must call
X509_STORE_CTX_init() before each call to X509_verify_cert(). If you fail
to do this then, at best, the results would be undefined.

Calling X509_verify_cert() with |ctx->chain| set to a non NULL value is
likely to have unexpected results, and could be dangerous. This commit
changes the behaviour of X509_verify_cert() so that it causes an error if
|ctx->chain| is anything other than NULL (because this indicates that we
have not been initialised properly). It also clarifies the associated
documentation. This is a follow up commit to CVE-2015-1793.

Reviewed-by: Stephen Henson <steve@openssl.org>
2015-07-07 21:50:09 +01:00
..
.cvsignore Add emacs cache files to .cvsignore. 2005-04-11 14:17:07 +00:00
by_dir.c Re-align some comments after running the reformat script. 2015-01-22 09:31:48 +00:00
by_file.c Run util/openssl-format-source -v -c . 2015-01-22 09:31:38 +00:00
Makefile Add test for CVE-2015-1793 2015-07-07 21:48:55 +01:00
verify_extra_test.c Add test for CVE-2015-1793 2015-07-07 21:48:55 +01:00
vpm_int.h Run util/openssl-format-source -v -c . 2015-01-22 09:31:38 +00:00
x509.h Run util/openssl-format-source -v -c . 2015-01-22 09:31:38 +00:00
x509_att.c Run util/openssl-format-source -v -c . 2015-01-22 09:31:38 +00:00
x509_cmp.c Run util/openssl-format-source -v -c . 2015-01-22 09:31:38 +00:00
x509_d2.c Run util/openssl-format-source -v -c . 2015-01-22 09:31:38 +00:00
x509_def.c Run util/openssl-format-source -v -c . 2015-01-22 09:31:38 +00:00
x509_err.c Run util/openssl-format-source -v -c . 2015-01-22 09:31:38 +00:00
x509_ext.c Run util/openssl-format-source -v -c . 2015-01-22 09:31:38 +00:00
x509_lu.c Add NULL checks from master 2015-05-13 12:55:03 -04:00
x509_obj.c Run util/openssl-format-source -v -c . 2015-01-22 09:31:38 +00:00
x509_r2x.c Re-align some comments after running the reformat script. 2015-01-22 09:31:48 +00:00
x509_req.c Check public key is not NULL. 2015-03-02 15:26:41 +00:00
x509_set.c Run util/openssl-format-source -v -c . 2015-01-22 09:31:38 +00:00
x509_trs.c Run util/openssl-format-source -v -c . 2015-01-22 09:31:38 +00:00
x509_txt.c Run util/openssl-format-source -v -c . 2015-01-22 09:31:38 +00:00
x509_v3.c Run util/openssl-format-source -v -c . 2015-01-22 09:31:38 +00:00
x509_vfy.c Reject calls to X509_verify_cert that have not been reinitialised 2015-07-07 21:50:09 +01:00
x509_vfy.h Add flag to inhibit checking for alternate certificate chains. Setting this 2015-04-20 13:42:17 +01:00
x509_vpm.c Fix cut/paste error 2015-05-04 10:54:18 -04:00
x509cset.c Run util/openssl-format-source -v -c . 2015-01-22 09:31:38 +00:00
x509name.c Re-align some comments after running the reformat script. 2015-01-22 09:31:48 +00:00
x509rset.c Run util/openssl-format-source -v -c . 2015-01-22 09:31:38 +00:00
x509spki.c Run util/openssl-format-source -v -c . 2015-01-22 09:31:38 +00:00
x509type.c Correctly check for export size limit 2015-05-20 22:19:34 +02:00
x_all.c Run util/openssl-format-source -v -c . 2015-01-22 09:31:38 +00:00