CVE-2025-64118: Tar Node-tar Has A Race Condition Vulnerability
MODERATECVE-2025-64118 is a MODERATE node-tar has a race condition vulnerability (CWE-362: Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')) affecting Tar libraries in the npm ecosystem. The issue involves node-tar has a race condition leading to uninitialized memory exposure. Remediation is available by upgrading affected packages to version 7.5.2.
CVE-2025-64118 at a Glance
How to Fix CVE-2025-64118
To remediate this vulnerability, upgrade all affected Tar dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install tar@7.5.2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls tar
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2025-64118, inspect your project dependencies using npm:
npm ls tar
Analyze the terminal output to locate any version of Tar in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 7.5.2), your application is affected.
Note: The npm ls tar command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-362: Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition'), where the product contains a concurrent code sequence that requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence operating concurrently. In Tar, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2025-64118 Affected Tar Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
tar
|
npm |
≥ 7.5.1
< 7.5.2
All 1 versions
7.5.1
|
7.5.2
|
References
Frequently Asked Questions
What is CVE-2025-64118?
Which Tar versions are affected?
What version fixes CVE-2025-64118?
Is tar affected?
What CWE is associated with CVE-2025-64118?
How can I check npm dependencies for CVE-2025-64118?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-29xp-372q-xqph",
"modified" : "2025-10-30T19:53:34Z",
"published" : "2025-10-30T17:13:17Z",
"aliases" : [ "CVE-2025-64118" ],
"summary" : "node-tar has a race condition leading to uninitialized memory exposure",
"details" : "### Summary\n\nUsing `.t` (aka `.list`) with `{ sync: true }` to read tar entry contents returns uninitialized memory contents if tar file was changed on disk to a smaller size while being read.\n\n### Details\n\nSee:\n* https://github.com/isaacs/node-tar/issues/445\n* https://github.com/isaacs/node-tar/pull/446\n* Regression happened in https://github.com/isaacs/node-tar/commit/5330eb04bc43014f216e5c271b40d5c00d45224d\n\n### PoC\n\nA:\n```js\nimport * as tar from 'tar'\nimport fs from 'node:fs'\n\nfs.writeFileSync('tar.test.tmp', Buffer.alloc(1*1024))\n\n// from readme\nconst filesAdded = []\ntar.c(\n {\n sync: true,\n file: 'tar.test.tmp.tar',\n onWriteEntry(entry) {\n // initially, it's uppercase and 0o644\n console.log('adding', entry.path, entry.stat.mode.toString(8))\n // make all the paths lowercase\n entry.path = entry.path.toLowerCase()\n // make the entry executable\n entry.stat.mode = 0o755\n // in the archive, it's lowercase and 0o755\n filesAdded.push([entry.path, entry.stat.mode.toString(8)])\n },\n },\n ['./tar.test.tmp'],\n)\n\nconst a = fs.readFileSync('tar.test.tmp.tar')\n\nfor (let i = 0; ; i++){\n if (i % 10000 === 0) console.log(i)\n fs.writeFileSync('tar.test.tmp.tar', a)\n fs.truncateSync('tar.test.tmp.tar', 600)\n}\n```\n\nB (vulnerable):\n```js\nimport * as tar from 'tar'\nimport * as fs from 'fs'\n\nwhile (true) {\n fs.readFileSync(import.meta.filename)\n tar.t({\n sync: true,\n file: 'tar.test.tmp.tar',\n onReadEntry: e => e.on('data', b => {\n const a = b.filter(x => x)\n if (a.length > 0) console.log(a.toString())\n })\n })\n}\n```\n\nRun A and B in parallel on Node.js 22 or >=25.1.0\n\nDumps `B` memory (wait for some time to observe text data)\n\n### Impact\n\nExposes process memory and could result in e.g. unintentionally (aka attacker-controlled) attempting to process sensitive data rather than tar entry contents. Uninitialized memory can contain unrelated file contents, environment variables, passwords, etc.\n\nTo execute, an attacker must reduce the file size to boundary between a tar header and body block, in the time between when the tar archive file size is read via `stat`, and the time when the tar archive parser reaches the entry that is truncated. If the file is truncated at a different boundary, then the uninitialized data will very likely not be a valid tar entry, causing the parser to treat the entry as a damaged archive (that is, throwing an error in `strict: true` mode, or by default, skipping the entry harmlessly).\n\nThis is conditional on using the `sync: true` option to the `tar.list`/`tar.t` method, and the `7.5.1` version specifically. Earlier versions were not affected.\n\nThis is also conditional to attacker being able to truncate (or induce a truncation/replacement) of a file on disk (e.g. in cache).\n\nIf the tar file is initially larger than the `opt.maxReadSize` (16kb by default), then uninitialized memory is not exposed to user code, and instead the program enters an infinite loop, causing a DoS rather than an information disclosure vulnerability.\n\nBy default, `tar.list` does _not_ process tar archive entry body content. So, this is further conditional on the user code doing something with the tar entry file contents in an `onReadEntry` method which would expose the file contents (for example, attempting to parse them in such a way that the uninitialized data could appear in an error message).\n\nOther methods in this library (`tar.extract`, etc.) are not affected by this vulnerability.",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:L/AC:H/AT:P/PR:L/UI:P/VC:H/VI:L/VA:L/SC:H/SI:H/SA:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "tar"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "7.5.1"
}, {
"fixed" : "7.5.2"
} ]
} ],
"versions" : [ "7.5.1" ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/isaacs/node-tar/security/advisories/GHSA-29xp-372q-xqph"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-64118"
}, {
"type" : "WEB",
"url" : "https://github.com/isaacs/node-tar/issues/445"
}, {
"type" : "WEB",
"url" : "https://github.com/isaacs/node-tar/pull/446"
}, {
"type" : "WEB",
"url" : "https://github.com/isaacs/node-tar/commit/5330eb04bc43014f216e5c271b40d5c00d45224d"
}, {
"type" : "WEB",
"url" : "https://github.com/isaacs/node-tar/commit/5e1a8e638600d3c3a2969b4de6a6ec44fa8d74c9"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/isaacs/node-tar"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-362" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2025-10-30T17:13:17Z",
"nvd_published_at" : "2025-10-30T18:15:33Z"
}
}