HighGHSA-3jfq-g458-7qm9CVE-2021-32804

Arbitrary File Creation/Overwrite due to insufficient absolute path sanitization

Published 3 Aug 2021 · Updated 8 Jul 2026

Is your project on an affected tar?

Private repo? Upload its lockfile instead, or connect GitHub to check every repo.

Look after several JavaScript apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie

Affected packages

tarnpm
Affected
<3.2.2
Fixed in
3.2.2
Update to the fixed version for your release line, for example:npm install tar@3.2.2
tarnpm
Affected
>=4.0.0 <4.4.14
Fixed in
4.4.14
Update to the fixed version for your release line, for example:npm install tar@4.4.14
tarnpm
Affected
>=5.0.0 <5.0.6
Fixed in
5.0.6
Update to the fixed version for your release line, for example:npm install tar@5.0.6
tarnpm
Affected
>=6.0.0 <6.1.1
Fixed in
6.1.1
Update to the fixed version for your release line, for example:npm install tar@6.1.1

Details

Impact

Arbitrary File Creation, Arbitrary File Overwrite, Arbitrary Code Execution

node-tar aims to prevent extraction of absolute file paths by turning absolute paths into relative paths when the preservePaths flag is not set to true. This is achieved by stripping the absolute path root from any absolute file paths contained in a tar file. For example /home/user/.bashrc would turn into home/user/.bashrc.

This logic was insufficient when file paths contained repeated path roots such as ////home/user/.bashrc. node-tar would only strip a single path root from such paths. When given an absolute file path with repeating path roots, the resulting path (e.g. ///home/user/.bashrc) would still resolve to an absolute path, thus allowing arbitrary file creation and overwrite.

Patches

3.2.2 || 4.4.14 || 5.0.6 || 6.1.1

NOTE: an adjacent issue CVE-2021-32803 affects this release level. Please ensure you update to the latest patch levels that address CVE-2021-32803 as well if this adjacent issue affects your node-tar use case.

Workarounds

Users may work around this vulnerability without upgrading by creating a custom onentry method which sanitizes the entry.path or a filter method which removes entries with absolute paths.

const path = require('path')
const tar = require('tar')

tar.x({
  file: 'archive.tgz',
  // either add this function...
  onentry: (entry) => {
    if (path.isAbsolute(entry.path)) {
      entry.path = sanitizeAbsolutePathSomehow(entry.path)
      entry.absolute = path.resolve(entry.path)
    }
  },

  // or this one
  filter: (file, entry) => {
    if (path.isAbsolute(entry.path)) {
      return false
    } else {
      return true
    }
  }
})

Users are encouraged to upgrade to the latest patch versions, rather than attempt to sanitize tar input themselves.

Is GHSA-3jfq-g458-7qm9 in any of your client repos?

Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected tar, and gives you the command that fixes it.

More advisories for tar

  • HighCVE-2026-73566node-tar: Uncontrolled recursion in mapHas/filesFilter allows uncatchable stack-overflow DoS via crafted long-path tar with member selection · 24 Jul 2026
  • MediumCVE-2026-59871node-tar: Process crash via PAX numeric path type confusion · 20 Jul 2026
  • CriticalCVE-2026-59873node-tar: Decompression/parse DoS via unlimited input · 20 Jul 2026
  • HighCVE-2026-59874node-tar: Negative tar entry size causes infinite loop in archive replace · 20 Jul 2026
  • MediumCVE-2026-59875node-tar: Uncaught Exception DoS via NUL byte in PAX path/linkpath records · 20 Jul 2026
  • MediumCVE-2026-53655node-tar applies PAX size override to intermediary GNU long-name/long-link headers, causing tar parser interpretation differential (file smuggling) · 15 Jun 2026
All 21 advisories for tar

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.