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