Skip to content
OpenAdvisories
High · 8.2 CVE-2021-37701 EUVD-2021-1668GHSA-9r2w-394v-53qc

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

Published Aug 31, 2021 · Updated Aug 4, 2024 · Assigned by GitHub_M

Description

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.

Affected products

VendorProductAffectedFixed
npm node-tar < 4.4.16, >= 5.0.0, < 5.0.8, >= 6.0.0, < 6.1.7 —

Fixed in Linux distributions

Distributions backport fixes, so the version that fixes this vulnerability differs per release — upgrade to at least the version shown. From the distributions' security trackers and advisories.

ReleasePackageFixed inAdvisory
Debian 14 node-tar 6.1.7+~cs11.3.10-1 —
Debian 13 node-tar 6.1.7+~cs11.3.10-1 —
Debian 12 node-tar 6.1.7+~cs11.3.10-1 —
Debian 11 node-tar 6.0.5+ds1+~cs11.3.9-1+deb11u2 DSA-5008-1
Debian 10 node-tar 4.4.6+ds1-3+deb10u2 DLA-3237-1
ReleasePackageFixed inAdvisory
Ubuntu 18.04 LTS node-tar No fix yet —
Show 3 more (older releases, extended support, other products)
ReleasePackageFixed inAdvisory
Ubuntu Pro 20.04 LTS node-tar No fix yet —
Ubuntu Pro 16.04 LTS node-tar No fix yet —
Ubuntu Pro 14.04 LTS node-tar No fix yet —
ReleasePackageFixed inAdvisory
RHEL 8 nodejs +3 1:12.22.12-1.module+el8.6.0+15324+1f2c5d8d RHSA-2022:0350, RHEA-2022:5139
RHEL 8 nodejs-nodemon 2.0.3-1.module+el8.4.0+11732+c668cc9f RHSA-2022:0350, RHEA-2022:5139
RHEL 8 nodejs-packaging 17-3.module+el8.1.0+3369+37ae6a45 RHSA-2022:0350, RHEA-2022:5139
RHEL 8 npm 1:6.14.15-1.14.18.2.2.module+el8.5.0+13644+8d46dafd RHSA-2022:0350, RHEA-2022:5139
RHEL 3 rh-nodejs12-nodejs +2 12.22.12-2.el7 RHSA-2022:4914
RHEL 3 rh-nodejs12-npm 6.14.16-12.22.12.2.el7 RHSA-2022:4914
RHEL 3 rh-nodejs14-nodejs +2 14.18.2-1.el7 RHSA-2022:0041
RHEL 3 rh-nodejs14-nodejs-nodemon 2.0.3-6.el7 RHSA-2022:0041
RHEL 3 rh-nodejs14-npm 6.14.15-14.18.2.1.el7 RHSA-2022:0041
Show 3 more (older releases, extended support, other products)
ReleasePackageFixed inAdvisory
RHEL 8.4 EUS nodejs +3 1:12.22.12-1.module+el8.4.0+15323+4d1cc445 RHSA-2022:0246, RHEA-2022:5615
RHEL 8.4 EUS nodejs-nodemon 2.0.3-1.module+el8.4.0+11732+c668cc9f RHSA-2022:0246, RHEA-2022:5615
RHEL 8.4 EUS nodejs-packaging 17-3.module+el8.1.0+3369+37ae6a45 RHSA-2022:0246, RHEA-2022:5615
RHEL 8.4 EUS npm 1:6.14.15-1.14.18.2.2.module+el8.4.0+13643+6c0ebf22 RHSA-2022:0246, RHEA-2022:5615
RHEL 8.2 EUS nodejs +3 1:12.22.12-1.module+el8.2.0+15322+a70ca0ab RHEA-2022:5221
RHEL 8.2 EUS nodejs-nodemon 1.18.3-1.module+el8.1.0+3369+37ae6a45 RHEA-2022:5221
RHEL 8.2 EUS nodejs-packaging 17-3.module+el8.1.0+3369+37ae6a45 RHEA-2022:5221
RHEL 8.2 EUS npm 1:6.14.16-1.12.22.12.1.module+el8.2.0+15322+a70ca0ab RHEA-2022:5221
RHEL 8.1 E4S nodejs +3 1:12.22.12-1.module+el8.1.0+15296+87b2f6ad RHEA-2022:4925
RHEL 8.1 E4S nodejs-nodemon 1.18.3-1.module+el8.1.0+3369+37ae6a45 RHEA-2022:4925
RHEL 8.1 E4S nodejs-packaging 17-3.module+el8.1.0+3369+37ae6a45 RHEA-2022:4925
RHEL 8.1 E4S npm 1:6.14.16-1.12.22.12.1.module+el8.1.0+15296+87b2f6ad RHEA-2022:4925

AlmaLinux

Errata ↗
ReleasePackageFixed inAdvisory
AlmaLinux 8 nodejs +3 1:14.18.2-2.module_el8.5.0+254+b4526b16 ALSA-2022:0350
AlmaLinux 8 nodejs-nodemon 2.0.15-1.module_el8.5.0+2605+45d748af ALSA-2022:0350
AlmaLinux 8 nodejs-packaging 23-3.module_el8.4.0+2522+3bd42762 ALSA-2022:0350
AlmaLinux 8 npm 1:6.14.15-1.14.18.2.2.module_el8.5.0+254+b4526b16 ALSA-2022:0350

Rocky Linux

Errata ↗
ReleasePackageFixed inAdvisory
Rocky Linux 8 nodejs 1:14.18.2-2.module+el8.5.0+733+de4fee6c RLSA-2022:0350
Rocky Linux 8 nodejs-nodemon 2.0.15-1.module+el8.5.0+721+4c107270 RLSA-2022:0350
Rocky Linux 8 nodejs-packaging 23-3.module+el8.3.0+100+234774f7 RLSA-2022:0350
ReleasePackageFixed inAdvisory
SLES 15 SP3 nodejs12 12.22.7-4.22.1 SUSE-SU-2021:3940-1
SLES 15 SP3 nodejs14 14.18.1-15.21.2 SUSE-SU-2021:3964-1
SLES 15 SP2 nodejs12 12.22.7-4.22.1 SUSE-SU-2021:3940-1
SLES 15 SP2 nodejs14 14.18.1-15.21.2 SUSE-SU-2021:3964-1
SLES 12 nodejs12 12.22.9-1.38.1 SUSE-SU-2022:0101-1
SLES 12 nodejs14 14.18.1-6.18.2 SUSE-SU-2021:3886-1
ReleasePackageFixed inAdvisory
openSUSE Tumbleweed nodejs14 14.18.1-1.1 openSUSE-SU-2024:11616-1
openSUSE Leap 15.3 nodejs12 12.22.7-4.22.1 openSUSE-SU-2021:3940-1
openSUSE Leap 15.3 nodejs14 14.18.1-15.21.2 openSUSE-SU-2021:3964-1
openSUSE Leap 15.2 nodejs12 12.22.7-lp152.3.21.1 openSUSE-SU-2021:1574-1
openSUSE Leap 15.2 nodejs14 14.18.1-lp152.17.1 openSUSE-SU-2021:1552-1
ReleasePackageFixed inAdvisory
Alpine v3.24 nodejs 14.17.6-r0 —
Alpine v3.23 nodejs 14.17.6-r0 —
Alpine v3.22 nodejs 14.17.6-r0 —
Alpine v3.21 nodejs 14.17.6-r0 —
Alpine v3.20 nodejs 14.17.6-r0 —
Show 9 more (older releases, extended support, other products)
ReleasePackageFixed inAdvisory
Alpine v3.19 nodejs 14.17.6-r0 —
Alpine v3.18 nodejs 14.17.6-r0 —
Alpine v3.17 nodejs 14.17.6-r0 —
Alpine v3.16 nodejs 14.17.6-r0 —
Alpine v3.15 nodejs 14.17.6-r0 —
Alpine v3.14 nodejs 14.17.6-r0 —
Alpine v3.13 nodejs 14.17.6-r0 —
Alpine v3.12 nodejs 12.22.6-r0 —
Alpine v3.11 nodejs 12.22.6-r0 —

Oracle Linux

ReleasePackageFixed inAdvisory
Oracle Linux 8 nodejs +3 1:14.18.2-2.module+el8.5.0+20489+261d51d3 ELSA-2022-0350
Oracle Linux 8 nodejs-nodemon 2.0.15-1.module+el8.5.0+20489+261d51d3 ELSA-2022-0350
Oracle Linux 8 nodejs-packaging 23-3.module+el8.3.0+7818+6cd30d85 ELSA-2022-0350
Oracle Linux 8 npm 1:6.14.15-1.14.18.2.2.module+el8.5.0+20489+261d51d3 ELSA-2022-0350

Affected packages

EcosystemPackageAffectedFixedRecord
npm tar >= 3.0.0, < 4.4.16 4.4.16 GHSA-9r2w-394v-53qc
npm tar >= 5.0.0, < 5.0.8 5.0.8 GHSA-9r2w-394v-53qc
npm tar >= 6.0.0, < 6.1.7 6.1.7 GHSA-9r2w-394v-53qc

Advisories 31

References