From ba6cbe1d218a6834adbbd0d3cb1427eac99c7a85 Mon Sep 17 00:00:00 2001 From: Kevin Jacobs Date: Tue, 1 Dec 2020 18:05:33 +0000 Subject: [PATCH] Bug 1674819 - Fix undefined shift when fuzzing r=bbeurdouche In fuzzer mode, session tickets are serialized without any encryption or integrity protection. This leads to a post-deserialize UBSAN error when shifting by a fuzzed (large) authType value. A real NSS server will not produce these values. Differential Revision: https://phabricator.services.mozilla.com/D97803 --HG-- extra : moz-landing-system : lando --- lib/ssl/ssl3exthandle.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/ssl/ssl3exthandle.c b/lib/ssl/ssl3exthandle.c index 2f1ab56fe0..fa1c66ee21 100644 --- a/lib/ssl/ssl3exthandle.c +++ b/lib/ssl/ssl3exthandle.c @@ -917,6 +917,13 @@ ssl_ParseSessionTicket(sslSocket *ss, const SECItem *decryptedTicket, PORT_SetError(SEC_ERROR_LIBRARY_FAILURE); return SECFailure; } + +#ifndef UNSAFE_FUZZER_MODE + PORT_Assert(temp < ssl_auth_size); +#else + temp %= (8 * sizeof(SSLAuthType)); +#endif + parsedTicket->authType = (SSLAuthType)temp; rv = ssl3_ExtConsumeHandshakeNumber(ss, &temp, 4, &buffer, &len); if (rv != SECSuccess) {