libcrypto "Client DoS due to large DH parameter"

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

libcrypto "Client DoS due to large DH parameter"

Stuart Henderson
from https://github.com/openssl/openssl/commit/3984ef0b7 (advisory forwarded
below).  is it ok to just use this directly?

Index: dh_key.c
===================================================================
RCS file: /cvs/src/lib/libcrypto/dh/dh_key.c,v
retrieving revision 1.27
diff -u -p -r1.27 dh_key.c
--- dh_key.c 29 Jan 2017 17:49:22 -0000 1.27
+++ dh_key.c 12 Jun 2018 14:08:13 -0000
@@ -104,10 +104,15 @@ generate_key(DH *dh)
  int ok = 0;
  int generate_new_key = 0;
  unsigned l;
- BN_CTX *ctx;
+ BN_CTX *ctx = NULL;
  BN_MONT_CTX *mont = NULL;
  BIGNUM *pub_key = NULL, *priv_key = NULL;
 
+ if (BN_num_bits(dh->p) > OPENSSL_DH_MAX_MODULUS_BITS) {
+ DHerr(DH_F_GENERATE_KEY, DH_R_MODULUS_TOO_LARGE);
+ return 0;
+ }
+
  ctx = BN_CTX_new();
  if (ctx == NULL)
  goto err;

----- Forwarded message from OpenSSL <[hidden email]> -----

From: OpenSSL <[hidden email]>
Organization: OpenSSL Project
Date: Tue, 12 Jun 2018 10:18:03 +0000
To: [hidden email], OpenSSL User Support ML <[hidden email]>, OpenSSL Announce ML
        <[hidden email]>
Reply-To: [hidden email], [hidden email]
User-Agent: Mutt/1.5.24 (2015-08-30)
Subject: [openssl-announce] OpenSSL Security Advisory


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512


OpenSSL Security Advisory [12 June 2018]
========================================

Client DoS due to large DH parameter (CVE-2018-0732)
====================================================

Severity: Low

During key agreement in a TLS handshake using a DH(E) based ciphersuite a
malicious server can send a very large prime value to the client. This will
cause the client to spend an unreasonably long period of time generating a key
for this prime resulting in a hang until the client has finished. This could be
exploited in a Denial Of Service attack.

Due to the low severity of this issue we are not issuing a new release of
OpenSSL 1.1.0 or 1.0.2 at this time. The fix will be included in OpenSSL 1.1.0i
and OpenSSL 1.0.2p when they become available. The fix is also available in
commit ea7abeeab (for 1.1.0) and commit 3984ef0b7 (for 1.0.2) in the OpenSSL git
repository.

This issue was reported to OpenSSL on 5th June 2018 by Guido Vranken who also
developed the fix.

References
==========

URL for this Security Advisory:
https://www.openssl.org/news/secadv/20180612.txt

Note: the online version of the advisory may be updated with additional details
over time.

For details of OpenSSL severity classifications please see:
https://www.openssl.org/policies/secpolicy.html
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCgAdFiEEhlersmDwVrHlGQg52cTSbQ5gRJEFAlsfnTgACgkQ2cTSbQ5g
RJE9Twf/VSgXaFPlW+JyA2BAiwGREMr/oMQe8mhmka3WQgNb7oMQRxk4ZqwRvLi2
ggPVOQilJ+tkXgeifEQ3SDRxDnnmcUvxbWB8Lt+7tjhM6O+GYGbGbzupnkBs2IIY
72vll4l7ySMQ8/fcdU/uuNyObfigLC9XndH3tEewxffs6uvDxMyGhZmNQpq1aZNj
rGj3dETUuO/Ln8siAD7nkv9xodRINViMP76fSKAtdaikvZa3uhLBMhX5tOzpR/ta
tc2+6uthdU9JjSRZZpfDlzzhsOFqMrLfOLrJQIIXshxUNeOZyJCkmT9ED8XZRDMB
twb1kOxCKz8Ky+Xm/Rki9uRVoZFjBg==
=kKic
-----END PGP SIGNATURE-----
--
openssl-announce mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-announce

----- End forwarded message -----


Reply | Threaded
Open this post in threaded view
|

Re: libcrypto "Client DoS due to large DH parameter"

Theo Buehler-5
On Tue, Jun 12, 2018 at 03:24:39PM +0100, Stuart Henderson wrote:

> from https://github.com/openssl/openssl/commit/3984ef0b7 (advisory forwarded
> below).  is it ok to just use this directly?
>
> Index: dh_key.c
> ===================================================================
> RCS file: /cvs/src/lib/libcrypto/dh/dh_key.c,v
> retrieving revision 1.27
> diff -u -p -r1.27 dh_key.c
> --- dh_key.c 29 Jan 2017 17:49:22 -0000 1.27
> +++ dh_key.c 12 Jun 2018 14:08:13 -0000
> @@ -104,10 +104,15 @@ generate_key(DH *dh)
>   int ok = 0;
>   int generate_new_key = 0;
>   unsigned l;
> - BN_CTX *ctx;
> + BN_CTX *ctx = NULL;

I don't object to doing this initialization, but I don't really see the
point of it -- unless you plan to do 'goto err' instead of 'return 0'
(but this would add a pointless generic ERR_R_BN_LIB error).

>   BN_MONT_CTX *mont = NULL;
>   BIGNUM *pub_key = NULL, *priv_key = NULL;
>  
> + if (BN_num_bits(dh->p) > OPENSSL_DH_MAX_MODULUS_BITS) {
> + DHerr(DH_F_GENERATE_KEY, DH_R_MODULUS_TOO_LARGE);

We don't use these two parameter error macros anymore. Please use

                DHerror(DH_R_MODULUS_TOO_LARGE);

With that it's

ok tb

(provided that those more knowledgeable about the fine points of
licencing agree that it's fine pulling it in.)

> + return 0;
> + }
> +
>   ctx = BN_CTX_new();
>   if (ctx == NULL)
>   goto err;

Reply | Threaded
Open this post in threaded view
|

Re: libcrypto "Client DoS due to large DH parameter"

Stuart Henderson
On 2018/06/12 16:47, Theo Buehler wrote:

> On Tue, Jun 12, 2018 at 03:24:39PM +0100, Stuart Henderson wrote:
> > from https://github.com/openssl/openssl/commit/3984ef0b7 (advisory forwarded
> > below).  is it ok to just use this directly?
> >
> > Index: dh_key.c
> > ===================================================================
> > RCS file: /cvs/src/lib/libcrypto/dh/dh_key.c,v
> > retrieving revision 1.27
> > diff -u -p -r1.27 dh_key.c
> > --- dh_key.c 29 Jan 2017 17:49:22 -0000 1.27
> > +++ dh_key.c 12 Jun 2018 14:08:13 -0000
> > @@ -104,10 +104,15 @@ generate_key(DH *dh)
> >   int ok = 0;
> >   int generate_new_key = 0;
> >   unsigned l;
> > - BN_CTX *ctx;
> > + BN_CTX *ctx = NULL;
>
> I don't object to doing this initialization, but I don't really see the
> point of it -- unless you plan to do 'goto err' instead of 'return 0'
> (but this would add a pointless generic ERR_R_BN_LIB error).

oh, that must be a holdover from Guido's first diff which did use goto err.

> >   BN_MONT_CTX *mont = NULL;
> >   BIGNUM *pub_key = NULL, *priv_key = NULL;
> >  
> > + if (BN_num_bits(dh->p) > OPENSSL_DH_MAX_MODULUS_BITS) {
> > + DHerr(DH_F_GENERATE_KEY, DH_R_MODULUS_TOO_LARGE);
>
> We don't use these two parameter error macros anymore. Please use
>
> DHerror(DH_R_MODULUS_TOO_LARGE);

oops :) started the build but forgot to check it before sending the mail ...

updated for these two below.

> With that it's
>
> ok tb
>
> (provided that those more knowledgeable about the fine points of
> licencing agree that it's fine pulling it in.)

I'm not sure what ended up happening with the switch to Apache license,
but the license in their repo hasn't changed.

Index: dh/dh_key.c
===================================================================
RCS file: /cvs/src/lib/libcrypto/dh/dh_key.c,v
retrieving revision 1.27
diff -u -p -r1.27 dh_key.c
--- dh/dh_key.c 29 Jan 2017 17:49:22 -0000 1.27
+++ dh/dh_key.c 12 Jun 2018 15:15:39 -0000
@@ -108,6 +108,11 @@ generate_key(DH *dh)
  BN_MONT_CTX *mont = NULL;
  BIGNUM *pub_key = NULL, *priv_key = NULL;
 
+ if (BN_num_bits(dh->p) > OPENSSL_DH_MAX_MODULUS_BITS) {
+ DHerror(DH_R_MODULUS_TOO_LARGE);
+ return 0;
+ }
+
  ctx = BN_CTX_new();
  if (ctx == NULL)
  goto err;