Miggo Logo

GHSA-29xp-372q-xqph: node-tar has a race condition leading to uninitialized memory exposure

N/A

CVSS Score

Basic Information

CVE ID
-
EPSS Score
-
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 analysis of the provided patches pinpoints the vulnerability to the listFileSync function in src/list.ts. The vulnerability is a classic TOCTOU (time-of-check to time-of-use) race condition. The vulnerability description explicitly mentions that the regression happened in commit 5330eb04bc43014f216e5c271b40d5c00d45224d. This commit modified listFileSync to first check the file size (stat.size), then allocate an unsafe buffer of that size, and finally read the file. This creates a window for an attacker to truncate the file. If the file is made smaller during this window, fs.readSync reads fewer bytes than the buffer size, but the entire buffer, including the uninitialized parts, is passed to the parser. The fixing commit, 5e1a8e638600d3c3a2969b4de6a6ec44fa8d74c9, addresses this by checking the number of bytes actually read and slicing the buffer to that size before passing it to the parser, thus preventing the leakage of uninitialized memory. The vulnerable function is internal and called when a user invokes tar.list() or tar.t() with the { sync: true } option.

Vulnerable functions

listFileSync
src/list.ts
The function `listFileSync` is vulnerable to a time-of-check to time-of-use (TOCTOU) race condition. It retrieves the file size using `fstatSync` and allocates a buffer of that size using `Buffer.allocUnsafe`. It then reads the file content into this buffer. If the file is truncated to a smaller size between the `fstatSync` and `readSync` calls, `readSync` will read fewer bytes than the buffer's allocated size. The original code passed the entire buffer, including the uninitialized portion containing potentially sensitive process memory, to the tar parser via `p.end(buf)`. The vulnerability was introduced in commit `5330eb04bc43014f216e5c271b40d5c00d45224d` and fixed in `5e1a8e638600d3c3a2969b4de6a6ec44fa8d74c9`.

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** *n*lysis o* t** provi*** p*t***s pinpoints t** vuln*r**ility to t** `list*il*Syn*` *un*tion in `sr*/list.ts`. T** vuln*r**ility is * *l*ssi* TO*TOU (tim*-o*-****k to tim*-o*-us*) r*** *on*ition. T** vuln*r**ility **s*ription *xpli*itly m*ntions t