Bug 1999739 (CVE-2021-37712)

Summary: CVE-2021-37712 nodejs-tar: Insufficient symlink protection due to directory cache poisoning using symbolic links allowing arbitrary file creation and overwrite
Product: [Other] Security Response Reporter: Guilherme de Almeida Suckevicz <gsuckevi>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: aileenc, amackenz, amasferr, amuller, anpicker, aos-bugs, bdettelb, bmontgom, caswilli, chazlett, drieden, eparis, erooth, etamir, extras-orphan, ggaughan, gghezzo, gmalinko, gparvin, hhorak, hvyas, janstey, jburrell, jochrist, jorton, jramanat, jwendell, jwon, kaycoth, mkudlej, nbecker, nodejs-maint, nodejs-sig, nstielau, ocs-bugs, pahickey, pdelbell, rcernich, rfreiman, spasquie, sponnaga, stcannon, tchollingsworth, thrcka, tjochec, twalsh, zsvetlik
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: nodejs-tar 4.4.18, nodejs-tar 5.0.10, nodejs-tar 6.1.9 Doc Type: If docs needed, set a value
Doc Text:
A flaw was found in the npm package "tar" (aka node-tar). Extracting tar files that contain two directories and a symlink with names containing Unicode values that normalize to the same value on Windows systems made it possible to bypass node-tar symlink checks on directories. This allows an untrusted tar file to extract and overwrite files into an arbitrary location. The highest threat from this vulnerability is to integrity and system availability.
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-02-01 22:30:51 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1999741, 1999740, 2002172, 2002173, 2002174, 2002175, 2002176, 2002177, 2002307, 2003774, 2008479, 2008480, 2008481, 2008482, 2008483, 2008484, 2029537, 2029538, 2031769, 2086777, 2086778, 2086779, 2086780, 2087162    
Bug Blocks: 1999747    

Description Guilherme de Almeida Suckevicz 2021-08-31 16:47:46 UTC
node-tar aims to guarantee that any file whose location would be modified by a symbolic link is not extracted. This is, in part, achieved by ensuring that extracted directories are not symlinks. Additionally, in order to prevent unnecessary stat calls to determine whether a given path is a directory, paths are cached when directories are created.

This logic was insufficient when extracting tar files that contained two directories and a symlink with names containing unicode values that normalized to the same value. Additionally, on Windows systems, long path portions would resolve to the same file system entities as their 8.3 "short path" counterparts. A specially crafted tar archive could thus include directories with two forms of the path that resolve to the same file system entity, followed by a symbolic link with a name in the first form, lastly followed by a file using the second form. It led to bypassing 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.

Reference:
https://github.com/npm/node-tar/security/advisories/GHSA-qq89-hq3f-393p

Comment 1 Guilherme de Almeida Suckevicz 2021-08-31 16:48:10 UTC
Created nodejs-tar tracking bugs for this issue:

Affects: epel-7 [bug 1999741]
Affects: fedora-all [bug 1999740]

Comment 16 errata-xmlrpc 2021-12-13 17:44:22 UTC
This issue has been addressed in the following products:

  Red Hat OpenShift Data Foundation 4.9.0 on RHEL-8

Via RHSA-2021:5086 https://access.redhat.com/errata/RHSA-2021:5086

Comment 18 errata-xmlrpc 2022-01-06 18:39:54 UTC
This issue has been addressed in the following products:

  Red Hat Software Collections for Red Hat Enterprise Linux 7

Via RHSA-2022:0041 https://access.redhat.com/errata/RHSA-2022:0041

Comment 20 errata-xmlrpc 2022-01-25 09:23:38 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8.4 Extended Update Support

Via RHSA-2022:0246 https://access.redhat.com/errata/RHSA-2022:0246

Comment 21 errata-xmlrpc 2022-02-01 21:14:30 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8

Via RHSA-2022:0350 https://access.redhat.com/errata/RHSA-2022:0350

Comment 22 Product Security DevOps Team 2022-02-01 22:30:47 UTC
This bug is now closed. Further updates for individual products will be reflected on the CVE page(s):

https://access.redhat.com/security/cve/cve-2021-37712

Comment 23 errata-xmlrpc 2022-06-06 09:26:42 UTC
This issue has been addressed in the following products:

  Red Hat Software Collections for Red Hat Enterprise Linux 7

Via RHSA-2022:4914 https://access.redhat.com/errata/RHSA-2022:4914