Vulnerability · Published Aug 3, 2021 · Assigned by GitHub_M

CVE-2021-32803Arbitrary File Creation/Overwrite via insufficient symlink protection due to directory cache poisoning

High 8.2

In plain English

A high-severity path traversal in node-tar from npm. There are no confirmed reports of exploitation so far. The chance it is exploited in the next 30 days is estimated at 7.8% (higher than 95% of all known vulnerabilities). Ready-made attack tooling exists: public proof-of-concept code. Fixed versions are available - upgrade the affected package.

Severity (CVSS 3.1)8.2High
Exploit odds (30 days)7.8%top 5.3% of all CVEs
Exploited in the wildNo reportsnot in CISA KEV
Attack tooling1Public PoC

Official description

The npm package "tar" (aka node-tar) before versions 6.1.2, 5.0.7, 4.4.15, and 3.2.3 has an arbitrary File Creation/Overwrite vulnerability via insufficient symlink protection. `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. This order of operations resulted in the directory being created and added to the `node-tar` directory cache. When a directory is present in the directory cache, subsequent calls to mkdir for that directory are skipped. However, this is also where `node-tar` checks for symlinks occur. 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. This issue was addressed in releases 3.2.3, 4.4.15, 5.0.7 and 6.1.2.

Affected packages & fixed versions

EcosystemPackageFixed inAdvisory
AlmaLinux:8nodejs1:12.22.5-1.module_el8.4.0+2529+af52a4c7ALSA-2021:3623
AlmaLinux:8nodejs1:12.22.5-1.module_el8.5.0+85+79a7b441ALSA-2021:3623
AlmaLinux:8nodejs-devel1:12.22.5-1.module_el8.5.0+85+79a7b441ALSA-2021:3623
AlmaLinux:8nodejs-devel1:12.22.5-1.module_el8.4.0+2529+af52a4c7ALSA-2021:3623
AlmaLinux:8nodejs-docs1:12.22.5-1.module_el8.4.0+2529+af52a4c7ALSA-2021:3623
AlmaLinux:8nodejs-full-i18n1:12.22.5-1.module_el8.5.0+85+79a7b441ALSA-2021:3623
AlmaLinux:8nodejs-full-i18n1:12.22.5-1.module_el8.4.0+2529+af52a4c7ALSA-2021:3623
AlmaLinux:8nodejs-nodemon2.0.3-1.module_el8.4.0+2521+c668cc9fALSA-2021:3623
AlmaLinux:8nodejs-nodemon2.0.3-1.module_el8.4.0+2521+c668cc9fALSA-2021:3666
AlmaLinux:8nodejs-packaging23-3.module_el8.4.0+2522+3bd42762ALSA-2021:3666
AlmaLinux:8nodejs-packaging17-3.module_el8.4.0+2224+b07ac28eALSA-2021:3623
AlmaLinux:8nodejs-packaging17-3.module_el8.4.0+2521+c668cc9fALSA-2021:3623
AlmaLinux:8nodejs-packaging17-3.module_el8.3.0+2023+d2377ea3ALSA-2021:3623
AlmaLinux:8nodejs-packaging23-3.module_el8.5.0+254+b4526b16ALSA-2021:3666
AlmaLinux:8npm1:6.14.14-1.12.22.5.1.module_el8.4.0+2529+af52a4c7ALSA-2021:3623
AlmaLinux:8npm1:6.14.14-1.12.22.5.1.module_el8.5.0+85+79a7b441ALSA-2021:3623
Alpine:v3.20tar0ALPINE-CVE-2021-32803
Alpine:v3.21tar0ALPINE-CVE-2021-32803
Alpine:v3.22tar0ALPINE-CVE-2021-32803
Alpine:v3.23tar0ALPINE-CVE-2021-32803
Alpine:v3.24tar0ALPINE-CVE-2021-32803
Debian:12node-tar6.1.7+~cs11.3.10-1DEBIAN-CVE-2021-32803
Debian:13node-tar6.1.7+~cs11.3.10-1DEBIAN-CVE-2021-32803
Debian:14node-tar6.1.7+~cs11.3.10-1DEBIAN-CVE-2021-32803
Rocky Linux:8nodejs1:14.17.5-1.module+el8.4.0+654+17ff1d38RLSA-2021:3666
Rocky Linux:8nodejs1:12.22.5-1.module+el8.4.0+647+e905fa21RLSA-2021:3623
Rocky Linux:8nodejs-nodemon0:2.0.3-1.module+el8.4.0+638+5344c6f7RLSA-2021:3623
Rocky Linux:8nodejs-nodemon0:2.0.3-1.module+el8.3.0+100+234774f7RLSA-2021:3666
Rocky Linux:8nodejs-nodemon0:2.0.3-1.module+el8.6.0+982+9fdca2d4RLSA-2021:3666
Rocky Linux:8nodejs-nodemon0:2.0.3-1.module+el8.4.0+638+5344c6f7RLSA-2021:3666
Rocky Linux:8nodejs-nodemon0:2.0.3-1.module+el8.3.0+100+234774f7RLSA-2021:3623
Rocky Linux:8nodejs-nodemon0:2.0.3-1.module+el8.6.0+982+9fdca2d4RLSA-2021:3623
Rocky Linux:8nodejs-packaging0:23-3.module+el8.7.0+1071+4bdda2a8RLSA-2021:3666
Rocky Linux:8nodejs-packaging0:23-3.module+el8.5.0+733+de4fee6cRLSA-2021:3666
Rocky Linux:8nodejs-packaging0:23-3.module+el8.3.0+100+234774f7RLSA-2021:3666
Rocky Linux:8nodejs-packaging0:17-3.module+el8.3.0+101+f84c7154RLSA-2021:3623
npmtar5.0.7GHSA-r628-mhmh-qjhw
npmtar3.2.3GHSA-r628-mhmh-qjhw
npmtar4.4.15GHSA-r628-mhmh-qjhw
npmtar6.1.2GHSA-r628-mhmh-qjhw

Affected products (as reported)

VendorProductVersions
npm node-tar < 3.2.3>= 4.0.0, < 4.4.15>= 5.0.0, < 5.0.7>= 6.0.0, < 6.1.2

Weakness: CWE-22 · Vector: CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:N

References