| Title | Espruino 2v29 Integer Overflow |
|---|
| Description | A vulnerability was found in Espruino up to 2v29. It has been classified as problematic. Affected is the function jsfReadFile in the file src/jsflash.c (Storage subsystem), reachable via jswrap_storage_read in src/jswrap_storage.c.
The manipulation of the length argument of Storage.read(name, offset, length) with a large value (e.g. INT_MAX = 2147483647) leads to an integer overflow in the bounds check at line 1052, which results in an out-of-bounds read.
Root cause: The bounds check if (offset + length > fileLen) uses signed 32-bit addition. With offset=1 and length=INT_MAX (2147483647), the addition wraps to -2147483648 (negative), which is always less than fileLen, bypassing the check entirely. The length value is then used unmodified, allowing reads far past the file boundary.
Impact: Information disclosure — an attacker with JS execution context can read the entire flash storage contents (all files, names, and data) in a single API call. Combined with Espruino's documented erase behavior (header-only deletion, data retained), previously deleted file contents are also exposed.
PoC:
var s = require("Storage");
s.write("target", "AA");
var leaked = s.read("target", 1, 2147483647);
// → returns contents of all other files in flash storage
Call path: Storage.read(name, offset, length) → jswrap_storage_read (jswrap_storage.c:131, no validation) → jsfReadFile (jsflash.c:1052, integer overflow)
Fix suggestion: Replace the addition-based check with subtraction: if (length > fileLen - offset) length = fileLen - offset; (safe because offset ≤ fileLen is guaranteed at this point). |
|---|
| Source | ⚠️ https://github.com/espruino/Espruino/issues/2776 |
|---|
| User | Hyeontaek Lim (UID 102677) |
|---|
| Submission | 11/04/2026 19:45 (24 days ago) |
|---|
| Moderation | 11/28/2026 20:18 (24 days later) |
|---|
| Status | Accepted |
|---|
| VulDB entry | 445129 [Espruino up to 2v29 Storage src/jsflash.c jsfReadFile length integer overflow] |
|---|
| Points | 20 |
|---|