CVEfocus › CVE database › CVE-2021-37701

CVE-2021-37701Arbitrary File Creation/Overwrite via insufficient symlink protection due to directory…

CVSS 8.2 HighEPSS 1.8% (higher than 80% of CVEs)Published 2021-08-31Updated 2024-08-04Assigner: GitHub_M

The npm package "tar" (aka node-tar) before versions 4.4.16, 5.0.8, and 6.1.7 has an arbitrary file creation/overwrite and arbitrary code execution vulnerability. 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 in the referenced GHSA-9r2w-394v-53qc.

CWE-22CWE-59

What to do

Fixed builds are available from AlmaLinux, Alpine, Debian, Red Hat, Rocky Linux, npm: see the table below for the fixed version per release.

Ubuntu has not shipped a fix for every release yet.

Is your server affected? One read-only command checks every installed package against this CVE and all others, using each vendor's fixed versions. Get started or get a free API key.

curl -sS "https://api.cvefocus.com/v1/check?format=text" -H "Authorization: Bearer $CVEFOCUS_KEY" \
  -H "Content-Type: text/plain" --data-binary @inventory.txt

Vendor status at a glance

35Fixed
4Fix pending
13Not affected

Status by vendor and release

From each vendor's own security data and VEX statements. "Fixed" means a fixed build is published for that release.

ReleasePackageStatusFixed versionAdvisory
Ubuntu 26.04node-tarNot affected
vulnerable_code_not_present
Ubuntu 25.10node-tarNot affected
vulnerable_code_not_present
Ubuntu 24.04node-tarNot affected
vulnerable_code_not_present
Ubuntu 22.04node-tarNot affected
vulnerable_code_not_present
Ubuntu 20.04node-tarFix pendingUBUNTU-CVE-2021-37701
Ubuntu 18.04node-tarFix pendingUBUNTU-CVE-2021-37701
Ubuntu 16.04node-tarFix pendingUBUNTU-CVE-2021-37701
Ubuntu 14.04node-tarFix pendingUBUNTU-CVE-2021-37701
Debian 14node-tarFixed6.1.7+~cs11.3.10-1DEBIAN-CVE-2021-37701
Debian 13node-tarFixed6.1.7+~cs11.3.10-1DEBIAN-CVE-2021-37701
Debian 12node-tarFixed6.1.7+~cs11.3.10-1DEBIAN-CVE-2021-37701
Red Hat Enterprise Linux 9nodejsNot affected
Red Hat Enterprise Linux 9nodejs-docsNot affected
Red Hat Enterprise Linux 9nodejs-full-i18nNot affected
Red Hat Enterprise Linux 9nodejs-libsNot affected
Red Hat Enterprise Linux 9npmNot affected
Red Hat Enterprise Linux 8nodejsFixed1:14.18.2-2.module+el8.5.0+13644+8d46dafdRHEA-2022:5139
Red Hat Enterprise Linux 8nodejs-develFixed1:12.22.12-1.module+el8.6.0+15324+1f2c5d8dRHSA-2022:0350
Red Hat Enterprise Linux 8nodejs-docsFixed1:14.18.2-2.module+el8.5.0+13644+8d46dafdRHEA-2022:5139
Red Hat Enterprise Linux 8nodejs-full-i18nFixed1:12.22.12-1.module+el8.6.0+15324+1f2c5d8dRHSA-2022:0350
Red Hat Enterprise Linux 8nodejs-libsNot affected
Red Hat Enterprise Linux 8nodejs-nodemonFixed0:2.0.15-1.module+el8.5.0+13504+a2e74d91RHEA-2022:5139
Red Hat Enterprise Linux 8nodejs-packagingFixed0:17-3.module+el8.1.0+3369+37ae6a45RHSA-2022:0350
Red Hat Enterprise Linux 8nodejs-packaging-bundlerNot affected
Red Hat Enterprise Linux 8npmFixed1:6.14.15-1.14.18.2.2.module+el8.5.0+13644+8d46dafdRHEA-2022:5139
Red Hat Enterprise Linux 8v8-12.4-develNot affected
Red Hat Enterprise Linux 8v8-13.6-develNot affected
AlmaLinux 8nodejsFixed1:14.18.2-2.module_el8.5.0+254+b4526b16ALSA-2022:0350
AlmaLinux 8nodejs-develFixed1:14.18.2-2.module_el8.5.0+2618+8d46dafdALSA-2022:0350
AlmaLinux 8nodejs-docsFixed1:14.18.2-2.module_el8.5.0+2618+8d46dafdALSA-2022:0350
AlmaLinux 8nodejs-full-i18nFixed1:14.18.2-2.module_el8.5.0+2618+8d46dafdALSA-2022:0350
AlmaLinux 8nodejs-nodemonFixed2.0.15-1.module_el8.5.0+2605+45d748afALSA-2022:0350
AlmaLinux 8nodejs-packagingFixed23-3.module_el8.4.0+2522+3bd42762ALSA-2022:0350
AlmaLinux 8npmFixed1:6.14.15-1.14.18.2.2.module_el8.5.0+2618+8d46dafdALSA-2022:0350
Rocky Linux 8nodejsFixed1:14.18.2-2.module+el8.5.0+733+de4fee6cRLSA-2022:0350
Rocky Linux 8nodejs-nodemonFixed0:2.0.15-1.module+el8.5.0+721+4c107270RLSA-2022:0350
Rocky Linux 8nodejs-packagingFixed0:23-3.module+el8.3.0+100+234774f7RLSA-2022:0350
Alpine Linux 3.24nodejsFixed14.17.6-r0ALPINE-CVE-2021-37701
Alpine Linux 3.23nodejsFixed14.17.6-r0ALPINE-CVE-2021-37701
Alpine Linux 3.22nodejsFixed14.17.6-r0ALPINE-CVE-2021-37701
Alpine Linux 3.21nodejsFixed14.17.6-r0ALPINE-CVE-2021-37701
Alpine Linux 3.20nodejsFixed14.17.6-r0ALPINE-CVE-2021-37701
Alpine Linux 3.19nodejsFixed14.17.6-r0ALPINE-CVE-2021-37701
Alpine Linux 3.18nodejsFixed14.17.6-r0ALPINE-CVE-2021-37701
Alpine Linux 3.17nodejsFixed14.17.6-r0ALPINE-CVE-2021-37701
Alpine Linux 3.16nodejsFixed14.17.6-r0ALPINE-CVE-2021-37701
Alpine Linux 3.15nodejsFixed14.17.6-r0ALPINE-CVE-2021-37701
Alpine Linux 3.14nodejsFixed14.17.6-r0ALPINE-CVE-2021-37701
Alpine Linux 3.13nodejsFixed14.17.6-r0ALPINE-CVE-2021-37701
Alpine Linux 3.12nodejsFixed12.22.6-r0ALPINE-CVE-2021-37701
Alpine Linux 3.11nodejsFixed12.22.6-r0ALPINE-CVE-2021-37701
npm librarytarFixed4.4.16GHSA-9r2w-394v-53qc

What the vendor says

As published in the CVE record by GitHub_M, the CVE's assigner (usually the vendor). Check the vendor's advisory before acting.

Vendor advisories:

References

About this page

Compiled by CVEfocus from the CVE List, the security data and VEX statements of Ubuntu, Debian, Red Hat, AlmaLinux, Rocky Linux and Microsoft, CISA's Known Exploited Vulnerabilities catalog and FIRST EPSS, refreshed several times a day (data status). Information only; see the disclaimer. Official record: cve.org · NVD.