Skip to content

SSL core dump in v6.9.1 #9551

Description

@rdkgit
  • v6.9.1
  • Red Hat Enterprise Linux Server release 7.3
  • 3.10.0-514.el7.x86_64

Created simple https server and try to connect to it with various clients. node core dumps w/o any stack trace. GDB output below. Sorry if this is duplicate. I was not find anything related via searching. Code works fine on Fedora system running 4.6.1. Also, system it is core-dumping on is an EC2 instance thus virtual.

#0  0x00007f228053a610 in asn1_enc_restore () from /lib64/libcrypto.so.10
Missing separate debuginfos, use: debuginfo-install glibc-2.17-157.el7.x86_64 keyutils-libs-1.5.8-3.el7.x86_64 krb5-libs-1.14.1-26.el7.x86_64 libcom_err-1.42.9-9.el7.x86_64 libgcc-4.8.5-11.el7.x86_64 libicu-50.1.2-15.el7.x86_64 libselinux-2.5-6.el7.x86_64 libstdc++-4.8.5-11.el7.x86_64 openssl-libs-1.0.1e-60.el7.x86_64 pcre-8.32-15.el7_2.1.x86_64 zlib-1.2.7-17.el7.x86_64
(gdb) where
#0  0x00007f228053a610 in asn1_enc_restore () from /lib64/libcrypto.so.10
#1  0x00007f228053786b in ASN1_item_ex_i2d () from /lib64/libcrypto.so.10
#2  0x00007f2280537d11 in asn1_template_ex_i2d () from /lib64/libcrypto.so.10
#3  0x00007f2280537aeb in ASN1_item_ex_i2d () from /lib64/libcrypto.so.10
#4  0x00007f2280537bef in asn1_item_flags_i2d () from /lib64/libcrypto.so.10
#5  0x00007f22808478cd in ssl3_add_cert_to_buf () from /lib64/libssl.so.10
#6  0x00007f2280847fa3 in ssl3_output_cert_chain () from /lib64/libssl.so.10
#7  0x00007f228083b755 in ssl3_send_server_certificate ()
   from /lib64/libssl.so.10
#8  0x00007f228083cbcd in ssl3_accept () from /lib64/libssl.so.10
#9  0x00007f228084a478 in ssl23_accept () from /lib64/libssl.so.10
#10 0x00007f228084b612 in ssl23_read () from /lib64/libssl.so.10
#11 0x0000000000e668c5 in node::TLSWrap::ClearOut (this=this@entry=0x2b1fc80)
    at ../src/tls_wrap.cc:420
#12 0x0000000000e66b93 in Cycle (this=0x2b1fc80) at ../src/tls_wrap.h:103
#13 node::TLSWrap::DoRead (this=0x2b1fc80, nread=201, buf=<optimized out>, 
    pending=<optimized out>) at ../src/tls_wrap.cc:727
#14 0x0000000000e38c05 in OnRead (pending=UV_UNKNOWN_HANDLE, 
    buf=0x7ffe9b499820, nread=201, this=0x29d4fe8) at ../src/stream_base.h:180
#15 node::StreamWrap::OnReadCommon (handle=<optimized out>, nread=201, 
    buf=0x7ffe9b499820, pending=UV_UNKNOWN_HANDLE) at ../src/stream_wrap.cc:245
#16 0x00007f22812dc774 in uv__read (stream=stream@entry=0x29d5040)
    at src/unix/stream.c:1192
#17 0x00007f22812dcedc in uv__stream_io (loop=<optimized out>, w=0x29d50c8, 
    events=1) at src/unix/stream.c:1259
#18 0x00007f22812e1db8 in uv__io_poll (
    loop=loop@entry=0x7f22814ec900 <default_loop_struct>, timeout=119999)
    at src/unix/linux-core.c:380
#19 0x00007f22812d3998 in uv_run (loop=0x7f22814ec900 <default_loop_struct>, 
    mode=UV_RUN_ONCE) at src/unix/core.c:354
#20 0x0000000000df81d8 in node::Start (argc=2, argv=<optimized out>)
    at ../src/node.cc:4608
#21 0x00007f227db25b35 in __libc_start_main () from /lib64/libc.so.6
#22 0x00000000006f4299 in _start ()

Activity

  1. added
    tlsIssues and PRs related to the tls subsystem.
    c++Issues and PRs that require attention from people who are familiar with C++.
    on Nov 11, 2016
  2. mscdex commented on Nov 11, 2016

    @mscdex
    Contributor
  3. sam-github commented on Nov 11, 2016

    @sam-github
    Contributor

    @rdkgit can you provide a standalone example?

  4. indutny commented on Nov 11, 2016

    @indutny
    Member

    @rdkgit could you please provide a certificate chain that you used?

  5. rdkgit commented on Nov 11, 2016

    @rdkgit
    Author

    Here is an example I just now tested and it core dumps node when I connect to it using openssl s_client.
    Test with: /bin/openssl s_client -connect hostname:8443

    // test.js
    // test to see if node core dumps
    
    var fs = require('fs');
    var constants = require('constants');
    var http = require('http');
    var https = require('https');
    var httpPort = 8080;
    var httpsPort = 8443;
    
    var sslOptions = {
    
      key: fs.readFileSync('/tmp/exterus-key.pem'),
      cert: fs.readFileSync('/tmp/exterus-cert.pem'),
      // startssl sub.class1.server.ca.pem append >> cert pem
      secureProtocol: 'SSLv23_method',
      secureOptions: constants.SSL_OP_NO_SSLv3 | constants.SSL_OP_NO_SSLv2,
    };
    
    // set up proxy server and start listening!!
    http.createServer().listen(httpPort);
    console.log("Test listening on "+httpPort);
    
    https.createServer(sslOptions).listen(httpsPort);
    console.log("Test listening on "+httpsPort);
  6. rdkgit commented on Nov 11, 2016

    @rdkgit
    Author

    The cert I'm using is from startssl. Do you want me to send you the cert itself? Or, what kind of output would you like?

    Thanks,

    Bobby

  7. indutny commented on Nov 11, 2016

    @indutny
    Member

    @rdkgit may I ask you to put the exterus-cert.pem contents to https://gist.github.com/ ? It seems like it is crashing when it tries to encode the certificate chain, so having the full certificate chain may be a key to understanding the cause of the crash.

  8. rdkgit commented on Nov 11, 2016

    @rdkgit
    Author

    OK, uploaded. Are you able to reference it? Sorry if thats a dumb question. Havent used this feature of github before.
    rdkgit/exterus-cert.pem

  9. indutny commented on Nov 11, 2016

    @indutny
    Member
  10. indutny commented on Nov 11, 2016

    @indutny
    Member

    @rdkgit have you built node.js from source? Or have you downloaded the binary?

  11. rdkgit commented on Nov 11, 2016

    @rdkgit
    Author

    I'm using the pre-built platform packages for both Fedora, RHEL, and Centos. It core dumps on my ec2 instance but not my Fedora desktop running older version of node.

  12. indutny commented on Nov 11, 2016

    @indutny
    Member

    Oh wait! I just realized that you are using shared openssl library: /lib64/libssl.so.10. Do you know which version of OpenSSL that EC2 system has?

  13. rdkgit commented on Nov 11, 2016

    @rdkgit
    Author

    OpenSSL 1.0.1e-fips 11 Feb 2013

    On my Fedora system where no core dumps (but older nodejs version), I have 1.0.2h though.

  14. indutny commented on Nov 11, 2016

    @indutny
    Member

    @rdkgit what does node -pe process.versions.openssl say?

  15. 8 remaining items

  16. bnoordhuis commented on Nov 14, 2016

    @bnoordhuis
    Member

    cc @sgallagher - maybe you can answer @rdkgit's question?

    I'll close out the bug report since it's a downstream issue.

  17. rdkgit commented on Nov 14, 2016

    @rdkgit
    Author

    Thanks! Happy to provide any/all info to RH so we can fix this in the RHEL package.

    Bobby

  18. sgallagher commented on Nov 14, 2016

    @sgallagher
    Contributor

    @rdkgit Where did you get the package for RHEL? Was it one provided by Red Hat Software Collections or was it something you got from Fedora EPEL (Extra Packages for Enterprise Linux)?

    The former are supported by Red Hat, the latter are community-supported.

    If you got it from EPEL, then you should file a bug at https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora%20EPEL in the nodejs package.

    Please also include the full output of rpm -q openssl (or rpm -q openssl-fips if you're using that one). I should note that the EPEL version hasn't been tested with FIPS; we only expect it to work with the standard OpenSSL. It may be that Node.js is not FIPS-compatible.

  19. rdkgit commented on Nov 14, 2016

    @rdkgit
    Author

    Hey. I believe it was from RHEL EPEL repo as I did not find it in the regular/default REPOs that were set up with my ec2 instance.

    yum list nodejs
    Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
    Available Packages
    nodejs.x86_64 1:6.9.1-1.el7 epel

    I will file a bug via bugzilla.

    Thanks,

    Bobby

  20. sgallagher commented on Nov 14, 2016

    @sgallagher
    Contributor

    For what it's worth, I just tested this with:

    openssl-libs-1.0.1e-51.el7_2.7.x86_64
    nodejs-6.9.1-1.el7.x86_64
    

    I was unable to reproduce the issue in either FIPS or non-FIPS mode with that version of OpenSSL (the latest available on RHEL 7.2). Can you confirm that you're using the most recent version? Please provide the output of rpm -q openssl-libs, @rdkgit

  21. rdkgit commented on Nov 14, 2016

    @rdkgit
    Author

    Hi!

    The ec2 instance I'm running has RHEL 7.3 and the following:

    openssl-libs-1.0.1e-60.el7.x86_64
    npm-3.10.8-1.6.9.1.1.el7.x86_64
    nodejs-6.9.1-1.el7.x86_64

    When I use this config, it core dumps reliably with my test program. I will create a bugzilla entry.

    Thanks,

    Bobby

  22. sgallagher commented on Nov 14, 2016

    @sgallagher
    Contributor

    @rdkgit Please include detailed information about how you generated the certificate in question (as in, exact steps). My guess is that there's something atypical about the certificate or its CA chain that's triggering a behavior I can't reproduce with a certificate generated the way I normally do.

  23. rdkgit commented on Nov 14, 2016

    @rdkgit
    Author

    Hi!

    Here is the command I ran to generate the CSR. I then uploaded to startssl and got the cert.

    /bin/openssl req -out exterus.csr -new -newkey rsa:2048 -nodes -keyout exterus.key

    I generated the csr on my desktop fedora system using my local copy of openssl.

    %/bin/openssl version
    OpenSSL 1.0.2h-fips 3 May 2016

    Bobby

  24. rdkgit commented on Nov 15, 2016

    @rdkgit
    Author

    Update from bugzilla investigation. https://bugzilla.redhat.com/show_bug.cgi?id=1394948

    My startssl cert .pem file also had the intermediate startssl cert appended to the end of it. Apparently, this is known to crash some revs of nodejs due to either openssl bug or bug in node code. Not sure. Either way, when I remove the intermediate cert (its not needed anyway), the problem goes away.

    Thanks to all for the help resolving this.

    Bobby

  25. sam-github commented on Dec 7, 2016

    @sam-github
    Contributor

    @rdkgit I can't comment on the bugzilla, but if they have questions about node, they should ask them here, I'm familiar with the referenced code.

    Btw, I'm surprised you don't need the intermediate cert... how does the peer know your intermediate if you don't send it?

  26. rdkgit commented on Dec 7, 2016

    @rdkgit
    Author

    Hi!

    I'm using the startcom class-1 server ca cert and that seems to make everyone happy. The convention that I understood is that one could append that the CA server cert to one's server cert. That works in other versions of node but this particular version of node core dumps. When I moved the start intermediate cert into the CA SSL option, everything worked.

    Thanks,

    Bobby

  27. mastergberry commented on Dec 23, 2016

    @mastergberry

    I can confirm this same issue. Have a very similar setup to the original one described and removing the second certificate in the chain did solve the issue. Seems to be a low level C library bug as reported on the redhat website.

  28. yuriploc commented on Apr 4, 2017

    @yuriploc

    Just for documentation sake, I had this issue with an EC2 instance, openssl and Let's Encrypt aswell:

    segfault in libcrypto.so.1.0.1e

    npm-3.10.10-1.6.9.4.2.el7.x86_64
    nodejs-6.9.4-2.el7.x86_64
    openssl-1.0.1e-60.el7_3.1.x86_64

    Replaced fullchain.pem by cert.pem in httpsOptions and everything worked out great.

  29. rcjpisani commented on Jun 18, 2017

    @rcjpisani

    @yuriploc thanks for the suggestion, I replaced my fullchain.pem file with cert.pem and everything is working now (using CentOS 7 and Let's Encrypt certs).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++Issues and PRs that require attention from people who are familiar with C++.tlsIssues and PRs related to the tls subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions