Arbitrary File Creation and Code Execution in npm package 'tar'

nodejs Updated 02 Oct 2025

Summary

31/08/2021
N/A
Yes i
High
8.6

CVE-2021-37713: 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. Affects nodejs across 2 version ranges.

< 3e35515c09da615ac268254bed85fe43ee71e2f0 < 12.22.6-r0

Fixed in 12.22.6-r0. How to fix ↓

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

The npm package 'tar', also known as node-tar, is a tool used for extracting tar files in Node.js applications. It ensures that files outside the extraction target directory are not extracted. However, versions before 4.4.18, 5.0.10, and 6.1.9 have a vulnerability that allows arbitrary file creation/overwrite and code execution. This vulnerability affects Windows systems when extracting tar files with specific path configurations.

Vulnerability Detail

The vulnerability arises from the insufficient logic in handling path resolutions on Windows systems. If a tar file contains a path that is not an absolute path but specifies a different drive letter from the extraction target, the path resolution may occur in the wrong directory. Additionally, the logic fails to properly sanitize paths with '..' portions immediately after the drive letter. This vulnerability can lead to arbitrary file creation, overwrite, and code execution.

How To Fix

Minimum fixed version

12.22.6-r0

This is the first release that contains the fix.

sudo apk add --upgrade nodejs

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Conclusion

The npm package 'tar' has a vulnerability that allows arbitrary file creation/overwrite and code execution. It affects versions before 4.4.18, 5.0.10, and 6.1.9 on Windows systems. To fix this vulnerability, it is recommended to upgrade to the latest patched versions of node-tar. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for nodejs →

Share this vulnerability

FAQ

The npm package 'tar', or node-tar, is a tool used for extracting tar files in Node.js applications. It ensures that files outside the extraction target directory are not extracted.

Versions before 4.4.18, 5.0.10, and 6.1.9 of 'tar' are affected by this vulnerability.

This vulnerability affects Windows systems when extracting tar files with specific path configurations. It can lead to arbitrary file creation, overwrite, and code execution.

To fix this vulnerability, it is recommended to upgrade to the latest patched versions of node-tar (4.4.18, 5.0.10, or 6.1.9).

There is no feasible workaround for this issue other than using the updated versions of node-tar.

Related vulnerabilities

Recent vulnerabilities recorded for nodejs.

How To Fix

Minimum fixed version

12.22.6-r0

This is the first release that contains the fix.

sudo apk add --upgrade nodejs

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback