NSS Heap buffer overflow vulnerability in ASN1 certificate parsing
Originally disclosed on Mozilla
- Fixed in 19 days
- Paid in 19 days
- Disclosed after 19 days
Created attachment 8715333
repro.tgz
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.97 Safari/537.36
Steps to reproduce:
This vulnerability affects (at least) the latest NSS code available
from the mercurial.
By giving a malformed certificate (DER format) to the commonly used
SEC_ASN1DecodeItem() function, the parser crashes as shown in
the stacktrace attached to this post.
The joined archive file contains a simple C program and the invalid certificate
causing the issue.
Actual results:
The free of a pointer is crashing due to a previous memory corruption
caused by the memcpy() call in the sec_asn1d_parse_leaf() (secasn1d.c)
function.
After debugging, one can see the arena memory is effectively corrupted by
hundreds of bytes contained in the certificate.
----
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff65fd5b8 in _int_free (av=0x7ffff6929620 <main_arena>, p=<optimized out>, have_lock=0) at malloc.c:3996
3996 malloc.c: No such file or directory.
(gdb) bt
#0 0x00007ffff65fd5b8 in _int_free (av=0x7ffff6929620 <main_arena>, p=<optimized out>, have_lock=0) at malloc.c:3996
#1 0x00007ffff6d6ae52 in PR_Free (ptr=0xfa78e0) at ../../../../pr/src/malloc/prmem.c:458
#2 0x00007ffff6d7e261 in PR_DestroyLock (lock=0xfa78e0) at ../../../../pr/src/pthreads/ptsynch.c:167
#3 0x00007ffff73c5a11 in PORT_FreeArena_Util (arena=0xfa7880, zero=1) at secport.c:338
#4 0x00007ffff73c0869 in SEC_ASN1DecoderFinish_Util (cx=0xfa79b0) at secasn1d.c:2982
#5 0x00007ffff73c0afd in SEC_ASN1Decode_Util (poolp=0xfa6eb0, dest=0xfa7090, theTemplate=0x7ffff793c580 <CERT_SignedDataTemplate>,
buf=0x61b700 <in_cert> "0\202\002\001\060\201\001A0\r\006\tCCCCCCCCC\005", len=1023) at secasn1d.c:3093
#6 0x00007ffff73c0b50 in SEC_ASN1DecodeItem_Util (poolp=0xfa6eb0, dest=0xfa7090,
theTemplate=0x7ffff793c580 <CERT_SignedDataTemplate>, src=0x7fffffffe4a0) at secasn1d.c:3107
#7 0x000000000040864d in main () at certutil.c:52
---
Expected results:
The expected result is the stop of the invalid certificate parsing with an error value contained in the return of SEC_ASN1DecodeItem() function.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A critical-severity memory corruption bug in Libraries. Mozilla made it public on 22 February 2016 as CVE-2016-1950.
About Memory corruption
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.