Closed Bug 1786018 Opened 4 years ago Closed 2 years ago

UndefinedBehaviorSanitizer: security/nss/lib/ssl/ssl3con.c:13150:47: runtime error: applying zero offset to null pointer with HTTP/2 Proxy

Categories

(NSS :: Libraries, defect, P2)

x86_64
Linux

Tracking

(firefox105 wontfix)

RESOLVED FIXED
Tracking Status
firefox105 --- wontfix

People

(Reporter: decoder, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: crash, sec-other, testcase)

Attachments

(5 files)

The attached testcase crashes on mozilla-central revision 20220819-58a08b3c7632 (build with (metadatabuildFlags not available)).

For detailed crash information, see attachment.

To reproduce the issue, perform the following steps:

  1. Download the attached testcase, save as "test.bin".
    2a. Build with --enable-fuzzing (requires Clang and ASan, also build gtests using ./mach gtest dontruntests).
    2b. Alternatively you can download builds from TC using python -mfuzzfetch -a --fuzzing --target firefox gtest (see https://github.com/MozillaSecurity/fuzzfetch).
  2. Run FUZZER=NetworkHttp2ProxyHttp2 objdir/dist/bin/firefox test.bin

I'm marking this one s-s because I don't know what exactly is happening here and the failure is deep inside critical TLS code. I can't easily test what would happen without UBSan but having null pointers with null offsets there feels wrong in any case. Note that if this is UB, the compiler can reorder/optimize things and potentially worse things can happen.

I also minimized the attached testcase on the byte level to make it easier to figure out what's going on.

Attached file Testcase

According to this comment, it seems this undefined behavior is fine.

More details:

  • The crash is at this line where cText->buf->buf is NULL and ivLen is 0.
  • cText->buf->buf is NULL because we got an empty record. This line shows gs->inbuf.len is 0.

I think this is more like an NSS issue, since what necko did is only calling SSL_ForceHandshake.

Dennis, could you take a look?
Thanks.

Assignee: nobody → nobody
Group: network-core-security → crypto-core-security
Component: Networking: HTTP → Libraries
Flags: needinfo?(djackson)
Product: Core → NSS
Version: Trunk → other

Doesn't look exploitable, but also we probably didn't want a null pointer there and will crash soon anyway? Or if there's a null check saving us maybe that could be moved earlier.

Keywords: sec-other
Assignee: nobody → djackson
Flags: needinfo?(djackson)
Attachment #9294380 - Attachment description: Bug 1786018 - Skip zero-length records in ssl3_UnprotectRecord() to avoid undefined behavior. r?djackson → Bug 1786018 - Skip zero-length records in ssl3_UnprotectRecord() to avoid undefined behavior. Enabled ubsan 'pointer-overflow' check for test coverage. r?djackson
Depends on: 1790763
Assignee: djackson → lschwarz
Attachment #9294380 - Attachment description: Bug 1786018 - Skip zero-length records in ssl3_UnprotectRecord() to avoid undefined behavior. Enabled ubsan 'pointer-overflow' check for test coverage. r?djackson → Bug 1786018 - Skip zero-length unprotected records in ssl3_HandleRecord() to avoid undefined behavior. Enabled ubsan 'pointer-overflow' check for test coverage. r?djackson

The bug assignee is inactive on Bugzilla, and this bug has severity 'S2'.
:beurdouche, could you have a look please?

For more information, please visit auto_nag documentation.

Assignee: lschwarz → nobody
Flags: needinfo?(bbeurdouche)

This ensures we properly test the different DTLS / TLS versions and makes the
expected behaviour explicit.

This is based on the patch developed by Leander in D157183, but is a
little more explicit.

Co-Authored-By: Leander Schwarz

Depends on D176156

@Dennis, when you have some time, can you land this please ? : ) Thanks !

Flags: needinfo?(bbeurdouche) → needinfo?(djackson)
Priority: -- → P2
Status: NEW → RESOLVED
Closed: 2 years ago
Flags: needinfo?(djackson)
Resolution: --- → FIXED
Group: crypto-core-security → core-security-release
Target Milestone: --- → 3.90
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: