DEV Community

StarkMan
StarkMan

Posted on

Espruino's Regular Expression Matcher Wrote Beyond Its Buffer

Espruino's Regular Expression Matcher Wrote Beyond Its Buffer

CVE-2026-138304 affects Espruino through 2v29. The defect is an out-of-bounds write in matchhere() in jswrap_regexp.c. A crafted regular expression or match operation can drive the engine past its allocated buffer, causing memory corruption or a device reset. Espruino provides a JavaScript environment for microcontrollers, so recovery may require a physical power cycle or reflashing.

The advisory rates the issue 6.9 under CVSS 4.0. That score does not answer the most important deployment question: who can supply the expression? A device that accepts scripts from local users has a different risk profile from one that receives expressions over a radio link, web console or untrusted application update.

Map the input path

Trace every way regular expressions reach the device. Include web and serial consoles, configuration files, MQTT or HTTP inputs and application code that builds patterns from sensor data. Check whether an attacker can trigger matching without authentication. Review watchdog behavior and whether a corrupted heap can persist after a crash.

The patch commit should be evaluated with build-specific tests. Test long alternations, empty groups, nested repetitions and malformed Unicode input. Run the tests with the same firmware options and memory constraints as production hardware. A failure in a desktop emulator may differ from a constrained device, especially when stack and heap sizes are reduced.

Contain and verify

Disable network-exposed script consoles and require authentication for any remaining management interface. Limit who can install code, preserve signed firmware baselines and reject unsigned update channels. If the device controls a physical process, define a safe state for a parser reset and test that the watchdog enters it.

Apply the upstream commit or a vendor firmware release that includes it. After updating, verify the version through an independent inventory source rather than a web banner alone. A page that says "Espruino" can identify a project or interface without proving the firmware revision or the presence of the vulnerable matcher.

References

Top comments (0)