CVE-2021-37712 Arbitrary File Creation/Overwrite via insufficient symlink protection due to directory cache poisoning using symbolic links

High 8.2 Published Updated

Attackers can bypass symlink protections in node-tar to create or overwrite arbitrary files, potentially leading to code execution.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Local or same network only
Victim action needed
A user has to click or open something
Fix
Available

What is CVE-2021-37712?

CVE-2021-37712 is a high-severity path traversal vulnerability in Debian Debian Linux, published on 31 Aug 2021. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

Official description

The npm package "tar" (aka node-tar) before versions 4.4.18, 5.0.10, and 6.1.9 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 names containing unicode values that normalized to the same value. Additionally, on Windows systems, long path portions would resolve to the same file system entities as their 8.3 "short path" counterparts. A specially crafted tar archive could thus include a directory with one form of the path, followed by a symbolic link with a different string that resolves to the same file system entity, followed by a file using the first form. By first creating a directory, and then replacing that directory with a symlink that had a different apparent name that resolved to the same entry in the filesystem, 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. These issues were addressed in releases 4.4.18, 5.0.10 and 6.1.9. 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-qq89-hq3f-393p.

Weakness: CWE-59, CWE-22

Which versions are affected by CVE-2021-37712?

6 open source packages ship an affected version, including tar. It affects 4 products.

PackageAffectedFixed in
tar npmFrom 3.0.04.4.18
tar npmFrom 3.0.04.4.18
tar npmFrom 5.0.05.0.10
tar npmFrom 5.0.05.0.10
tar npmFrom 6.0.06.1.9
tar npmFrom 6.0.06.1.9

Products include Debian Debian Linux, Npmjs Tar, Oracle Graalvm, Siemens Sinec Infrastructure Network Services.

How do I fix CVE-2021-37712?

Upgrade tar to a fixed version for your release line: 4.4.18, 5.0.10 or 6.1.9.

Upgrade, and resolve every user-supplied path against an allowed base folder before opening it. More about Path traversal.

Is CVE-2021-37712 being exploited?

There is no known exploitation of CVE-2021-37712 in the wild and no public exploit code.

All Debian Debian Linux vulnerabilities

Sources

Also known as ALPINE-CVE-2021-37712, CLEANSTART-2026-IJ66731, CLEANSTART-2026-WP70960, DEBIAN-CVE-2021-37712, GHSA-qq89-hq3f-393p, ROOT-APP-NPM-CVE-2021-37712 and 1 more.

Is CVE-2021-37712 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free