Matt Caswell aae41f8c54 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:57:11 +01:00
..
2015-03-24 07:52:24 -04:00
2015-03-24 07:52:24 -04:00
2013-06-12 23:42:08 +01:00
2015-03-25 11:31:18 -04:00
2014-06-29 13:38:55 +01:00
2000-09-16 15:39:28 +00:00
2014-08-30 09:55:56 -04:00
2006-12-06 09:10:59 +00:00
2010-04-06 14:45:18 +00:00
2015-06-23 17:09:35 -04:00
2014-08-28 18:55:50 -04:00
2015-04-30 21:37:06 -04:00
2015-04-30 21:37:06 -04:00
2009-10-28 13:52:07 +00:00
2015-04-30 21:37:06 -04:00
2015-04-30 21:37:06 -04:00
2015-04-30 21:37:06 -04:00
2015-05-22 23:40:38 +01:00
2015-06-23 17:09:35 -04:00
2013-06-12 23:42:08 +01:00
2014-04-15 18:17:12 +01:00
2013-06-12 23:42:08 +01:00
2013-06-12 23:42:08 +01:00
2015-02-02 22:40:36 -05:00
2015-03-24 23:17:16 -04:00
2009-10-17 17:06:19 +00:00
2015-03-24 23:17:16 -04:00
2013-06-12 23:42:08 +01:00
2015-03-25 18:35:24 -04:00
2015-05-03 08:51:23 -04:00
2013-08-21 13:43:00 +01:00
2015-05-03 08:51:23 -04:00
2000-02-01 01:37:00 +00:00
2004-11-14 15:11:37 +00:00
2014-07-02 03:43:42 +01:00
2000-02-01 01:37:00 +00:00
2000-02-24 11:55:57 +00:00
2000-02-24 11:55:57 +00:00
2000-02-01 01:37:00 +00:00
2000-02-24 11:55:57 +00:00
2000-09-23 07:16:17 +00:00
2015-03-28 10:54:15 -04:00
2013-10-22 07:38:25 +01:00
2013-06-12 23:42:08 +01:00
2014-08-28 18:55:50 -04:00
2014-08-28 18:55:50 -04:00
2015-05-28 18:00:28 +01:00
2006-05-14 11:28:00 +00:00
2009-05-17 14:48:31 +00:00
2000-03-22 15:30:03 +00:00
2015-03-25 12:38:19 +00:00
2013-06-12 23:42:08 +01:00
2001-03-21 15:25:56 +00:00
2013-09-05 21:43:50 +01:00
2014-08-28 18:55:50 -04:00
2014-08-28 18:55:50 -04:00
2000-02-24 11:55:57 +00:00
2006-12-06 09:10:59 +00:00
2015-03-24 23:17:16 -04:00
2003-12-27 15:04:54 +00:00
2015-02-25 20:52:34 +00:00
2006-05-14 11:28:00 +00:00
2015-04-25 16:07:28 -04:00
2007-09-24 11:22:58 +00:00
2015-04-30 17:33:59 -04:00
2010-01-27 12:54:58 +00:00