CVE-2025-58050
pcre2: PCRE2: heap-buffer-overflow read in match_ref due to missing boundary restoration in SCS
Severity
ModerateRed Hat Product Security
CVSS 3.1
Review impact separately from score.
Published · August 28, 2025
Updated · August 31, 2026
Description
In pcre2 library, there is a vulnerability in the code that causes a heap-buffer-overflow. This arises from using the special verb - Scan-SubString together with (*ACCEPT) which causes an out-of-bounds read. This could be exploited by an attacker through crafting a pattern using this combination to trigger the heap-buffer overflow.
Statement
The bug is in src/pcre2_match.c. When (*scs:...) temporarily restricts the match boundaries to a captured substring, the engine restores the current subject pointer (Feptr) correctly on an immediate (*ACCEPT), but it fails to restore mb->end_subject and mb->true_end_subject. If execution later calls match_ref (for example for a backreference like \2), the bounds check can underflow because mb->end_subject - eptr becomes negative and is cast to an unsigned size. That makes the length check pass incorrectly and memcmp reads past the end of the allocated buffer, causing a heap-buffer-overflow read.
CVSS score applicability
The CVSS score(s) listed for this vulnerability do not reflect the associated product's status, and are included for informational purposes to better understand the severity of this vulnerability.
Mitigation
No mitigation is specified in collected source.
CVSS / CWE
CVSS 3.1 · 6.5CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:L
CWE-125 · Out-of-bounds Read