Executive brief
The re2 library, a popular Node.js wrapper for the RE2 regular expression engine, is vulnerable to a denial-of-service attack. When processing certain patterns that can match empty strings, the library enters an infinite loop that rapidly consumes all available system memory and CPU. This can cause the entire application to freeze or crash, requiring a manual restart of the service.
Technical details
A vulnerability exists in the global match implementation within `lib/match.cc` of the node-re2 library. When `String.prototype.match` is called with a global RE2 object, the native C++ loop fails to advance the byte index if a zero-width (empty) match is found. This results in an infinite loop where the same empty match is repeatedly appended to a native vector, leading to 100% CPU utilization and rapid heap exhaustion. The issue is reachable if an attacker can influence either the regular expression pattern or the subject string. The vulnerability was fixed in version 1.25.2 by ensuring the cursor advances by at least one code point after an empty match.
Affected products
- uhop re2 (npm) <= 1.25.1
Timeline
- 2026-07-07: disclosed
- 2026-07-30: advisory: NVD publication
- 2026-07-31: patched: GitHub Advisory published and reviewed