CVE-2021-37701Arbitrary File Creation/Overwrite via insufficient symlink protection due to directory…
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.
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
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.
| Release | Package | Status | Fixed version | Advisory |
|---|---|---|---|---|
| Ubuntu 26.04 | node-tar | Not affected vulnerable_code_not_present | ||
| Ubuntu 25.10 | node-tar | Not affected vulnerable_code_not_present | ||
| Ubuntu 24.04 | node-tar | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | node-tar | Not affected vulnerable_code_not_present | ||
| Ubuntu 20.04 | node-tar | Fix pending | UBUNTU-CVE-2021-37701 | |
| Ubuntu 18.04 | node-tar | Fix pending | UBUNTU-CVE-2021-37701 | |
| Ubuntu 16.04 | node-tar | Fix pending | UBUNTU-CVE-2021-37701 | |
| Ubuntu 14.04 | node-tar | Fix pending | UBUNTU-CVE-2021-37701 | |
| Debian 14 | node-tar | Fixed | 6.1.7+~cs11.3.10-1 | DEBIAN-CVE-2021-37701 |
| Debian 13 | node-tar | Fixed | 6.1.7+~cs11.3.10-1 | DEBIAN-CVE-2021-37701 |
| Debian 12 | node-tar | Fixed | 6.1.7+~cs11.3.10-1 | DEBIAN-CVE-2021-37701 |
| Red Hat Enterprise Linux 9 | nodejs | Not affected | ||
| Red Hat Enterprise Linux 9 | nodejs-docs | Not affected | ||
| Red Hat Enterprise Linux 9 | nodejs-full-i18n | Not affected | ||
| Red Hat Enterprise Linux 9 | nodejs-libs | Not affected | ||
| Red Hat Enterprise Linux 9 | npm | Not affected | ||
| Red Hat Enterprise Linux 8 | nodejs | Fixed | 1:14.18.2-2.module+el8.5.0+13644+8d46dafd | RHEA-2022:5139 |
| Red Hat Enterprise Linux 8 | nodejs-devel | Fixed | 1:12.22.12-1.module+el8.6.0+15324+1f2c5d8d | RHSA-2022:0350 |
| Red Hat Enterprise Linux 8 | nodejs-docs | Fixed | 1:14.18.2-2.module+el8.5.0+13644+8d46dafd | RHEA-2022:5139 |
| Red Hat Enterprise Linux 8 | nodejs-full-i18n | Fixed | 1:12.22.12-1.module+el8.6.0+15324+1f2c5d8d | RHSA-2022:0350 |
| Red Hat Enterprise Linux 8 | nodejs-libs | Not affected | ||
| Red Hat Enterprise Linux 8 | nodejs-nodemon | Fixed | 0:2.0.15-1.module+el8.5.0+13504+a2e74d91 | RHEA-2022:5139 |
| Red Hat Enterprise Linux 8 | nodejs-packaging | Fixed | 0:17-3.module+el8.1.0+3369+37ae6a45 | RHSA-2022:0350 |
| Red Hat Enterprise Linux 8 | nodejs-packaging-bundler | Not affected | ||
| Red Hat Enterprise Linux 8 | npm | Fixed | 1:6.14.15-1.14.18.2.2.module+el8.5.0+13644+8d46dafd | RHEA-2022:5139 |
| Red Hat Enterprise Linux 8 | v8-12.4-devel | Not affected | ||
| Red Hat Enterprise Linux 8 | v8-13.6-devel | Not affected | ||
| AlmaLinux 8 | nodejs | Fixed | 1:14.18.2-2.module_el8.5.0+254+b4526b16 | ALSA-2022:0350 |
| AlmaLinux 8 | nodejs-devel | Fixed | 1:14.18.2-2.module_el8.5.0+2618+8d46dafd | ALSA-2022:0350 |
| AlmaLinux 8 | nodejs-docs | Fixed | 1:14.18.2-2.module_el8.5.0+2618+8d46dafd | ALSA-2022:0350 |
| AlmaLinux 8 | nodejs-full-i18n | Fixed | 1:14.18.2-2.module_el8.5.0+2618+8d46dafd | ALSA-2022:0350 |
| AlmaLinux 8 | nodejs-nodemon | Fixed | 2.0.15-1.module_el8.5.0+2605+45d748af | ALSA-2022:0350 |
| AlmaLinux 8 | nodejs-packaging | Fixed | 23-3.module_el8.4.0+2522+3bd42762 | ALSA-2022:0350 |
| AlmaLinux 8 | npm | Fixed | 1:6.14.15-1.14.18.2.2.module_el8.5.0+2618+8d46dafd | ALSA-2022:0350 |
| Rocky Linux 8 | nodejs | Fixed | 1:14.18.2-2.module+el8.5.0+733+de4fee6c | RLSA-2022:0350 |
| Rocky Linux 8 | nodejs-nodemon | Fixed | 0:2.0.15-1.module+el8.5.0+721+4c107270 | RLSA-2022:0350 |
| Rocky Linux 8 | nodejs-packaging | Fixed | 0:23-3.module+el8.3.0+100+234774f7 | RLSA-2022:0350 |
| Alpine Linux 3.24 | nodejs | Fixed | 14.17.6-r0 | ALPINE-CVE-2021-37701 |
| Alpine Linux 3.23 | nodejs | Fixed | 14.17.6-r0 | ALPINE-CVE-2021-37701 |
| Alpine Linux 3.22 | nodejs | Fixed | 14.17.6-r0 | ALPINE-CVE-2021-37701 |
| Alpine Linux 3.21 | nodejs | Fixed | 14.17.6-r0 | ALPINE-CVE-2021-37701 |
| Alpine Linux 3.20 | nodejs | Fixed | 14.17.6-r0 | ALPINE-CVE-2021-37701 |
| Alpine Linux 3.19 | nodejs | Fixed | 14.17.6-r0 | ALPINE-CVE-2021-37701 |
| Alpine Linux 3.18 | nodejs | Fixed | 14.17.6-r0 | ALPINE-CVE-2021-37701 |
| Alpine Linux 3.17 | nodejs | Fixed | 14.17.6-r0 | ALPINE-CVE-2021-37701 |
| Alpine Linux 3.16 | nodejs | Fixed | 14.17.6-r0 | ALPINE-CVE-2021-37701 |
| Alpine Linux 3.15 | nodejs | Fixed | 14.17.6-r0 | ALPINE-CVE-2021-37701 |
| Alpine Linux 3.14 | nodejs | Fixed | 14.17.6-r0 | ALPINE-CVE-2021-37701 |
| Alpine Linux 3.13 | nodejs | Fixed | 14.17.6-r0 | ALPINE-CVE-2021-37701 |
| Alpine Linux 3.12 | nodejs | Fixed | 12.22.6-r0 | ALPINE-CVE-2021-37701 |
| Alpine Linux 3.11 | nodejs | Fixed | 12.22.6-r0 | ALPINE-CVE-2021-37701 |
| npm library | tar | Fixed | 4.4.16 | GHSA-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.
- npm node-tar: affected: < 4.4.16, >= 5.0.0, < 5.0.8, >= 6.0.0, < 6.1.7
Vendor advisories:
- https://www.debian.org/security/2021/dsa-5008 (vendor-advisory)
References
- https://www.npmjs.com/package/tar
- https://github.com/npm/node-tar/security/advisories/GHSA-9r2w-394v-53qc
- https://www.oracle.com/security-alerts/cpuoct2021.html
- https://www.debian.org/security/2021/dsa-5008
- https://cert-portal.siemens.com/productcert/pdf/ssa-389290.pdf
- https://lists.debian.org/debian-lts-announce/2022/12/msg00023.html
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.