Path traversal in NPM Tar



Published: 2021-08-03 | Updated: 2021-11-17
Risk Medium
Patch available YES
Number of vulnerabilities 1
CVE-ID CVE-2021-32803
CWE-ID CWE-36
Exploitation vector Network
Public exploit N/A
Vulnerable software
Subscribe
tar
Web applications / JS libraries

Vendor npm Inc.

Security Bulletin

This security bulletin contains one medium risk vulnerability.

1) Absolute Path Traversal

EUVDB-ID: #VU58206

Risk: Medium

CVSSv3.1: 6.5 [CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N/E:U/RL:O/RC:C]

CVE-ID: CVE-2021-32803

CWE-ID: CWE-36 - Absolute Path Traversal

Exploit availability: No

Description

The vulnerability allows a remote attacker to overwrite arbitrary files on the system.

The vulnerability exists due to a logic issue when extracting tar files that contained both a directory and a symlink with the same name as the directory. This order of operations resulted in the directory being created and added to the node-tar directory cache. When a directory is present in the directory cache, subsequent calls to mkdir for that directory are skipped. However, this is also where node-tar checks for symlinks occur.

By first creating a directory, and then replacing that directory with a symlink, 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.

Mitigation

Install updates from vendor's website.

Vulnerable software versions

tar: 3.0.0 - 6.1.1

External links

http://github.com/npm/node-tar/security/advisories/GHSA-r628-mhmh-qjhw
http://github.com/npm/node-tar/commit/9dbdeb6df8e9dbd96fa9e84341b9d74734be6c20


Q & A

Can this vulnerability be exploited remotely?

Yes. This vulnerability can be exploited by a remote non-authenticated attacker via the Internet.

Is there known malware, which exploits this vulnerability?

No. We are not aware of malware exploiting this vulnerability.



###SIDEBAR###