CVE-2021-37713: Arbitrary File Creation/Overwrite on Windows via insufficient relative path sanitization in tar
Summary
CVE-2021-37713: Arbitrary File Creation/Overwrite on Windows via insufficient relative path sanitization. Affects tar across 3 version ranges.
< 4.4.18
>= 5.0.0, < 5.0.10
>= 6.0.0, < 6.1.9
Fixed in 4.4.18, 5.0.10 or 6.1.9, depending on the release line you run. How to fix ↓
Also tracked for
- nodejs · Alpine:v3.11
The same CVE-2021-37713 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
The 'tar' package is an open-source library for creating and extracting tar archives in the Node.js ecosystem. It provides functionality to compress and decompress files and directories. However, a vulnerability has been identified in versions prior to 4.4.18, 5.0.10, and 6.1.9 that allows arbitrary file creation, overwrite, and potential code execution on Windows systems. This vulnerability arises from insufficient relative path sanitization during the extraction process.
Vulnerability Detail
The vulnerability in the 'tar' package affects Windows systems when extracting tar files that contain a path with a different drive letter than the extraction target. For example, if the extraction target is 'D:\extraction\dir' and the tar file contains a path like 'C:some\path', the path resolution would occur against the current working directory on the 'C:' drive instead of the extraction target directory. Additionally, paths starting with a drive letter followed by two dots, such as 'c:..', bypass the check for '..' path portions. This allows an attacker to create or overwrite arbitrary files outside the intended extraction target directory, potentially leading to arbitrary code execution.
How To Fix
Latest published version: 7.5.22 as of 22 Oct 2026
npm install tar@7.5.22
Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.
If you can't move to the latest
The minimum fixed version depends on the release line you run.
-
< 4.4.184.4.18npm install tar@4.4.18 -
>= 5.0.0, < 5.0.105.0.10npm install tar@5.0.10 -
>= 6.0.0, < 6.1.96.1.9npm install tar@6.1.9
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
There is no reasonable workaround for this issue without performing the same path normalization procedures implemented in the patched versions of 'tar'. It is strongly advised to upgrade to the latest patched versions rather than attempting to sanitize paths manually.
Conclusion
The 'tar' package prior to versions 4.4.18, 5.0.10, and 6.1.9 is vulnerable to arbitrary file creation, overwrite, and potential code execution on Windows systems. Upgrading to the latest patched versions is crucial to mitigate this vulnerability. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tar →
FAQ
The impact of this vulnerability includes arbitrary file creation, arbitrary file overwrite, and potential arbitrary code execution on Windows systems using the 'tar' package prior to versions 4.4.18, 5.0.10, and 6.1.9.
No, this vulnerability only affects Windows systems.
There are no reasonable workarounds for this vulnerability. Upgrading to the latest patched versions of the 'tar' package is the recommended solution.
You can use the Vulert Playground at Vulert Scanner to check if your application is affected by this vulnerability. Vulert monitors and alerts in real-time for open-source vulnerabilities without requiring access to the code or installation.
The CVSS score for this vulnerability is 8.2, indicating a high severity level.
References
Related vulnerabilities
Recent vulnerabilities recorded for tar.