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.
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
| Ecosystem | Package | Fixed in | Advisory |
|---|---|---|---|
| AlmaLinux:8 | nodejs | 1:12.22.5-1.module_el8.4.0+2529+af52a4c7 | ALSA-2021:3623 |
| AlmaLinux:8 | nodejs | 1:12.22.5-1.module_el8.5.0+85+79a7b441 | ALSA-2021:3623 |
| AlmaLinux:8 | nodejs-devel | 1:12.22.5-1.module_el8.4.0+2529+af52a4c7 | ALSA-2021:3623 |
| AlmaLinux:8 | nodejs-devel | 1:12.22.5-1.module_el8.5.0+85+79a7b441 | ALSA-2021:3623 |
| AlmaLinux:8 | nodejs-docs | 1:12.22.5-1.module_el8.4.0+2529+af52a4c7 | ALSA-2021:3623 |
| AlmaLinux:8 | nodejs-full-i18n | 1:12.22.5-1.module_el8.4.0+2529+af52a4c7 | ALSA-2021:3623 |
| AlmaLinux:8 | nodejs-full-i18n | 1:12.22.5-1.module_el8.5.0+85+79a7b441 | ALSA-2021:3623 |
| AlmaLinux:8 | nodejs-nodemon | 2.0.3-1.module_el8.4.0+2521+c668cc9f | ALSA-2021:3623 |
| AlmaLinux:8 | nodejs-nodemon | 2.0.3-1.module_el8.4.0+2521+c668cc9f | ALSA-2021:3666 |
| AlmaLinux:8 | nodejs-packaging | 23-3.module_el8.4.0+2522+3bd42762 | ALSA-2021:3666 |
| AlmaLinux:8 | nodejs-packaging | 17-3.module_el8.4.0+2224+b07ac28e | ALSA-2021:3623 |
| AlmaLinux:8 | nodejs-packaging | 17-3.module_el8.4.0+2521+c668cc9f | ALSA-2021:3623 |
| AlmaLinux:8 | nodejs-packaging | 17-3.module_el8.3.0+2023+d2377ea3 | ALSA-2021:3623 |
| AlmaLinux:8 | nodejs-packaging | 23-3.module_el8.5.0+254+b4526b16 | ALSA-2021:3666 |
| AlmaLinux:8 | npm | 1:6.14.14-1.12.22.5.1.module_el8.4.0+2529+af52a4c7 | ALSA-2021:3623 |
| AlmaLinux:8 | npm | 1:6.14.14-1.12.22.5.1.module_el8.5.0+85+79a7b441 | ALSA-2021:3623 |
| Alpine:v3.20 | tar | 0 | ALPINE-CVE-2021-32804 |
| Alpine:v3.21 | tar | 0 | ALPINE-CVE-2021-32804 |
| Alpine:v3.22 | tar | 0 | ALPINE-CVE-2021-32804 |
| Alpine:v3.23 | tar | 0 | ALPINE-CVE-2021-32804 |
| Alpine:v3.24 | tar | 0 | ALPINE-CVE-2021-32804 |
| Debian:12 | node-tar | 6.1.7+~cs11.3.10-1 | DEBIAN-CVE-2021-32804 |
| Debian:13 | node-tar | 6.1.7+~cs11.3.10-1 | DEBIAN-CVE-2021-32804 |
| Debian:14 | node-tar | 6.1.7+~cs11.3.10-1 | DEBIAN-CVE-2021-32804 |
| Rocky Linux:8 | nodejs | 1:14.17.5-1.module+el8.4.0+654+17ff1d38 | RLSA-2021:3666 |
| Rocky Linux:8 | nodejs | 1:12.22.5-1.module+el8.4.0+647+e905fa21 | RLSA-2021:3623 |
| Rocky Linux:8 | nodejs-nodemon | 0:2.0.3-1.module+el8.6.0+982+9fdca2d4 | RLSA-2021:3623 |
| Rocky Linux:8 | nodejs-nodemon | 0:2.0.3-1.module+el8.3.0+100+234774f7 | RLSA-2021:3623 |
| Rocky Linux:8 | nodejs-nodemon | 0:2.0.3-1.module+el8.4.0+638+5344c6f7 | RLSA-2021:3623 |
| Rocky Linux:8 | nodejs-nodemon | 0:2.0.3-1.module+el8.6.0+982+9fdca2d4 | RLSA-2021:3666 |
| Rocky Linux:8 | nodejs-nodemon | 0:2.0.3-1.module+el8.3.0+100+234774f7 | RLSA-2021:3666 |
| Rocky Linux:8 | nodejs-nodemon | 0:2.0.3-1.module+el8.4.0+638+5344c6f7 | RLSA-2021:3666 |
| Rocky Linux:8 | nodejs-packaging | 0:23-3.module+el8.5.0+733+de4fee6c | RLSA-2021:3666 |
| Rocky Linux:8 | nodejs-packaging | 0:23-3.module+el8.3.0+100+234774f7 | RLSA-2021:3666 |
| Rocky Linux:8 | nodejs-packaging | 0:23-3.module+el8.7.0+1071+4bdda2a8 | RLSA-2021:3666 |
| Rocky Linux:8 | nodejs-packaging | 0:17-3.module+el8.3.0+101+f84c7154 | RLSA-2021:3623 |
| Ubuntu:22.04:LTS | node-tar | no fix listed | UBUNTU-CVE-2021-32804 |
| Ubuntu:24.04:LTS | node-tar | no fix listed | UBUNTU-CVE-2021-32804 |
| Ubuntu:25.10 | node-tar | no fix listed | UBUNTU-CVE-2021-32804 |
| Ubuntu:26.04:LTS | node-tar | no fix listed | UBUNTU-CVE-2021-32804 |
| Ubuntu:26.10 | node-tar | no fix listed | UBUNTU-CVE-2021-32804 |
| npm | tar | 5.0.6 | GHSA-3jfq-g458-7qm9 |
| npm | tar | 3.2.2 | GHSA-3jfq-g458-7qm9 |
| npm | tar | 4.4.14 | GHSA-3jfq-g458-7qm9 |
| npm | tar | 6.1.1 | GHSA-3jfq-g458-7qm9 |
Affected products (as reported)
Weakness: CWE-22 · Vector: CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:N
References
- https://www.npmjs.com/package/tar x_refsource_MISC
- https://github.com/npm/node-tar/security/advisories/GHSA-3jfq-g458-7qm9 x_refsource_CONFIRM
- https://github.com/npm/node-tar/commit/1f036ca23f64a547bdd6c79c1a44bc62e8115da4 x_refsource_MISC
- https://www.npmjs.com/advisories/1770 x_refsource_MISC
- https://www.oracle.com/security-alerts/cpuoct2021.html x_refsource_MISC
- https://cert-portal.siemens.com/productcert/pdf/ssa-389290.pdf x_refsource_CONFIRM