Your RSA-2048 keys break in 2030. Find every one of them before attackers do.
📦
📦 npm
Not in CISA KEV
HIGH severity

CVE-2021-37701 — tar

HIGH

CVE-2021-37701 is a high-severity (CVSS 8.6) Path Traversal vulnerability in tar. A fix is available for tar — see the affected versions and patch details below.

Arbitrary File Creation/Overwrite via insufficient symlink protection due to directory cache poisoning using symbolic links

Also known asGHSA-9r2w-394v-53qc
Published
Updated
Affected
3 pkgs
Patched
3 / 3
Exploits
None indexed
Exploitation data as of Oct 10, 2026 · OSV.dev, NVD, FIRST.org (EPSS)

EPSS Exploitation Probability

via FIRST.org ↗
3.3%probability of exploitation in next 30 days
Lower Risk0.00%
Lower risk than most CVEs88th percentile — riskier than 88% of all scored CVEsHighest risk
0.00%1.41%2.83%4.24%0.1%3.3%Apr 26Aug 26Oct 26

Probability of exploitation in the next 30 days, from FIRST.org EPSS.

How urgent is this, really

CVE-2021-37701 by exploitation likelihood (EPSS) against impact (CVSS). Outside the shaded patch-first corner.

Where this sits among everything scored

Of 385,738 CVEs with a current EPSS score, this one falls in the < 10% band (highlighted). Counts from FIRST.org, log-scaled.

Real-World Exposure

3 pkgs affected

How broadly this vulnerability is actually deployed: weekly install volume shows current usage, and reverse-dependency count shows how many other packages break if it stays unpatched.

8Kother npm packages depend on this — each one inherits the vulnerability until it's patched upstream
tarnpm
89.7Mdownloads / week

Description

Impact

Arbitrary File Creation, Arbitrary File Overwrite, Arbitrary Code Execution

node-tar aims to guarantee that any file whose location would be modified by a symbolic link is not extracted. This is, in part, achieved by ensuring that extracted directories are not symlinks. Additionally, in order to prevent unnecessary stat calls to determine whether a given path is a directory, paths are cached when directories are created.

This logic was insufficient when extracting tar files that contained both a directory and a symlink with the same name as the directory, where the symlink and directory names in the archive entry used backslashes as a path separator on posix systems. The cache checking logic used both \ and / characters as path separators, however \ is a valid filename character on posix systems.

By first creating a directory, and then replacing that directory with a symlink, it was thus possible to bypass node-tar symlink checks on directories, essentially allowing an untrusted tar file to symlink into an arbitrary location and subsequently extracting arbitrary files into that location, thus allowing arbitrary file creation and overwrite.

Additionally, a similar confusion could arise on case-insensitive filesystems. If a tar archive contained a directory at FOO, followed by a symbolic link named foo, then on case-insensitive file systems, the creation of the symbolic link would remove the directory from the filesystem, but not from the internal directory cache, as it would not be treated as a cache hit. A subsequent file entry within the FOO directory would then be placed in the target of the symbolic link, thinking that the directory had already been created.

These issues were addressed in releases 4.4.16, 5.0.8 and 6.1.7.

The v3 branch of node-tar has been deprecated and did not receive patches for these issues. If you are still using a v3 release we recommend you update to a more recent version of node-tar. If this is not possible, a workaround is available below.

Patches

4.4.16 || 5.0.8 || 6.1.7

Workarounds

Users may work around this vulnerability without upgrading by creating a custom filter method which prevents the extraction of symbolic links.

const tar = require('tar')

tar.x({
  file: 'archive.tgz',
  filter: (file, entry) => {
    if (entry.type === 'SymbolicLink') {
      return false
    } else {
      return true
    }
  }
})

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

Fix

The problem is addressed in the following ways:

  1. All paths are normalized to use / as a path separator, replacing \ with / on Windows systems, and leaving \ intact in the path on posix systems. This is performed in depth, at every level of the program where paths are consumed.
  2. Directory cache pruning is performed case-insensitively. This may result in undue cache misses on case-sensitive file systems, but the performance impact is negligible.

Caveat

Note that this means that the entry objects exposed in various parts of tar's API will now always use / as a path separator, even on Windows systems. This is not expected to cause problems, as / is a valid path separator on Windows systems, but may result in issues if entry.path is compared against a path string coming from some other API such as fs.realpath() or path.resolve().

Users are encouraged to always normalize paths using a well-tested method such as path.resolve() before comparing paths to one another.

Affected Packages

3 total 3 fixed
EcosystemPackageVulnerable rangeFix
📦npmtar≥ 3.0.0&&< 4.4.164.4.16npm install tar@4.4.16
📦npmtar≥ 5.0.0&&< 5.0.85.0.8npm install tar@5.0.8
📦npmtar≥ 6.0.0&&< 6.1.76.1.7npm install tar@6.1.7

Affected Products

4 products · 8 configurations
OS
debian linuxdebian
2 versions
10.011.0
Application
tarnpmjs
≥ 6.0.0 && < 6.1.7
range
Application
graalvmoracle
2 versions
20.3.321.2.0
Application
sinec infrastructure network servicessiemens
< 1.0.1.1
range

Detection & mitigation playbook

Open-source dependency
  1. Detect

    Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for tar, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.

  2. Fix

    Update tar to 4.4.16 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2021-37701 is resolved across your whole dependency graph.

  3. Workarounds

    Resolve every user-supplied path to its canonical form and reject anything that escapes the intended directory, and run the component under an account that has no read or write access outside the directory it legitimately serves.

Fixing This On Your OS

If you run this on a Linux distribution, patch through your package manager against the distro's own security advisory below — it tracks the exact backported fix for your release, which can ship on a different timeline (and sometimes a different severity) than the upstream project.

Red HatModerate

Red Hat Enterprise Linux version 8 and Red Hat Software Collection both embed `node-tar` in the npm command. However, npm explicitly prevents the extraction of symlink via a filter. npm might still be affected via node-gyp, if the attacker is able to control the target URL.

ProductFixed inAdvisory
Red Hat Enterprise Linux 8nodejs:12-8060020220523160029.ad008a3aRHEA-2022:5139
Red Hat Enterprise Linux 8nodejs:14-8050020211213115342.c5368500RHSA-2022:0350
Red Hat Enterprise Linux 8.1 Update Services for SAP Solutionsnodejs:12-8010020220518102644.c27ad7f8RHEA-2022:4925
Red Hat Enterprise Linux 8.2 Extended Update Supportnodejs:12-8020020220523154454.4cda2c84RHEA-2022:5221
Red Hat Enterprise Linux 8.4 Extended Update Supportnodejs:12-8040020220523155137.522a0ee4RHEA-2022:5615
Red Hat Enterprise Linux 8.4 Extended Update Supportnodejs:14-8040020211213111158.522a0ee4RHSA-2022:0246
Red Hat OpenShift Data Foundation 4.9.0 on RHEL-8odf4/cephcsi-rhel8:4.9-164.57484e3.release_4.9RHSA-2021:5086
Red Hat Software Collections for Red Hat Enterprise Linux 7rh-nodejs14-nodejs-0:14.18.2-1.el7RHSA-2022:0041

Frequently Asked Questions

### Impact Arbitrary File Creation, Arbitrary File Overwrite, Arbitrary Code Execution `node-tar` aims to guarantee that any file whose location would be modified by a symbolic link is not extracted. This is, in part, achieved by ensuring that extracted directories are not symlinks. Additionally, in order to prevent unnecessary stat calls to determine whether a given path is a directory, paths are cached when directories are created. This logic was insufficient when extracting tar files that contained both a directory and a symlink with the same name as the directory, where the symlink and
O3 Security · Impact-Aware SCA

Is CVE-2021-37701 in your dependencies?

Find it across npm, including transitive dependencies.

CVE-2021-37701: tar RCE — Fixed in 4.4.16