CVE-2021-32803
Arbitrary File Creation/Overwrite via insufficient symlink protection due to directory cache poisoning
Check your servers for CVE-2021-32803
The Vulnpocalypse collector sends the package list of each Linux server and of its container images once a day. Vulnpocalypse shows every server where CVE-2021-32803 affects node-tar, with the command that installs the fix. The free plan covers one server and one domain and does not need a credit card.
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.
Severity (CVSS)
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:N
- Attack vector
- local: the attacker needs local access, or a user has to open a prepared file
- Attack complexity
- low: an attack works without special conditions
- Privileges required
- none: the attacker does not need an account
- User interaction
- required: a user has to do something, such as open a link or a file
- Scope
- changed: the damage reaches other components, such as the host of a container or other users
- Impact
- confidentiality high, integrity high, availability none: what an attacker can read (confidentiality), change (integrity) or stop (availability)
Exploitation
EPSS 7.10%: the probability of exploitation activity in the next 30 days, from the EPSS model of FIRST. The score is higher than 94.3% of all scored CVEs. Scores of 1 Dec 2026.
Weakness
- CWE-22 Improper Limitation of a Pathname to a Restricted Directory
Affected products
As the CNA lists them.
| Product | Versions |
|---|---|
| node-tar |
affected < 3.2.3 affected >= 4.0.0, < 4.4.15 affected >= 5.0.0, < 5.0.7 affected >= 6.0.0, < 6.1.2
|
Is my server affected?
Find the installed version of node-tar and compare it with the fixed version of your distribution. Distributions often fix a CVE in a package version of their own, so the version number of the upstream project can mislead.
Debian, Ubuntu
dpkg -l | grep -i node-tar
# packages whose changelog names the CVE (fixed in the installed version)
zgrep -l CVE-2021-32803 /usr/share/doc/*/changelog.Debian.gz
# Ubuntu
pro fix CVE-2021-32803RHEL, Rocky, Alma, Fedora
rpm -q node-tar
# lists the advisory while the fix is not installed
dnf updateinfo list --cve CVE-2021-32803Alpine
apk list --installed | grep -i node-tarWith Trivy, on the host and for a container image. When a package is affected, it prints the installed and the fixed version:
trivy rootfs --scanners vuln / | grep CVE-2021-32803
trivy image --scanners vuln IMAGE | grep CVE-2021-32803
Vulnpocalypse makes this comparison every day for the package lists of your servers and container images, including language packages (npm, PyPI, Go, Maven and others), and sends the command that installs the fix. Start free with one server and one domain or read how to install the collector.
References
Advisories
- https://github.com/npm/node-tar/security/advisories/GHSA-r628-mhmh-qjhw github.com
- https://cert-portal.siemens.com/productcert/pdf/ssa-389290.pdf cert-portal.siemens.com
Other references
- https://github.com/npm/node-tar/commit/9dbdeb6df8e9dbd96fa9e84341b9d74734be6c20 github.com
- https://www.npmjs.com/advisories/1771 npmjs.com
- https://www.npmjs.com/package/tar npmjs.com
- https://www.oracle.com/security-alerts/cpuoct2021.html oracle.com
Source: the record CVE-2021-32803 of the CVE List (CVE Program), CVE Terms of Use; EPSS of FIRST; the CWE catalog of MITRE, CWE Terms of Use. The text of the record is shown as published. Data sources and licences.
Vulnpocalypse