Arbitrary File Write Affecting tar package, versions >=6.0.0 <6.1.9>=5.0.0 <5.0.10<4.4.18


Severity

Recommended
0.0
high
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

EPSS
0.07% (34th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Arbitrary File Write vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-JS-TAR-1579155
  • published1 Sept 2021
  • disclosed1 Sept 2021
  • creditginkoid, chen-robert, JarLob

Introduced: 1 Sep 2021

CVE-2021-37713  (opens in a new tab)
CWE-22  (opens in a new tab)

How to fix?

Upgrade tar to version 6.1.9, 5.0.10, 4.4.18 or higher.

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Arbitrary File Write. node-tar aims to guarantee that any file whose location would be outside of the extraction target directory is not extracted. This is, in part, accomplished by sanitizing absolute paths of entries within the archive, skipping archive entries that contain .. path portions, and resolving the sanitized paths against the extraction target directory.

This logic is insufficient on Windows systems when extracting tar files that contain a path that is not an absolute path, but specify a drive letter different from the extraction target, such as C:some\path. If the drive letter does not match the extraction target, for example D:\extraction\dir, then the result of path.resolve(extractionDirectory, entryPath) resolves against the current working directory on the C: drive, rather than the extraction target directory.

Additionally, a .. portion of the path can occur immediately after the drive letter, such as C:../foo, and is not properly sanitized by the logic that checks for .. within the normalized and split portions of the path.

Note: This only affects users of node-tar on Windows systems.

References

CVSS Scores

version 3.1