CRYPTO_set_mem_functions() is broken

Bug #1594748 reported by Timo Sirainen
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenSSL
Invalid
Unknown
openssl (Ubuntu)
Fix Released
Undecided
Joy Latten
Xenial
Fix Released
Undecided
Unassigned

Bug Description

Description: Ubuntu 16.04 LTS
Release: 16.04

openssl:
  Installed: 1.0.2g-1ubuntu4.1
  Candidate: 1.0.2g-1ubuntu4.1
  Version table:
 *** 1.0.2g-1ubuntu4.1 500
        500 http://fi.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages
        100 /var/lib/dpkg/status
     1.0.2g-1ubuntu4 500
        500 http://fi.archive.ubuntu.com/ubuntu xenial/main amd64 Packages

CRYPTO_set_mem_functions() always returns 0 because library initialization already calls CRYPTO_malloc() and disables it:

#0 CRYPTO_malloc (num=num@entry=1168, file=file@entry=0x7ffff70ae02c "fips_drbg_lib.c",
    line=line@entry=106) at mem.c:329
#1 0x00007ffff70596df in FIPS_drbg_new (type=type@entry=0, flags=flags@entry=0)
    at fips_drbg_lib.c:106
#2 0x00007ffff705aeb9 in FIPS_drbg_health_check (
    dctx=dctx@entry=0x7ffff731c960 <ossl_dctx>) at fips_drbg_selftest.c:760
#3 0x00007ffff70595f0 in FIPS_drbg_init (dctx=dctx@entry=0x7ffff731c960 <ossl_dctx>,
    type=<optimized out>, flags=<optimized out>) at fips_drbg_lib.c:94
#4 0x00007ffff6fe38f3 in RAND_init_fips () at rand_lib.c:287
#5 0x00007ffff6f26f7a in OPENSSL_init_library () at o_init.c:119
#6 0x00007ffff7de74ea in call_init (l=<optimized out>, argc=argc@entry=1,
    argv=argv@entry=0x7fffffffe5e8, env=env@entry=0x7fffffffe5f8) at dl-init.c:72
#7 0x00007ffff7de75fb in call_init (env=0x7fffffffe5f8, argv=0x7fffffffe5e8, argc=1,
    l=<optimized out>) at dl-init.c:30
#8 _dl_init (main_map=main_map@entry=0x640380, argc=1, argv=0x7fffffffe5e8,
    env=0x7fffffffe5f8) at dl-init.c:120

This doesn't happen in upstream OpenSSL or in Debian's OpenSSL. Looking at the patches, this is caused by FIPS_drbg_init() in openssl-1.0.2g-fips.patch:

+ if (!(dctx->xflags & DRBG_FLAG_TEST)) {
+ if (!FIPS_drbg_health_check(dctx)) {
+ FIPSerr(FIPS_F_FIPS_DRBG_INIT, FIPS_R_SELFTEST_FAILURE);
+ return 0;
+ }
+ }

I don't want any FIPS mode enabled though, so does it really even need to call RAND_init_fips() then?

Changed in openssl (Ubuntu):
assignee: nobody → Joy Latten (j-latten)
Revision history for this message
Joy Latten (j-latten) wrote :

Looking into this...

Revision history for this message
Joy Latten (j-latten) wrote :

Ok, this is also "broken" or an issue in upstream openssl 1.0.2 when OPENSSL_FIPS is defined.
See, https://rt.openssl.org/Ticket/Display.html?id=4559#txn-68189 or
http://rt.openssl.org/Ticket/Display.html?id=4559

Revision history for this message
Joy Latten (j-latten) wrote :

Waiting to see upstream commit/fix for this since this is an issue in the upstream openssl code when OPENSSL_FIPS is defined.

Revision history for this message
Joy Latten (j-latten) wrote :

Just as a note, the fips mode is not enabled in 1.0.2g-1ubuntu4.1. But OPENSSL_FIPS is defined and its codes compiled in. Thus in OPENSSL_init_library(), the RAND_init_fips() is included in.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in openssl (Ubuntu):
status: New → Confirmed
Dave Chiluk (chiluk)
tags: added: sts
Revision history for this message
Dave Chiluk (chiluk) wrote :

@Joy

It looks like the upstream bug has been rejected. Do you know what the resolution for this issue was? Can you work with upstream to figure out what's going on?

Thanks,

Revision history for this message
Joy Latten (j-latten) wrote :

Investigating.

Revision history for this message
Dave Chiluk (chiluk) wrote :

This needs to be resolved in Xenial as well.

Revision history for this message
Dave Chiluk (chiluk) wrote :

For those affected by this in xenial, I have created a PPA with fips removed from the openssl binaries.

See it here.
https://launchpad.net/~chiluk/+archive/ubuntu/openssl+nofips

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package openssl - 1.0.2g-1ubuntu8

---------------
openssl (1.0.2g-1ubuntu8) yakkety; urgency=medium

  * Remove unused FIPS patches for now. (LP: #1594748, LP: #1593953,
    LP: #1591797, LP: #1588524)

 -- Marc Deslauriers <email address hidden> Mon, 15 Aug 2016 14:20:42 -0400

Changed in openssl (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Chris J Arges (arges) wrote : Please test proposed package

Hello Timo, or anyone else affected,

Accepted openssl into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/openssl/1.0.2g-1ubuntu4.3 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in openssl (Ubuntu Xenial):
status: New → Fix Committed
tags: added: verification-needed
Revision history for this message
Joy Latten (j-latten) wrote :

I tested version 1.0.2g-1ubuntu4.3 with the death.c program from the upstream openssl bug ticket 4559 and confirmed this problem is now resolved.

tags: added: verification-done
removed: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package openssl - 1.0.2g-1ubuntu4.4

---------------
openssl (1.0.2g-1ubuntu4.4) xenial-security; urgency=medium

  * SECURITY UPDATE: Pointer arithmetic undefined behaviour
    - debian/patches/CVE-2016-2177.patch: avoid undefined pointer
      arithmetic in ssl/s3_srvr.c, ssl/ssl_sess.c, ssl/t1_lib.c.
    - CVE-2016-2177
  * SECURITY UPDATE: Constant time flag not preserved in DSA signing
    - debian/patches/CVE-2016-2178-*.patch: preserve BN_FLG_CONSTTIME in
      crypto/dsa/dsa_ossl.c.
    - CVE-2016-2178
  * SECURITY UPDATE: DTLS buffered message DoS
    - debian/patches/CVE-2016-2179.patch: fix queue handling in
      ssl/d1_both.c, ssl/d1_clnt.c, ssl/d1_lib.c, ssl/d1_srvr.c,
      ssl/ssl_locl.h.
    - CVE-2016-2179
  * SECURITY UPDATE: OOB read in TS_OBJ_print_bio()
    - debian/patches/CVE-2016-2180.patch: fix text handling in
      crypto/ts/ts_lib.c.
    - CVE-2016-2180
  * SECURITY UPDATE: DTLS replay protection DoS
    - debian/patches/CVE-2016-2181-1.patch: properly handle unprocessed
      records in ssl/d1_pkt.c.
    - debian/patches/CVE-2016-2181-2.patch: protect against replay attacks
      in ssl/d1_pkt.c, ssl/ssl.h, ssl/ssl_err.c.
    - debian/patches/CVE-2016-2181-3.patch: update error code in ssl/ssl.h.
    - CVE-2016-2181
  * SECURITY UPDATE: OOB write in BN_bn2dec()
    - debian/patches/CVE-2016-2182.patch: don't overflow buffer in
      crypto/bn/bn_print.c.
    - CVE-2016-2182
  * SECURITY UPDATE: SWEET32 Mitigation
    - debian/patches/CVE-2016-2183.patch: move DES ciphersuites from HIGH
      to MEDIUM in ssl/s3_lib.c.
    - CVE-2016-2183
  * SECURITY UPDATE: Malformed SHA512 ticket DoS
    - debian/patches/CVE-2016-6302.patch: sanity check ticket length in
      ssl/t1_lib.c.
    - CVE-2016-6302
  * SECURITY UPDATE: OOB write in MDC2_Update()
    - debian/patches/CVE-2016-6303.patch: avoid overflow in
      crypto/mdc2/mdc2dgst.c.
    - CVE-2016-6303
  * SECURITY UPDATE: OCSP Status Request extension unbounded memory growth
    - debian/patches/CVE-2016-6304.patch: remove OCSP_RESPIDs from previous
      handshake in ssl/t1_lib.c.
    - CVE-2016-6304
  * SECURITY UPDATE: Certificate message OOB reads
    - debian/patches/CVE-2016-6306-1.patch: check lengths in ssl/s3_clnt.c,
      ssl/s3_srvr.c.
    - debian/patches/CVE-2016-6306-2.patch: make message buffer slightly
      larger in ssl/d1_both.c, ssl/s3_both.c.
    - CVE-2016-6306

 -- Marc Deslauriers <email address hidden> Thu, 22 Sep 2016 08:22:22 -0400

Changed in openssl (Ubuntu Xenial):
status: Fix Committed → Fix Released
Changed in openssl:
status: Unknown → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.