Skip to content
Memory corruption Disclosed report Advanced CVE-2020-12403

CHACHA20-POLY1305 decryption with undersized tag leads to out-of-bounds read

The ChaCha20-Poly1305 decryption routine in NSS reads one byte beyond the end of a buffer when given an authentication tag shorter than expected. An attacker could potentially trigger an out-of-bounds read, though the report does not demonstrate a practical exploit.

Guido Vranken Follow

Originally disclosed on Mozilla

  • Fixed in 2 months
  • Paid in 3 months
  • Disclosed after 2 months
Text
Created attachment 9147106
chacha20_oob_read.cpp

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:76.0) Gecko/20100101 Firefox/76.0

Steps to reproduce:

Recent NSS checkout compiled on 64 bit Linux using:

./build.sh --clang --enable-fips --static --asan --disable-tests --fuzz=oss

Then compile and run the attached C++ file.


Actual results:

out-of-bounds read

=================================================================
==20341==ERROR: AddressSanitizer: global-buffer-overflow on address 0x00000085a697 at pc 0x00000063ca9c bp 0x7ffdb7d48510 sp 0x7ffdb7d48508
READ of size 1 at 0x00000085a697 thread T0
    #0 0x63ca9b in Hacl_Chacha20Poly1305_256_aead_decrypt /mnt/2tb/cf-nss/sandbox/nss/out/Debug/../../lib/freebl/verified/Hacl_Chacha20Poly1305_256.c:1167:64
    #1 0x58fedf in ChaCha20Poly1305_Open /mnt/2tb/cf-nss/sandbox/nss/out/Debug/../../lib/freebl/chacha20poly1305.c:267:19
    #2 0x7ef031 in sftk_ChaCha20Poly1305_Decrypt /mnt/2tb/cf-nss/sandbox/nss/out/Debug/../../lib/softoken/pkcs11c.c:705:12
    #3 0x7f1383 in NSC_Decrypt /mnt/2tb/cf-nss/sandbox/nss/out/Debug/../../lib/softoken/pkcs11c.c:1813:10
    #4 0x6eadfd in PK11_Decrypt /mnt/2tb/cf-nss/sandbox/nss/out/Debug/../../lib/pk11wrap/pk11obj.c:933:11
    #5 0x5192a8 in main /mnt/2tb/cf-nss/cryptofuzz/modules/nss/poc.cpp:46:5
    #6 0x7f503c413b96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310
    #7 0x41c6e9 in _start (/mnt/2tb/cf-nss/cryptofuzz/modules/nss/poc+0x41c6e9)

I have not yet checked if Firefox via TLS or WebCrypt might be affected.


Expected results:

no memory violations

The original report as published on Mozilla's Bugzilla, by Guido Vranken. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the decryption function does not properly validate the length of the authentication tag before reading it, leading to an out-of-bounds read.

Impact

An attacker could cause an out-of-bounds read, potentially leading to a crash or limited information disclosure; the report does not confirm whether Firefox via TLS or WebCrypto is affected.

What the attacker needed

Ability to supply a short authentication tag

How it was found

  1. Build NSS with AddressSanitizer enabled.
  2. Compile and run the attached C++ proof-of-concept file.
  3. Observe the AddressSanitizer global-buffer-overflow report.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When decrypting data, the code checks a short 'tag' (a kind of checksum) to verify integrity. If the tag is too short, the code accidentally reads one byte past the end of the buffer, which is a memory safety bug. This could crash the program or leak a tiny amount of memory, but the report does not show how to exploit it.

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.

More by Guido Vranken

View all

1 more disclosed report, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.