VulnWatch by ve1ve2
medium 4.3 EPSS 0.71%

GHSA-76gg-c692-v2mw / CVE-2023-3247: Missing error check and insufficient random bytes in HTTP Digest authentication for SOAP

Source:
PHP releases (GitHub php/php-src tags)
Published:
Fetched:
Updated:
Affects:
php php-src

https://github.com/php/php-src/security/advisories/GHSA-76gg-c692-v2mw ↗

repo-advisoryCWE-252CWE-334securityrepo:php/php-srcstack

Missing error check and insufficient random bytes in HTTP Digest authentication for SOAP **This report was co-authored by @timwolla** ### Summary The random byte generation function used in the SOAP HTTP Digest authentication code is not checked for failure. This can result in a stack information leak. Furthermore, there's an insufficient number of random bytes used. ### Details Context: https://github.com/php/php-src/blob/af809ef028e1e3ed59284e2506cab0f275b55d8e/ext/soap/php_http.c#L664-L671 If `php_random_bytes_throw` fails, the nonce will be uninitialized, but still sent to the server. The client nonce is intended to protect against a malicious server. See section 5.10 and 5.12 of [RFC 7616](https://www.rfc-editor.org/rfc/rfc7616), and bullet point 2 below. Tim pointed out that even though it's the MD5 of the nonce that gets sent, enumerating 31 bits is trivial. So we have still a stack information leak of 31 bits. Furthermore, Tim found the following issues: * The small size of cnonce might cause the server to erroneously reject a request due to a repeated (cnonce, nc) pair. As per the birthday problem 31 bits of randomness will return a duplication with 50% chance after less than 55000 requests and nc always starts counting at 1. * The cnonce is intended to protect the client and password against a malicious server that returns a constant server nonce where the server precomputed a rainbow table between passwords and correct client response. As storage is fairly cheap, a server could precompute the client responses for (a subset of) client nonces and still have a chance of reversing the client response with the same probability as the cnonce duplication. Precomputing the rainbow table for all 2^31 cnonces increases the rainbow table size by factor 2 billion, which is infeasible. But precomputing it for 2^14 cnonces only increases the table size by factor 16k and the server would still have a 10% chance of successfully reversing a password with a single client request. ### PoC We do not have a proof-of-concept. ### Impact The weak randomness affects applications that use SOAP with HTTP Digest authentication against a possibly malicious server over HTTP. The stack information leak applies to both HTTP and HTTPS, but is only a few bytes. ### Proposed patch This patch fixes the issues by increasing the nonce size, and checking the return value of php_random_bytes_throw(). In the process we also get rid of the MD5 hashing of the nonce. ```diff From f26fcd3a152a5c6b2d140cb35a5040671696f6e1 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sun, 16 Apr 2023 15:05:03 +0200 Subject: [PATCH] Fix missing randomness check and insufficient random bytes for SOAP HTTP Digest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If php_random_bytes_throw fails, the nonce will be uninitialized, but still sent to the server. The client nonce is intended to protect Patched: 8.0.29, 8.1.20, 8.2.7

Linked vulnerabilities (2)

CVE-2023-3247 medium 4.3 EPSS 0.71% (p54) NVDCVE.orgGHSA
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N

php8.2 - security update

CWE: CWE-252, CWE-334Aliases: GHSA-76gg-c692-v2mw

Missing error check and insufficient random bytes in HTTP Digest authentication for SOAP

CWE: CWE-252, CWE-334Aliases: CVE-2023-3247