Closed Bug 1879513 Opened 2 years ago Closed 2 years ago

HandleCertificateDecode causes Null-dereference

Categories

(NSS :: Libraries, defect, P1)

Tracking

(firefox-esr115 unaffected, firefox122 unaffected, firefox123 unaffected, firefox124 unaffected)

RESOLVED FIXED
Tracking Status
firefox-esr115 --- unaffected
firefox122 --- unaffected
firefox123 --- unaffected
firefox124 --- unaffected

People

(Reporter: anna.weine, Assigned: anna.weine)

References

Details

(Keywords: oss-fuzz, sec-low)

Attachments

(1 file)

https://oss-fuzz.com/testcase-detail/5816648133050368:

AddressSanitizer:DEADLYSIGNAL
=================================================================
==185569==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000058 (pc 0x0000006ec36d bp 0x7ffd3c5b9750 sp 0x7ffd3c5b9700 T0)
==185569==The signal is caused by a WRITE memory access.
==185569==Hint: address points to the zero page.
SCARINESS: 10 (null-deref)
#0 0x6ec36d in PK11_DigestOp nss/lib/pk11wrap/pk11cxt.c:1506:19
#1 0x5f34d0 in ssl3_UpdatePostHandshakeHashes nss/lib/ssl/ssl3con.c:4070:10
#2 0x6118f2 in ssl_HashHandshakeMessageInt nss/lib/ssl/ssl3con.c:12535:10
#3 0x6118f2 in ssl_HashPostHandshakeMessage nss/lib/ssl/ssl3con.c:12595:12
#4 0x586958 in tls13_HandleCertificateDecode nss/lib/ssl/tls13con.c:3866:14
#5 0x586958 in tls13_HandlePostHelloHandshakeMessage nss/lib/ssl/tls13con.c:1211:20
#6 0x612555 in ssl3_HandleHandshakeMessage nss/lib/ssl/ssl3con.c:12684:22

Assignee: nobody → nkulatova
Blocks: 1548723

As John mentioned (and I checked) the bug is happening when the code is trying to hash a buffer with shaPostHandshake being null.

The quick working fix could be this, but I am not happy about the fix, because as for me it does not solve the problem, but removes the consequences.

if (ss->ssl3.hs.shaPostHandshake == NULL)
    {
        ss->ssl3.hs.shaPostHandshake = PK11_CloneContext(ss->ssl3.hs.sha);
        if (ss->ssl3.hs.shaPostHandshake == NULL) {
            ssl_MapLowLevelError(SSL_ERROR_SHA_DIGEST_FAILURE);
            return SECFailure;
        }
    }

The allocation of shaPostHandshake is happening either in tls13_SendCertificateRequest (https://searchfox.org/mozilla-central/source/security/nss/lib/ssl/tls13con.c#2677) or tls13_HandleCertificateRequest (https://searchfox.org/mozilla-central/source/security/nss/lib/ssl/tls13con.c#2989).

I don't immediately see how the certificate compression function causes this problem, as this function is somehow equivalent to HandleCertificate function. If the certificate is encoded we call tls13_HandleCertificateDecode, otherwise - tls13_HandleCertificate()

Attachment #9379390 - Attachment description: WIP: Bug 1879513 - Certificate Compression: enabling the check that the compression was advertised → Bug 1879513 - Certificate Compression: enabling the check that the compression was advertised
Attachment #9379390 - Attachment description: Bug 1879513 - Certificate Compression: enabling the check that the compression was advertised → WIP: Bug 1879513 - Certificate Compression: enabling the check that the compression was advertised
Attachment #9379390 - Attachment description: WIP: Bug 1879513 - Certificate Compression: enabling the check that the compression was advertised → Bug 1879513 - Certificate Compression: enabling the check that the compression was advertised
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Keywords: oss-fuzz

Does this affect NSS 3.90 also (used in ESR115)?

Group: crypto-core-security → core-security-release
Flags: needinfo?(nkulatova)
Target Milestone: --- → 3.98

This was a short lived regression on NSS trunk. No NSS or Firefox releases were affected.

Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: