Vulnerability · Published Aug 3, 2021 · Assigned by GitHub_M

CVE-2021-32804Arbitrary File Creation/Overwrite due to insufficient absolute path sanitization

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 15.1% (higher than 97% 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)15.1%top 3.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.1, 5.0.6, 4.4.14, and 3.3.2 has a arbitrary File Creation/Overwrite vulnerability due to insufficient absolute path sanitization. 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. This issue was addressed in releases 3.2.2, 4.4.14, 5.0.6 and 6.1.1. 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. See referenced GitHub Advisory for details. Be aware of CVE-2021-32803 which fixes a similar bug in later versions of tar.

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.4.0+2529+af52a4c7ALSA-2021:3623
AlmaLinux:8nodejs-devel1:12.22.5-1.module_el8.5.0+85+79a7b441ALSA-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.4.0+2529+af52a4c7ALSA-2021:3623
AlmaLinux:8nodejs-full-i18n1:12.22.5-1.module_el8.5.0+85+79a7b441ALSA-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-32804
Alpine:v3.21tar0ALPINE-CVE-2021-32804
Alpine:v3.22tar0ALPINE-CVE-2021-32804
Alpine:v3.23tar0ALPINE-CVE-2021-32804
Alpine:v3.24tar0ALPINE-CVE-2021-32804
Debian:12node-tar6.1.7+~cs11.3.10-1DEBIAN-CVE-2021-32804
Debian:13node-tar6.1.7+~cs11.3.10-1DEBIAN-CVE-2021-32804
Debian:14node-tar6.1.7+~cs11.3.10-1DEBIAN-CVE-2021-32804
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.6.0+982+9fdca2d4RLSA-2021:3623
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.4.0+638+5344c6f7RLSA-2021:3623
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.3.0+100+234774f7RLSA-2021:3666
Rocky Linux:8nodejs-nodemon0:2.0.3-1.module+el8.4.0+638+5344c6f7RLSA-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:23-3.module+el8.7.0+1071+4bdda2a8RLSA-2021:3666
Rocky Linux:8nodejs-packaging0:17-3.module+el8.3.0+101+f84c7154RLSA-2021:3623
Ubuntu:22.04:LTSnode-tarno fix listedUBUNTU-CVE-2021-32804
Ubuntu:24.04:LTSnode-tarno fix listedUBUNTU-CVE-2021-32804
Ubuntu:25.10node-tarno fix listedUBUNTU-CVE-2021-32804
Ubuntu:26.04:LTSnode-tarno fix listedUBUNTU-CVE-2021-32804
Ubuntu:26.10node-tarno fix listedUBUNTU-CVE-2021-32804
npmtar5.0.6GHSA-3jfq-g458-7qm9
npmtar3.2.2GHSA-3jfq-g458-7qm9
npmtar4.4.14GHSA-3jfq-g458-7qm9
npmtar6.1.1GHSA-3jfq-g458-7qm9

Affected products (as reported)

VendorProductVersions
npm node-tar < 3.2.2>= 4.0.0, < 4.4.14>= 5.0.0, < 5.0.6>= 6.0.0, < 6.1.1

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

References