oweals/openssl.git
8 years agoFix double free in d2i_PrivateKey().
Dr. Stephen Henson [Tue, 3 May 2016 14:05:31 +0000 (15:05 +0100)]
Fix double free in d2i_PrivateKey().

RT#4527

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 3340e8bb186f689df5720352f65a9c0c42b6046b)

8 years agoadd documentation
Dr. Stephen Henson [Tue, 3 May 2016 14:21:41 +0000 (15:21 +0100)]
add documentation

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit b1b3e14fbeb373a288ba20402600e071e6f402f8)

8 years agoPrepare for 1.0.1u-dev
Matt Caswell [Tue, 3 May 2016 13:50:37 +0000 (14:50 +0100)]
Prepare for 1.0.1u-dev

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoPrepare for 1.0.1t release OpenSSL_1_0_1t
Matt Caswell [Tue, 3 May 2016 13:49:52 +0000 (14:49 +0100)]
Prepare for 1.0.1t release

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agomake update
Matt Caswell [Tue, 3 May 2016 13:49:52 +0000 (14:49 +0100)]
make update

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoUpdate CHANGES and NEWS for the new release
Matt Caswell [Tue, 3 May 2016 08:37:23 +0000 (09:37 +0100)]
Update CHANGES and NEWS for the new release

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFix ASN1_INTEGER handling.
Dr. Stephen Henson [Fri, 15 Apr 2016 01:37:09 +0000 (02:37 +0100)]
Fix ASN1_INTEGER handling.

Only treat an ASN1_ANY type as an integer if it has the V_ASN1_INTEGER
tag: V_ASN1_NEG_INTEGER is an internal only value which is never used
for on the wire encoding.

Thanks to David Benjamin <davidben@google.com> for reporting this bug.

This was found using libFuzzer.

RT#4364 (part)CVE-2016-2108.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
8 years agoCheck that we have enough padding characters.
Kurt Roeckx [Sat, 16 Apr 2016 21:08:56 +0000 (23:08 +0200)]
Check that we have enough padding characters.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
CVE-2016-2107

MR: #2572

8 years agoRemove some documentation for functions not in 1.0.x
Matt Caswell [Tue, 3 May 2016 11:45:45 +0000 (12:45 +0100)]
Remove some documentation for functions not in 1.0.x

A few functions in the recently added EVP_EncodeInit docs don't apply to
the 1.0.x branches.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoAdd documentation for EVP_EncodeInit() and similar functions
Matt Caswell [Mon, 25 Apr 2016 10:54:30 +0000 (11:54 +0100)]
Add documentation for EVP_EncodeInit() and similar functions

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoEnsure EVP_EncodeUpdate handles an output length that is too long
Matt Caswell [Mon, 25 Apr 2016 08:06:29 +0000 (09:06 +0100)]
Ensure EVP_EncodeUpdate handles an output length that is too long

With the EVP_EncodeUpdate function it is the caller's responsibility to
determine how big the output buffer should be. The function writes the
amount actually used to |*outl|. However this could go negative with a
sufficiently large value for |inl|. We add a check for this error
condition.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoAvoid overflow in EVP_EncodeUpdate
Matt Caswell [Fri, 4 Mar 2016 10:17:17 +0000 (10:17 +0000)]
Avoid overflow in EVP_EncodeUpdate

An overflow can occur in the EVP_EncodeUpdate function which is used for
Base64 encoding of binary data. If an attacker is able to supply very large
amounts of input data then a length check can overflow resulting in a heap
corruption. Due to the very large amounts of data involved this will most
likely result in a crash.

Internally to OpenSSL the EVP_EncodeUpdate function is primarly used by the
PEM_write_bio* family of functions. These are mainly used within the
OpenSSL command line applications, so any application which processes
data from an untrusted source and outputs it as a PEM file should be
considered vulnerable to this issue.

User applications that call these APIs directly with large amounts of
untrusted data may also be vulnerable.

Issue reported by Guido Vranken.

CVE-2016-2105

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoPrevent EBCDIC overread for very long strings
Matt Caswell [Thu, 28 Apr 2016 09:46:55 +0000 (10:46 +0100)]
Prevent EBCDIC overread for very long strings

ASN1 Strings that are over 1024 bytes can cause an overread in
applications using the X509_NAME_oneline() function on EBCDIC systems.
This could result in arbitrary stack data being returned in the buffer.

Issue reported by Guido Vranken.

CVE-2016-2176

Reviewed-by: Andy Polyakov <appro@openssl.org>
8 years agoFix encrypt overflow
Matt Caswell [Thu, 3 Mar 2016 23:36:23 +0000 (23:36 +0000)]
Fix encrypt overflow

An overflow can occur in the EVP_EncryptUpdate function. If an attacker is
able to supply very large amounts of input data after a previous call to
EVP_EncryptUpdate with a partial block then a length check can overflow
resulting in a heap corruption.

Following an analysis of all OpenSSL internal usage of the
EVP_EncryptUpdate function all usage is one of two forms.

The first form is like this:
EVP_EncryptInit()
EVP_EncryptUpdate()

i.e. where the EVP_EncryptUpdate() call is known to be the first called
function after an EVP_EncryptInit(), and therefore that specific call
must be safe.

The second form is where the length passed to EVP_EncryptUpdate() can be
seen from the code to be some small value and therefore there is no
possibility of an overflow.

Since all instances are one of these two forms, I believe that there can
be no overflows in internal code due to this problem.

It should be noted that EVP_DecryptUpdate() can call EVP_EncryptUpdate()
in certain code paths. Also EVP_CipherUpdate() is a synonym for
EVP_EncryptUpdate(). Therefore I have checked all instances of these
calls too, and came to the same conclusion, i.e. there are no instances
in internal usage where an overflow could occur.

This could still represent a security issue for end user code that calls
this function directly.

CVE-2016-2106

Issue reported by Guido Vranken.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 3f3582139fbb259a1c3cbb0a25236500a409bf26)

8 years agoFix i2d_X509_AUX: pp can be NULL.
Dr. Stephen Henson [Mon, 2 May 2016 16:33:50 +0000 (17:33 +0100)]
Fix i2d_X509_AUX: pp can be NULL.

Reported by David Benjamin

Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 05aef4bbdbc18e7b9490512cdee41e8a608bcc0e)

8 years agoDon't free ret->data if malloc fails.
Dr. Stephen Henson [Wed, 27 Apr 2016 19:27:41 +0000 (20:27 +0100)]
Don't free ret->data if malloc fails.

Issue reported by Guido Vranken.

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 64eaf6c928f4066d62aa86f805796ef05bd0b1cc)

8 years agoAdd checks to X509_NAME_oneline()
Dr. Stephen Henson [Thu, 28 Apr 2016 18:45:44 +0000 (19:45 +0100)]
Add checks to X509_NAME_oneline()

Sanity check field lengths and sums to avoid potential overflows and reject
excessively large X509_NAME structures.

Issue reported by Guido Vranken.

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 9b08619cb45e75541809b1154c90e1a00450e537)

Conflicts:
crypto/x509/x509.h
crypto/x509/x509_err.c

8 years agoSanity check buffer length.
Dr. Stephen Henson [Thu, 28 Apr 2016 12:09:27 +0000 (13:09 +0100)]
Sanity check buffer length.

Reject zero length buffers passed to X509_NAME_onelne().

Issue reported by Guido Vranken.

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit b33d1141b6dcce947708b984c5e9e91dad3d675d)

8 years agoAdd size limit to X509_NAME structure.
Dr. Stephen Henson [Thu, 28 Apr 2016 11:55:29 +0000 (12:55 +0100)]
Add size limit to X509_NAME structure.

This adds an explicit limit to the size of an X509_NAME structure. Some
part of OpenSSL (e.g. TLS) already effectively limit the size due to
restrictions on certificate size.

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 295f3a24919157e2f9021d0b1709353710ad63db)

8 years agoReject inappropriate private key encryption ciphers.
Dr. Stephen Henson [Sat, 23 Apr 2016 12:33:05 +0000 (13:33 +0100)]
Reject inappropriate private key encryption ciphers.

The traditional private key encryption algorithm doesn't function
properly if the IV length of the cipher is zero. These ciphers
(e.g. ECB mode) are not suitable for private key encryption
anyway.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit d78df5dfd650e6de159a19a033513481064644f5)

8 years agoEnsure we check i2d_X509 return val
Matt Caswell [Mon, 25 Apr 2016 15:05:55 +0000 (16:05 +0100)]
Ensure we check i2d_X509 return val

The i2d_X509() function can return a negative value on error. Therefore
we should make sure we check it.

Issue reported by Yuan Jochen Kang.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 446ba8de9af9aa4fa3debc7c76a38f4efed47a62)

8 years agoFix a signed/unsigned warning
Matt Caswell [Mon, 25 Apr 2016 16:45:11 +0000 (17:45 +0100)]
Fix a signed/unsigned warning

This causes a compilation failure when using --strict-warnings in 1.0.2
and 1.0.1

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
(cherry picked from commit 0ca67644ddedfd656d43a6639d89a6236ff64652)

8 years agoFix NULL deref in apps/pkcs7
Rich Salz [Mon, 25 Apr 2016 12:56:54 +0000 (08:56 -0400)]
Fix NULL deref in apps/pkcs7

Thanks to Brian Carpenter for finding and reporting this.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 79356a83b78a2d936dcd022847465d9ebf6c67b1)

8 years agoFix buffer overrun in ASN1_parse().
Viktor Dukhovni [Wed, 20 Apr 2016 02:23:24 +0000 (22:23 -0400)]
Fix buffer overrun in ASN1_parse().

Backport of commits:

        79c7f74d6cefd5d32fa20e69195ad3de834ce065
bdcd660e33710079b495cf5cc6a1aaa5d2dcd317

from master.

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoHarden ASN.1 BIO handling of large amounts of data.
Dr. Stephen Henson [Mon, 11 Apr 2016 12:57:20 +0000 (13:57 +0100)]
Harden ASN.1 BIO handling of large amounts of data.

If the ASN.1 BIO is presented with a large length field read it in
chunks of increasing size checking for EOF on each read. This prevents
small files allocating excessive amounts of data.

CVE-2016-2109

Thanks to Brian Carpenter for reporting this issue.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
(cherry picked from commit c62981390d6cf9e3d612c489b8b77c2913b25807)

8 years agoFix memory leak on invalid CertificateRequest.
David Benjamin [Mon, 14 Mar 2016 19:03:07 +0000 (15:03 -0400)]
Fix memory leak on invalid CertificateRequest.

Free up parsed X509_NAME structure if the CertificateRequest message
contains excess data.

The security impact is considered insignificant. This is a client side
only leak and a large number of connections to malicious servers would
be needed to have a significant impact.

This was found by libFuzzer.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
Reviewed-by: Stephen Henson <steve@openssl.org>
(cherry picked from commit ec66c8c98881186abbb4a7ddd6617970f1ee27a7)

8 years agoFix FIPS SSLv2 test
Dr. Stephen Henson [Sat, 26 Mar 2016 15:00:53 +0000 (15:00 +0000)]
Fix FIPS SSLv2 test

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
(cherry picked from commit 21211ade53f92629250bbea5e37d9179a31d3be2)

8 years agoFix the no-comp option for Windows
Matt Caswell [Thu, 17 Mar 2016 12:55:02 +0000 (12:55 +0000)]
Fix the no-comp option for Windows

no-comp on Windows was not actually suppressing compilation of the code,
although it was suppressing its use.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit a6406c95984a1009f5676bbcf60cc0d6db107af4)

8 years agoAdd a check for a failed malloc
Matt Caswell [Tue, 15 Mar 2016 11:51:48 +0000 (11:51 +0000)]
Add a check for a failed malloc

Ensure we check for a NULL return from OPENSSL_malloc

Issue reported by Guido Vranken.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoEnsure that memory allocated for the ticket is freed
Matt Caswell [Tue, 15 Mar 2016 11:38:56 +0000 (11:38 +0000)]
Ensure that memory allocated for the ticket is freed

If a call to EVP_DecryptUpdate fails then a memory leak could occur.
Ensure that the memory is freed appropriately.

Issue reported by Guido Vranken.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFix a potential double free in EVP_DigestInit_ex
Matt Caswell [Mon, 14 Mar 2016 17:06:19 +0000 (17:06 +0000)]
Fix a potential double free in EVP_DigestInit_ex

There is a potential double free in EVP_DigestInit_ex. This is believed
to be reached only as a result of programmer error - but we should fix it
anyway.

Issue reported by Guido Vranken.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit ffe9150b1508a0ffc9e724f975691f24eb045c05)

8 years agoAdd no-ssl2-method
Kurt Roeckx [Wed, 9 Mar 2016 17:10:52 +0000 (18:10 +0100)]
Add no-ssl2-method

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
MR: #2341
(cherry picked from commit 4256957570a233ed4e9840353e95e623dfd62086)

8 years agoexpose SSLv2 method prototypes
Viktor Dukhovni [Tue, 8 Mar 2016 20:30:27 +0000 (15:30 -0500)]
expose SSLv2 method prototypes

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
8 years agoRetain SSLv2 methods as functions that return NULL
Viktor Dukhovni [Mon, 7 Mar 2016 21:10:38 +0000 (21:10 +0000)]
Retain SSLv2 methods as functions that return NULL

This improves ABI compatibility when symbol resolution is not lazy.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agobn/asm/x86[_64]-mont*.pl: complement alloca with page-walking.
Andy Polyakov [Fri, 4 Mar 2016 10:39:11 +0000 (11:39 +0100)]
bn/asm/x86[_64]-mont*.pl: complement alloca with page-walking.

Some OSes, *cough*-dows, insist on stack being "wired" to
physical memory in strictly sequential manner, i.e. if stack
allocation spans two pages, then reference to farmost one can
be punishable by SEGV. But page walking can do good even on
other OSes, because it guarantees that villain thread hits
the guard page before it can make damage to innocent one...

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit adc4f1fc25b2cac90076f1e1695b05b7aeeae501)

Resolved conflicts:
crypto/bn/asm/x86_64-mont.pl
crypto/bn/asm/x86_64-mont5.pl

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoRemove LOW from the default
Kurt Roeckx [Sun, 10 Jan 2016 12:23:43 +0000 (13:23 +0100)]
Remove LOW from the default

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
(cherry picked from commit 29cce508972f61511318bf8cf7011fae027cddb2)

8 years agoDon't shift serial number into sign bit
Dr. Stephen Henson [Fri, 4 Mar 2016 18:04:46 +0000 (18:04 +0000)]
Don't shift serial number into sign bit

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 01c32b5e448f6d42a23ff16bdc6bb0605287fa6f)

8 years agoSanity check PVK file fields.
Dr. Stephen Henson [Thu, 3 Mar 2016 23:37:36 +0000 (23:37 +0000)]
Sanity check PVK file fields.

PVK files with abnormally large length or salt fields can cause an
integer overflow which can result in an OOB read and heap corruption.
However this is an rarely used format and private key files do not
normally come from untrusted sources the security implications not
significant.

Fix by limiting PVK length field to 100K and salt to 10K: these should be
more than enough to cover any files encountered in practice.

Issue reported by Guido Vranken.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 5f57abe2b150139b8b057313d52b1fe8f126c952)

8 years agoPrepare for 1.0.1t-dev
Matt Caswell [Tue, 1 Mar 2016 13:42:02 +0000 (13:42 +0000)]
Prepare for 1.0.1t-dev

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoPrepare for 1.0.1s release OpenSSL_1_0_1s
Matt Caswell [Tue, 1 Mar 2016 13:40:46 +0000 (13:40 +0000)]
Prepare for 1.0.1s release

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agomake update
Matt Caswell [Tue, 1 Mar 2016 13:40:45 +0000 (13:40 +0000)]
make update

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoEnsure mk1mf.pl is aware of no-weak-ssl-ciphers option
Matt Caswell [Tue, 1 Mar 2016 12:08:33 +0000 (12:08 +0000)]
Ensure mk1mf.pl is aware of no-weak-ssl-ciphers option

Update mk1mf.pl to properly handle no-weak-ssl-ciphers

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoUpdate CHANGES and NEWS for new release
Matt Caswell [Tue, 1 Mar 2016 11:00:48 +0000 (11:00 +0000)]
Update CHANGES and NEWS for new release

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoperlasm/x86_64-xlate.pl: handle inter-bank movd.
Andy Polyakov [Thu, 11 Sep 2014 22:06:00 +0000 (00:06 +0200)]
perlasm/x86_64-xlate.pl: handle inter-bank movd.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 902b30df193afc3417a96ba72a81ed390bd50de3)

8 years agocrypto/bn/x86_64-mont5.pl: constant-time gather procedure.
Andy Polyakov [Tue, 26 Jan 2016 15:25:02 +0000 (16:25 +0100)]
crypto/bn/x86_64-mont5.pl: constant-time gather procedure.

[Backport from master]

CVE-2016-0702

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agobn/bn_exp.c: constant-time MOD_EXP_CTIME_COPY_FROM_PREBUF.
Andy Polyakov [Tue, 26 Jan 2016 10:34:41 +0000 (11:34 +0100)]
bn/bn_exp.c: constant-time MOD_EXP_CTIME_COPY_FROM_PREBUF.

Performance penalty varies from platform to platform, and even
key length. For rsa2048 sign it was observed to reach almost 10%.

CVE-2016-0702

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoDisable EXPORT and LOW SSLv3+ ciphers by default
Viktor Dukhovni [Fri, 19 Feb 2016 18:05:11 +0000 (13:05 -0500)]
Disable EXPORT and LOW SSLv3+ ciphers by default

Reviewed-by: Emilia Käsper <emilia@openssl.org>
8 years agoBring SSL method documentation up to date
Viktor Dukhovni [Thu, 18 Feb 2016 04:22:59 +0000 (23:22 -0500)]
Bring SSL method documentation up to date

Reviewed-by: Emilia Käsper <emilia@openssl.org>
8 years agoDisable SSLv2 default build, default negotiation and weak ciphers.
Viktor Dukhovni [Thu, 18 Feb 2016 02:37:15 +0000 (21:37 -0500)]
Disable SSLv2 default build, default negotiation and weak ciphers.

SSLv2 is by default disabled at build-time.  Builds that are not
configured with "enable-ssl2" will not support SSLv2.  Even if
"enable-ssl2" is used, users who want to negotiate SSLv2 via the
version-flexible SSLv23_method() will need to explicitly call either
of:

    SSL_CTX_clear_options(ctx, SSL_OP_NO_SSLv2);
or
    SSL_clear_options(ssl, SSL_OP_NO_SSLv2);

as appropriate.  Even if either of those is used, or the application
explicitly uses the version-specific SSLv2_method() or its client
or server variants, SSLv2 ciphers vulnerable to exhaustive search
key recovery have been removed.  Specifically, the SSLv2 40-bit
EXPORT ciphers, and SSLv2 56-bit DES are no longer available.

Mitigation for CVE-2016-0800

Reviewed-by: Emilia Käsper <emilia@openssl.org>
8 years agoFix BN_hex2bn/BN_dec2bn NULL ptr/heap corruption
Matt Caswell [Mon, 22 Feb 2016 10:27:18 +0000 (10:27 +0000)]
Fix BN_hex2bn/BN_dec2bn NULL ptr/heap corruption

In the BN_hex2bn function the number of hex digits is calculated using
an int value |i|. Later |bn_expand| is called with a value of |i * 4|.
For large values of |i| this can result in |bn_expand| not allocating any
memory because |i * 4| is negative. This leaves ret->d as NULL leading
to a subsequent NULL ptr deref. For very large values of |i|, the
calculation |i * 4| could be a positive value smaller than |i|. In this
case memory is allocated to ret->d, but it is insufficiently sized
leading to heap corruption. A similar issue exists in BN_dec2bn.

This could have security consequences if BN_hex2bn/BN_dec2bn is ever
called by user applications with very large untrusted hex/dec data. This is
anticipated to be a rare occurrence.

All OpenSSL internal usage of this function uses data that is not expected
to be untrusted, e.g. config file data or application command line
arguments. If user developed applications generate config file data based
on untrusted data then it is possible that this could also lead to security
consequences. This is also anticipated to be a rare.

Issue reported by Guido Vranken.

CVE-2016-0797

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit c175308407858afff3fc8c2e5e085d94d12edc7d)

8 years agoRevert "Don't check RSA_FLAG_SIGN_VER."
Kurt Roeckx [Sat, 27 Feb 2016 12:38:01 +0000 (13:38 +0100)]
Revert "Don't check RSA_FLAG_SIGN_VER."

This reverts commit 23a58779f53a9060c823d00d76b3070cad61d9a3.

This broke existing engines that didn't properly implement the sign and verify
functions.

Reviewed-by: Richard Levitte <levitte@openssl.org>
MR: #2077

8 years agoFix memory issues in BIO_*printf functions
Matt Caswell [Thu, 25 Feb 2016 13:09:46 +0000 (13:09 +0000)]
Fix memory issues in BIO_*printf functions

The internal |fmtstr| function used in processing a "%s" format string
in the BIO_*printf functions could overflow while calculating the length
of a string and cause an OOB read when printing very long strings.

Additionally the internal |doapr_outch| function can attempt to write to
an OOB memory location (at an offset from the NULL pointer) in the event of
a memory allocation failure. In 1.0.2 and below this could be caused where
the size of a buffer to be allocated is greater than INT_MAX. E.g. this
could be in processing a very long "%s" format string. Memory leaks can also
occur.

These issues will only occur on certain platforms where sizeof(size_t) >
sizeof(int). E.g. many 64 bit systems. The first issue may mask the second
issue dependent on compiler behaviour.

These problems could enable attacks where large amounts of untrusted data
is passed to the BIO_*printf functions. If applications use these functions
in this way then they could be vulnerable. OpenSSL itself uses these
functions when printing out human-readable dumps of ASN.1 data. Therefore
applications that print this data could be vulnerable if the data is from
untrusted sources. OpenSSL command line applications could also be
vulnerable where they print out ASN.1 data, or if untrusted data is passed
as command line arguments.

Libssl is not considered directly vulnerable. Additionally certificates etc
received via remote connections via libssl are also unlikely to be able to
trigger these issues because of message size limits enforced within libssl.

CVE-2016-0799

Issue reported by Guido Vranken.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit 578b956fe741bf8e84055547b1e83c28dd902c73)

8 years agoCVE-2016-0798: avoid memory leak in SRP
Emilia Kasper [Wed, 24 Feb 2016 11:59:59 +0000 (12:59 +0100)]
CVE-2016-0798: avoid memory leak in SRP

The SRP user database lookup method SRP_VBASE_get_by_user had confusing
memory management semantics; the returned pointer was sometimes newly
allocated, and sometimes owned by the callee. The calling code has no
way of distinguishing these two cases.

Specifically, SRP servers that configure a secret seed to hide valid
login information are vulnerable to a memory leak: an attacker
connecting with an invalid username can cause a memory leak of around
300 bytes per connection.

Servers that do not configure SRP, or configure SRP but do not configure
a seed are not vulnerable.

In Apache, the seed directive is known as SSLSRPUnknownUserSeed.

To mitigate the memory leak, the seed handling in SRP_VBASE_get_by_user
is now disabled even if the user has configured a seed.

Applications are advised to migrate to SRP_VBASE_get1_by_user. However,
note that OpenSSL makes no strong guarantees about the
indistinguishability of valid and invalid logins. In particular,
computations are currently not carried out in constant time.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoGH714: missing field initialisation
FdaSilvaYY [Fri, 19 Feb 2016 22:28:52 +0000 (23:28 +0100)]
GH714: missing field initialisation

Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
(cherry picked from commit 04f2a0b50d219aafcef2fa718d91462b587aa23d)

8 years agoFix double free in DSA private key parsing.
Dr. Stephen Henson [Thu, 18 Feb 2016 12:47:23 +0000 (12:47 +0000)]
Fix double free in DSA private key parsing.

Fix double free bug when parsing malformed DSA private keys.

Thanks to Adam Langley (Google/BoringSSL) for discovering this bug using
libFuzzer.

CVE-2016-0705

Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 6c88c71b4e4825c7bc0489306d062d017634eb88)

8 years agomodes/ctr128.c: pay attention to ecount_buf alignment in CRYPTO_ctr128_encrypt.
Andy Polyakov [Fri, 12 Feb 2016 13:07:27 +0000 (14:07 +0100)]
modes/ctr128.c: pay attention to ecount_buf alignment in CRYPTO_ctr128_encrypt.

It's never problem if CRYPTO_ctr128_encrypt is called from EVP, because
buffer in question is always aligned within EVP_CIPHER_CTX structure.

RT#4218

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 5e4bbeb49fb6522d858703201b5adee9611e7b7b)

8 years agoutil/mk1mf.pl: use LINK_CMD instead of LINK variable.
Andy Polyakov [Wed, 3 Feb 2016 17:21:00 +0000 (18:21 +0100)]
util/mk1mf.pl: use LINK_CMD instead of LINK variable.

Trouble is that LINK variable assignment in make-file interferes with
LINK environment variable, which can be used to modify Microsoft's
LINK.EXE behaviour.

RT#4289

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit d44bb1c31ca00f4359090daa15659c0dd1a08f0d)

Resolved conflicts:
util/pl/VC-32.pl

(cherry picked from commit 0fffd522426c7fc022894c8dd079dc2625c04096)

8 years agoms/uplink-x86.pl: make it work.
Andy Polyakov [Tue, 9 Feb 2016 10:53:11 +0000 (11:53 +0100)]
ms/uplink-x86.pl: make it work.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 740b2b9a6cf31b02916a4d18f868e8a95934c083)

8 years agoFix CHANGES entry about DSA_generate_parameters_ex
Kurt Roeckx [Wed, 27 Jan 2016 19:31:57 +0000 (20:31 +0100)]
Fix CHANGES entry about DSA_generate_parameters_ex

Reviewed-by: Viktor Dukhovni <openssl-users@dukhovni.org>
(cherry picked from commit 2b0c11a620c3a3431410c5d56799286f60f60d8d)

8 years agoCorrect number of arguments in BIO_get_conn_int_port macro
Richard Levitte [Thu, 28 Jan 2016 16:55:11 +0000 (17:55 +0100)]
Correct number of arguments in BIO_get_conn_int_port macro

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 41a28cb2944a4e1c9d13889757a3bd9f72abeca1)

8 years agoPrepare for 1.0.1s-dev
Matt Caswell [Thu, 28 Jan 2016 14:22:09 +0000 (14:22 +0000)]
Prepare for 1.0.1s-dev

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoPrepare for 1.0.1r release OpenSSL_1_0_1r
Matt Caswell [Thu, 28 Jan 2016 14:21:21 +0000 (14:21 +0000)]
Prepare for 1.0.1r release

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoTARFILE wasn't correctly set
Richard Levitte [Thu, 28 Jan 2016 14:18:50 +0000 (15:18 +0100)]
TARFILE wasn't correctly set

This solves an earlier cherry-pick mistake.

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoFurther updates to CHANGES and NEWS
Matt Caswell [Thu, 28 Jan 2016 12:28:53 +0000 (12:28 +0000)]
Further updates to CHANGES and NEWS

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoUpdate CHANGES and NEWS ready for release
Matt Caswell [Wed, 27 Jan 2016 13:55:05 +0000 (13:55 +0000)]
Update CHANGES and NEWS ready for release

Update CHANGES and NEWS with details of the issues fixed in the forthcoming
release.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoBetter SSLv2 cipher-suite enforcement
Viktor Dukhovni [Thu, 31 Dec 2015 03:44:51 +0000 (22:44 -0500)]
Better SSLv2 cipher-suite enforcement

Based on patch by: Nimrod Aviram <nimrod.aviram@gmail.com>

CVE-2015-3197

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoAlways generate DH keys for ephemeral DH cipher suites
Matt Caswell [Thu, 17 Dec 2015 02:57:20 +0000 (02:57 +0000)]
Always generate DH keys for ephemeral DH cipher suites

Modified version of the commit ffaef3f15 in the master branch by Stephen
Henson. This makes the SSL_OP_SINGLE_DH_USE option a no-op and always
generates a new DH key for every handshake regardless.

This is a follow on from CVE-2016-0701. This branch is not impacted by
that CVE because it does not support X9.42 style parameters. It is still
possible to generate parameters based on primes that are not "safe",
although by default OpenSSL does not do this. The documentation does
sign post that using such parameters is unsafe if the private DH key is
reused. However to avoid accidental problems or future attacks this commit
has been backported to this branch.

Issue reported by Antonio Sanso

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoFix BSD -rpath parameter
Richard Levitte [Tue, 19 Jan 2016 19:35:41 +0000 (20:35 +0100)]
Fix BSD -rpath parameter

For BSD systems, Configure adds a shared_ldflags including a reference
to the Makefile variable LIBRPATH, but since it must be passed down to
Makefile.shared, care must be taken so the value of LIBRPATH doesn't
get expanded too early, or it ends up giving an empty string.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
(cherry picked from commit c64879d3f3cc4c7f1c436a9fe3bd109847a23629)

8 years agoValidate ClientHello session_id field length and send alert on failure
Alessandro Ghedini [Wed, 13 Jan 2016 12:49:24 +0000 (12:49 +0000)]
Validate ClientHello session_id field length and send alert on failure

RT#4080

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoUpdate license year range to 2016
Prayag Verma [Mon, 18 Jan 2016 03:19:09 +0000 (08:49 +0530)]
Update license year range to 2016

Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 02f70372470b4dd3b21443bb615292175f5d2c88)

8 years agoEmpty SNI names are not valid
Viktor Dukhovni [Sat, 16 Jan 2016 17:57:24 +0000 (12:57 -0500)]
Empty SNI names are not valid

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoTo avoid possible time_t overflow use X509_time_adj_ex()
Dr. Stephen Henson [Thu, 14 Jan 2016 00:25:25 +0000 (00:25 +0000)]
To avoid possible time_t overflow use X509_time_adj_ex()

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
(cherry picked from commit 9aa00b187a65b1f30789d6274ec31ea86efe7973)

Conflicts:
apps/x509.c

8 years agoChange minimum DH size from 768 to 1024
Kurt Roeckx [Sun, 10 Jan 2016 12:55:08 +0000 (13:55 +0100)]
Change minimum DH size from 768 to 1024

Reviewed-by: Viktor Dukhovni <openssl-users@dukhovni.org>
8 years agoFile is about s_time, not s_client
Kurt Roeckx [Sat, 2 Jan 2016 19:42:27 +0000 (20:42 +0100)]
File is about s_time, not s_client

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit 1918e01c9f915e2eba31a5e2f86f0a5daa4fafb6)

8 years agoFix X509_STORE_CTX_cleanup()
Viktor Dukhovni [Fri, 1 Jan 2016 05:51:12 +0000 (00:51 -0500)]
Fix X509_STORE_CTX_cleanup()

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
8 years agoRT4202: Update rt URL's.
Rich Salz [Mon, 28 Dec 2015 19:58:23 +0000 (14:58 -0500)]
RT4202: Update rt URL's.

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 41977c53cd04f52b2b5e56d31ace782577620ac3)

8 years agoAdd some documentation for the OCSP callback functions
Matt Caswell [Mon, 30 Nov 2015 16:04:51 +0000 (16:04 +0000)]
Add some documentation for the OCSP callback functions

Describe the usage of the OCSP callback functions on both the client and
the server side.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
(cherry picked from commit c52c3b5e11253afabaa62739a8ee1c4c4bddcd53)

8 years agoEnsure we don't call the OCSP callback if resuming a session
Matt Caswell [Mon, 30 Nov 2015 13:29:41 +0000 (13:29 +0000)]
Ensure we don't call the OCSP callback if resuming a session

It makes no sense to call the OCSP status callback if we are resuming a
session because no certificates will be sent.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
(cherry picked from commit 0ac6239955965f58f9dddb4229e8cd58e0dba20d)

8 years agoFix error when server does not send CertificateStatus message
Matt Caswell [Thu, 5 Nov 2015 14:52:27 +0000 (14:52 +0000)]
Fix error when server does not send CertificateStatus message

If a server sends the status_request extension then it may choose
to send the CertificateStatus message. However this is optional.
We were treating it as mandatory and the connection was failing.

Thanks to BoringSSL for reporting this issue.

RT#4120

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
(cherry picked from commit 905943af3b43116b64ae815db1a6b9c2f15e0356)

8 years agoFix memory leak in DSA redo case.
David Benjamin [Thu, 17 Dec 2015 19:11:11 +0000 (20:11 +0100)]
Fix memory leak in DSA redo case.

Found by clang scan-build.

Signed-off-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Richard Levitte <levitte@openssl.org>
RT: #4184, MR: #1496
(cherry picked from commit 679d87515d23ca31491effdc264edc81c695a72a)

8 years agoDon't check RSA_FLAG_SIGN_VER.
Dr. Stephen Henson [Sun, 20 Dec 2015 18:18:43 +0000 (18:18 +0000)]
Don't check RSA_FLAG_SIGN_VER.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 6656ba7152dfe4bba865e327dd362ea08544aa80)

8 years agoBIO_s_datagram() ctrl doesn't support SEEK/TELL, so don't pretend it does
Richard Levitte [Mon, 2 Nov 2015 15:43:28 +0000 (16:43 +0100)]
BIO_s_datagram() ctrl doesn't support SEEK/TELL, so don't pretend it does

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 17592f323ac7dad381cc3b512573c291b1a820c0)

8 years agoCorrect or add comments indicating what controls belong to what
Richard Levitte [Sun, 1 Nov 2015 14:56:21 +0000 (15:56 +0100)]
Correct or add comments indicating what controls belong to what

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 6d97060ee00518efc99c5d89a78529dc111780fb)

8 years agoDocument how BIO_get_conn_ip and BIO_get_conn_int_port actually work
Richard Levitte [Sun, 1 Nov 2015 14:45:49 +0000 (15:45 +0100)]
Document how BIO_get_conn_ip and BIO_get_conn_int_port actually work

No dummy arguments.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 7eb51251252ea0b269227d267512b98495f51bc4)

8 years agoHave BIO_get_conn_int_port use BIO_ctrl instead BIO_int_ctrl
Richard Levitte [Sun, 1 Nov 2015 14:42:04 +0000 (15:42 +0100)]
Have BIO_get_conn_int_port use BIO_ctrl instead BIO_int_ctrl

BIO_int_ctrl isn't made for the purpose BIO_get_conn_int_port used it
for.

This also changes BIO_C_GET_CONNECT to actually return the port
instead of assigning it to a pointer that was never returned back to
the caller.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 2a60fccdd9b696e01fddaa268e92ea210beb0e8f)

8 years agoFix more URLs mangled by reformat
Matt Caswell [Sat, 19 Dec 2015 14:42:06 +0000 (14:42 +0000)]
Fix more URLs mangled by reformat

Fix some more URLs mangled by indent in the reformat. These ones don't exist
in master so we have a separate commit. Based on a patch supplied by Arnaud
Lacombe <al@aerilon.ca>

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFix URLs mangled by reformat
Matt Caswell [Sat, 19 Dec 2015 14:38:17 +0000 (14:38 +0000)]
Fix URLs mangled by reformat

Some URLs in the source code ended up getting mangled by indent. This fixes
it. Based on a patch supplied by Arnaud Lacombe <al@aerilon.ca>

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoRemove the "eay" c-file-style indicators
Richard Levitte [Fri, 18 Dec 2015 12:13:31 +0000 (13:13 +0100)]
Remove the "eay" c-file-style indicators

Since we don't use the eay style any more, there's no point tryint to
tell emacs to use it.

Reviewed-by: Ben Laurie <ben@openssl.org>
8 years agoProvide better "make depend" warning.
Rich Salz [Thu, 10 Dec 2015 17:31:01 +0000 (12:31 -0500)]
Provide better "make depend" warning.

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 2e31ef0366d368ac8cf7f5ecc9052bff27337799)

8 years agoFix a ** 0 mod 1 = 0 for real this time.
Emilia Kasper [Mon, 14 Dec 2015 15:38:15 +0000 (16:38 +0100)]
Fix a ** 0 mod 1 = 0 for real this time.

Commit 2b0180c37fa6ffc48ee40caa831ca398b828e680 attempted to do this but
only hit one of many BN_mod_exp codepaths. Fix remaining variants and add
a test for each method.

Thanks to Hanno Boeck for reporting this issue.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit d911097d7c93e4cfeab624b34d73fe51da158b69)
(cherry picked from commit 44e4f5b04b43054571e278381662cebd3f3555e6)

8 years agoFix tarball production to keep test/bctest and util/pod2mantest
Richard Levitte [Mon, 14 Dec 2015 02:53:06 +0000 (03:53 +0100)]
Fix tarball production to keep test/bctest and util/pod2mantest

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 474a53b3a36568d19d7b918ee879efd2707e7c67)

8 years agoEnsure |rwstate| is set correctly on BIO_flush
Matt Caswell [Wed, 4 Nov 2015 11:20:50 +0000 (11:20 +0000)]
Ensure |rwstate| is set correctly on BIO_flush

A BIO_flush call in the DTLS code was not correctly setting the |rwstate|
variable to SSL_WRITING. This means that SSL_get_error() will not return
SSL_ERROR_WANT_WRITE in the event of an IO retry.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 67f60be8c9ae5ff3129fcd6238baf124385a41d8)

8 years agoFix DTLS handshake fragment retries
Matt Caswell [Tue, 3 Nov 2015 14:45:07 +0000 (14:45 +0000)]
Fix DTLS handshake fragment retries

If using DTLS and NBIO then if a second or subsequent handshake message
fragment hits a retry, then the retry attempt uses the wrong fragment
offset value. This commit restores the fragment offset from the last
attempt.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 2ad226e88bee97847496e542d63c67997d5beda6)

8 years agoDon't use applink for static builds.
Dr Stephen Henson [Tue, 8 Dec 2015 19:10:48 +0000 (19:10 +0000)]
Don't use applink for static builds.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 10119938215298ad414468e7c2779d7fd1a0b979)

8 years agoRefer to website for acknowledgements.
Rich Salz [Tue, 8 Dec 2015 21:07:09 +0000 (16:07 -0500)]
Refer to website for acknowledgements.

Reviewed-by: Steve Marquess <marquess@openssl.com>
(cherry picked from commit ab29c82a55f3583a490733dd521ea6c486e8e2fb)

8 years agoNot all 'find's know -xtype, use -type instead
Richard Levitte [Tue, 8 Dec 2015 14:34:52 +0000 (15:34 +0100)]
Not all 'find's know -xtype, use -type instead

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 3cd7aef34d0d414d27ab00abadb99265a2cffde9)

8 years agoAdapt the OS X build to use the OS X tar
Richard Levitte [Tue, 8 Dec 2015 11:43:05 +0000 (12:43 +0100)]
Adapt the OS X build to use the OS X tar

As part of this, move release creation to a script to be called from
.travis.yml.  That makes it much easier to test outside of travis.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 382af61f6213e975b4c2a50fd8b9fedd23d86ab5)

8 years agoMake it possible to affect the way dists are made
Richard Levitte [Tue, 8 Dec 2015 11:42:27 +0000 (12:42 +0100)]
Make it possible to affect the way dists are made

Introducing DISTTARVARS to propagate changed variables down to the
tar-making target.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 4d3c30a1799bf7b4dc7223b84417c4de992a6b9c)

8 years agoCleanup the EVP_MD_CTX before exit rather than after
Richard Levitte [Tue, 8 Dec 2015 00:01:13 +0000 (01:01 +0100)]
Cleanup the EVP_MD_CTX before exit rather than after

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit c44844d928ad3c471c8dbe8baf2df8957900125b)

8 years agoChange tar owner and group to just 0
Richard Levitte [Mon, 7 Dec 2015 15:50:15 +0000 (16:50 +0100)]
Change tar owner and group to just 0

It seems like some tar versions don't like the name:id form for
--owner and --group.  The closest known anonymous user being 0 (root),
that seems to be the most appropriate user/group to assign ownership
to.  It matters very little when unpacking either way.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit b91dd150d2b9b5ddca37722e7f52ea59ba7f80da)