CVE-2024-12905: Tar fs Path Traversal Vulnerability
HIGHCVE-2024-12905 is a HIGH (CVSS 7.5) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Tar fs libraries in the npm ecosystem. The issue involves tar-fs vulnerable to link following and path traversal via extracting a crafted tar file. Remediation is available by upgrading affected packages to version 1.16.4, 2.1.2, 3.0.7.
CVE-2024-12905 at a Glance
Security Impact
CVSS: 7.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N).
How to Fix CVE-2024-12905
To remediate this vulnerability, upgrade all affected Tar fs 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-fs@1.16.4
npm install tar-fs@2.1.2
npm install tar-fs@3.0.7
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls tar-fs
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2024-12905, inspect your project dependencies using npm:
npm ls tar-fs
Analyze the terminal output to locate any version of Tar fs in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.16.4), your application is affected.
Note: The npm ls tar-fs 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-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Tar fs, 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-2024-12905 Affected Tar fs Versions
3 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
tar-fs
|
npm |
< 1.16.4
|
1.16.4
|
|
tar-fs
|
npm |
≥ 2.0.0
< 2.1.2
|
2.1.2
|
|
tar-fs
|
npm |
≥ 3.0.0
< 3.0.7
|
3.0.7
|
References
Frequently Asked Questions
What is CVE-2024-12905?
Which Tar fs versions are affected?
What version fixes CVE-2024-12905?
Is tar-fs affected?
What is the CVSS score of CVE-2024-12905?
What CWE is associated with CVE-2024-12905?
How can I check npm dependencies for CVE-2024-12905?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-pq67-2wwv-3xjx",
"modified" : "2025-11-03T22:54:57Z",
"published" : "2025-03-27T18:31:28Z",
"aliases" : [ "CVE-2024-12905" ],
"summary" : "tar-fs Vulnerable to Link Following and Path Traversal via Extracting a Crafted tar File",
"details" : "An Improper Link Resolution Before File Access (\"Link Following\") and Improper Limitation of a Pathname to a Restricted Directory (\"Path Traversal\"). This vulnerability occurs when extracting a maliciously crafted tar file, which can result in unauthorized file writes or overwrites outside the intended extraction directory. The issue is associated with index.js in the tar-fs package.\n\nThis issue affects tar-fs: from 0.0.0 before 1.16.4, from 2.0.0 before 2.1.2, from 3.0.0 before 3.0.7.\n\n### PoC\n```javascript\n// Create a writable stream to extract the tar content\nconst extractStream = tarfs.extract('/', {\n // We can ignore the file type checks to allow the extraction of the malicious file\n ignore: (name) => false,\n});\n\n// Create a tar stream\nconst tarStream = tarfs.pack().on('error', (err) => {\n throw err;\n});\n\n// Append the malicious entry to the tar stream\ntarStream.entry({ name: '/flag.txt', mode: 0o644 }, Buffer.from('This is a flag!'));\n\n// Finalize the tar stream\ntarStream.finalize();\n\n// Pipe the tar stream into the extract stream\ntarStream.pipe(extractStream);\n```",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "tar-fs"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.16.4"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "tar-fs"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.0.0"
}, {
"fixed" : "2.1.2"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "tar-fs"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "3.0.0"
}, {
"fixed" : "3.0.7"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-12905"
}, {
"type" : "WEB",
"url" : "https://github.com/mafintosh/tar-fs/commit/a1dd7e7c7f4b4a8bd2ab60f513baca573b44e2ed"
}, {
"type" : "WEB",
"url" : "https://arxiv.org/abs/2506.04962"
}, {
"type" : "WEB",
"url" : "https://arxiv.org/pdf/2506.04962"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/mafintosh/tar-fs"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2025/06/msg00012.html"
}, {
"type" : "WEB",
"url" : "https://www.seal.security/blog/a-link-to-the-past-uncovering-a-new-vulnerability-in-tar-fs"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-22" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2025-03-28T22:11:42Z",
"nvd_published_at" : "2025-03-27T17:15:53Z"
}
}