Miggo Logo

CVE-2025-64118: node-tar has a race condition leading to uninitialized memory exposure

N/A

CVSS Score

Basic Information

EPSS Score
0.01335%
Published
10/30/2025
Updated
10/30/2025
KEV Status
No
Technology
TechnologyJavaScript

Technical Details

CVSS Vector
-
Package NameEcosystemVulnerable VersionsFirst Patched Version
tarnpm= 7.5.17.5.2

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability exists in the synchronous file listing functionality of the node-tar library, specifically within the listFileSync function located in src/list.ts. The vulnerability was introduced in commit 5330eb04bc43014f216e5c271b40d5c00d45224d, which changed the file reading logic. The new logic introduced a time-of-check-to-time-of-use (TOCTOU) race condition. It checks the file size, allocates an uninitialized buffer of that size (Buffer.allocUnsafe), and then reads the file. If the file is made smaller by an external process during this window, the read operation will not fill the entire buffer, causing the uninitialized (and potentially sensitive) memory to be passed to the tar parser. The fix, applied in commit 5e1a8e638600d3c3a2969b4de6a6ec44fa8d74c9, resolves this by using the return value of fs.readSync to determine how many bytes were actually read and then passing only that portion of the buffer to the parser. The user-facing API for this functionality is tar.list({ sync: true }) or tar.t({ sync: true }), which would call the vulnerable listFileSync function internally.

Vulnerable functions

listFileSync
src/list.ts
The vulnerability is a race condition within the `listFileSync` function. The function first retrieves the file's statistics (including its size) and then allocates a buffer of that size using `Buffer.allocUnsafe`, which does not initialize the memory. It then reads the file's contents into this buffer. If an attacker truncates the file on disk between the time the size is checked (`fstatSync`) and the time the file is read (`readSync`), `readSync` will only fill a portion of the buffer. The rest of the buffer will contain uninitialized memory, which may hold sensitive data from the process. This entire buffer, including the uninitialized portion, is then passed to the tar parser via `p.end(buf)`, leading to potential information disclosure.

WAF Protection Rules

WAF Rule

### Summ*ry Usin* `.t` (*k* `.list`) wit* `{ syn*: tru* }` to r*** t*r *ntry *ont*nts r*turns uniniti*liz** m*mory *ont*nts i* t*r *il* w*s ***n*** on *isk to * sm*ll*r siz* w*il* **in* r***. ### **t*ils S**: * *ttps://*it*u*.*om/is***s/no**-t*r/i

Reasoning

T** vuln*r**ility *xists in t** syn**ronous *il* listin* *un*tion*lity o* t** `no**-t*r` li*r*ry, sp**i*i**lly wit*in t** `list*il*Syn*` *un*tion lo**t** in `sr*/list.ts`. T** vuln*r**ility w*s intro*u*** in *ommit `**********************************