Skip to content
OpenAdvisories
High · 8.2 CVE-2021-37713 EUVD-2021-1573GHSA-5955-9wpr-37jh

Arbitrary File Creation/Overwrite on Windows via insufficient relative path sanitization

Published Aug 31, 2021 · Updated Aug 4, 2024 · Assigned by GitHub_M

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 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 was insufficient on Windows systems when extracting tar files that contained a path that was not an absolute path, but specified 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)` would resolve against the current working directory on the `C:` drive, rather than the extraction target directory. Additionally, a `..` portion of the path could occur immediately after the drive letter, such as `C:../foo`, and was not properly sanitized by the logic that checked for `..` within the normalized and split portions of the path. This only affects users of `node-tar` on Windows systems. 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. There is no reasonable way to work around this issue without performing the same path normalization procedures that node-tar now does. Users are encouraged to upgrade to the latest patched versions of node-tar, rather than attempt to sanitize paths themselves.

Affected products

VendorProductAffectedFixed
npm node-tar < 4.4.18, >= 5.0.0, < 5.0.10, >= 6.0.0, < 6.1.9 —

Fixed in Linux distributions

Distributions backport fixes, so the version that fixes this vulnerability differs per release — upgrade to at least the version shown. From the distributions' security trackers and advisories.

ReleasePackageFixed inAdvisory
SLES 15 SP3 nodejs12 12.22.7-4.22.1 SUSE-SU-2021:3940-1
SLES 15 SP3 nodejs14 14.18.1-15.21.2 SUSE-SU-2021:3964-1
SLES 15 SP2 nodejs12 12.22.7-4.22.1 SUSE-SU-2021:3940-1
SLES 15 SP2 nodejs14 14.18.1-15.21.2 SUSE-SU-2021:3964-1
SLES 12 nodejs12 12.22.9-1.38.1 SUSE-SU-2022:0101-1
SLES 12 nodejs14 14.18.1-6.18.2 SUSE-SU-2021:3886-1
ReleasePackageFixed inAdvisory
openSUSE Tumbleweed nodejs14 14.18.1-1.1 openSUSE-SU-2024:11616-1
openSUSE Leap 15.3 nodejs12 12.22.7-4.22.1 openSUSE-SU-2021:3940-1
openSUSE Leap 15.3 nodejs14 14.18.1-15.21.2 openSUSE-SU-2021:3964-1
openSUSE Leap 15.2 nodejs12 12.22.7-lp152.3.21.1 openSUSE-SU-2021:1574-1
openSUSE Leap 15.2 nodejs14 14.18.1-lp152.17.1 openSUSE-SU-2021:1552-1
ReleasePackageFixed inAdvisory
Alpine v3.24 nodejs 14.17.6-r0 —
Alpine v3.23 nodejs 14.17.6-r0 —
Alpine v3.22 nodejs 14.17.6-r0 —
Alpine v3.21 nodejs 14.17.6-r0 —
Alpine v3.20 nodejs 14.17.6-r0 —
Show 9 more (older releases, extended support, other products)
ReleasePackageFixed inAdvisory
Alpine v3.19 nodejs 14.17.6-r0 —
Alpine v3.18 nodejs 14.17.6-r0 —
Alpine v3.17 nodejs 14.17.6-r0 —
Alpine v3.16 nodejs 14.17.6-r0 —
Alpine v3.15 nodejs 14.17.6-r0 —
Alpine v3.14 nodejs 14.17.6-r0 —
Alpine v3.13 nodejs 14.17.6-r0 —
Alpine v3.12 nodejs 12.22.6-r0 —
Alpine v3.11 nodejs 12.22.6-r0 —

Affected packages

EcosystemPackageAffectedFixedRecord
npm tar < 4.4.18 4.4.18 GHSA-5955-9wpr-37jh
npm tar >= 5.0.0, < 5.0.10 5.0.10 GHSA-5955-9wpr-37jh
npm tar >= 6.0.0, < 6.1.9 6.1.9 GHSA-5955-9wpr-37jh

Advisories 18

References