Home > Programming, Security > The NULL certificate prefix bug

The NULL certificate prefix bug

October 3rd, 2009 Leave a comment Print Print Go to comments

Before some months, at the Black Hat 2009, Moxie Marlinspikes and Dan Kaminsky presented a vulnerability that exists at some implementations of SSL.

It’s concept is pretty simple, you request a certificate having as a CN (common name) www.paypal.com\x00.example.com. This can be easy, especially for some public key infrastructures operated by companies for their internal needs, where server certificates are issued automatically as long as the CN is a host under a specific domain. However, since many SSL implementations use strcmp for validating the remote host, they will only check if the host is equal to the part before \x00! So a malicious user can simply issue such a certificate and using spoofing he can start a man in the middle attack. Furthermore, it is possible to issue a certificate with a CN such as *.paypal.com\x00.example.com which will match all hosts under the paypal.com domain. Or even the CN *\x00.example.com which will match… everything! Jacob Appelbaum has created such a certificate and posted it to the Noisebridge-discuss mailing list.

Firefox 3.5.2 and 3.0.13 have fixed this vulnerability, however I checked with the Internet Explorer browser today and it still has this bug. The test was done at a friend’s pc so I don’t know exactly the patches he has applied or when he last run windows update. It is very interesting that it probably uses the strcpy function for copying the value of CN to the buffer where it keeps the certificate information so when you try to see them, you only see www.paypal.com!

You can use the following program to create your own certificate requests. You run it as follows:

At the output you will get the private key and the certificate request.

Categories: Programming, Security Tags:
  1. Ygor
    May 11th, 2011 at 21:28 | #1

    When i compile the code its fail. Error

    Do you help-me?

    gcc code.c -o code
    /tmp/ccFb8kKi.o: In function initssl':
    code.c:(.text+0xe): undefined reference to
    code.c:(.text+0x23): undefined reference to BIO_new_fp'
    /tmp/ccFb8kKi.o: In function
    code.c:(.text+0x35): undefined reference to CRYPTO_cleanup_all_ex_data'
    code.c:(.text+0x42): undefined reference to
    code.c:(.text+0x4f): undefined reference to BIO_free'
    /tmp/ccFb8kKi.o: In function
    code.c:(.text+0x134): undefined reference to EVP_PKEY_new'
    code.c:(.text+0x17e): undefined reference to
    code.c:(.text+0x20c): undefined reference to RSA_generate_key'
    code.c:(.text+0x245): undefined reference to
    code.c:(.text+0x255): undefined reference to ERR_error_string'
    code.c:(.text+0x2a0): undefined reference to
    code.c:(.text+0x2f2): undefined reference to X509_REQ_set_pubkey'
    code.c:(.text+0x348): undefined reference to
    code.c:(.text+0x38d): undefined reference to X509_NAME_add_entry_by_txt'
    code.c:(.text+0x3d2): undefined reference to
    code.c:(.text+0x43c): undefined reference to X509_NAME_add_entry_by_txt'
    code.c:(.text+0x441): undefined reference to
    code.c:(.text+0x45d): undefined reference to X509_REQ_sign'
    code.c:(.text+0x4fc): undefined reference to
    code.c:(.text+0x539): undefined reference to PEM_write_X509_REQ'
    code.c:(.text+0x547): undefined reference to
    code.c:(.text+0x555): undefined reference to `EVP_PKEY_free’
    collect2: ld returned 1 exit status

  2. Fotis
    May 19th, 2011 at 01:38 | #2

    You must link against libcrypto. Try gcc code.c -o code -lcrypto.

  3. March 20th, 2015 at 18:50 | #3

    I want to add this as a test on tls-o-matic. You have not been explicit about the license of this code. Can I use it and add it to the git repo of tls-o-matic?

    Thank you

    • Fotis
      April 9th, 2015 at 10:13 | #4

      It’s public domain, you can use it wherever you want.

  4. April 23rd, 2015 at 11:45 | #5

    Thank you!

  1. No trackbacks yet.

This site is using OpenAvatar based on


SEO Powered by Platinum SEO from Techblissonline
%d bloggers like this:

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.