| Title | Espruino 2v29 Stack Buffer Overflow |
|---|
| Description | A vulnerability was found in Espruino up to 2v29. It has been classified as critical. Affected is the function matchhere in the file src/jswrap_regexp.c (RegExp engine).
The manipulation with a regular expression containing 10 or more capture groups leads to a stack-based buffer overflow (out-of-bounds write).
# Root cause
At lines 216-218, info.groupStart[info.groups] and info.groupEnd[info.groups] are written before the bounds check if(info.groups < MAX_GROUPS). The arrays are declared as size_t[9] (indices 0..8, MAX_GROUPS=9). When a regex has exactly 10 capture groups, info.groups reaches 9, causing a 1-element OOB write of 8 bytes (size_t) on the stack.
# Impact
Stack memory corruption leading to crash (DoS). The written value is a string index, limiting attacker control, but it is a clear memory safety violation.
# PoC (minimal):
"x".match(/((((((((((/)
(10 opening parentheses — triggers groupStart[9] write past array bounds)
# Reproduction
Compile Espruino with ASAN (-fsanitize=address) and run the PoC. ASAN reports: "stack-buffer-overflow WRITE of size 8".
Verified on Espruino v2.29 (latest release as of 2026-10-29). The bug is present in all versions that include the jswrap_regexp.c regex engine.
Call path: "str".match(/.../) → jswrap_string_match (jswrap_string.c:295) → match (jswrap_regexp.c:98) → matchhere (recursive, line 216) |
|---|
| Source | ⚠️ https://github.com/espruino/Espruino/issues/2775 |
|---|
| User | Hyeontaek Lim (UID 102677) |
|---|
| Submission | 11/04/2026 19:37 (24 days ago) |
|---|
| Moderation | 11/28/2026 20:17 (24 days later) |
|---|
| Status | Accepted |
|---|
| VulDB entry | 445128 [Espruino up to 2v29 RegExp Engine src/jswrap_regexp.c matchhere out-of-bounds write] |
|---|
| Points | 20 |
|---|