Bug 2024237 (CVE-2021-31566)

Summary: CVE-2021-31566 libarchive: symbolic links incorrectly followed when changing modes, times, ACL and flags of a file while extracting an archive
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: bdettelb, caswilli, databases-maint, dkuc, fjansen, hhorak, jburrell, jwong, kaycoth, mike, ndevos, odubaj, panovotn, pkubat, praiskup, psegedy, sbiarozk, vkumar, vmugicag
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: libarchive 3.5.2 Doc Type: If docs needed, set a value
Doc Text:
An improper link resolution flaw can occur while extracting an archive leading to changing modes, times, access control lists, and flags of a file outside of the archive. An attacker may provide a malicious archive to a victim user, who would trigger this flaw when trying to extract the archive. A local attacker may use this flaw to gain more privileges in a system.
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-03-15 15:01:34 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: 2024238, 2024239, 2026075, 2026078, 2026828, 2026829, 2028035    
Bug Blocks: 2024258    

Description Guilherme de Almeida Suckevicz 2021-11-17 16:42:34 UTC
Some modes, times, ACLs and file flags especially on directories are set on archive_write_close() time. An archive can contain multiple entries with the same path. If a directory entry is marked for post-processing and a symlink entry with the same path "replaces" the directory with the symlink, the "fixup" postprocessing may alter the link target instead of the file itself.

Reference:
https://github.com/libarchive/libarchive/issues/1566

Upstream patch:
https://github.com/libarchive/libarchive/commit/b41daecb5ccb4c8e3b2c53fd6147109fc12c3043

Comment 1 Guilherme de Almeida Suckevicz 2021-11-17 16:42:59 UTC
Created libarchive tracking bugs for this issue:

Affects: fedora-all [bug 2024238]


Created mingw-libarchive tracking bugs for this issue:

Affects: fedora-all [bug 2024239]

Comment 4 Doran Moppert 2021-11-26 04:29:17 UTC
Second upstream patch completes the fix for this issue:

https://github.com/libarchive/libarchive/commit/e2ad1a2c3064fa9eba6274b3641c4c1beed25c0b

Comment 5 Doran Moppert 2021-11-26 04:30:37 UTC
*** Bug 2024242 has been marked as a duplicate of this bug. ***

Comment 11 Honza Horak 2021-12-22 13:35:58 UTC
There is another upstream fix that seems to be related (mentions the original b41daec):
https://github.com/libarchive/libarchive/commit/8a1bd5c18e896f0411a991240ce0d772bb02c840

which seems to be problematic and was later improved with this one:
https://github.com/libarchive/libarchive/commit/ede459d2ebb879f5eedb6f7abea203be0b334230

Comment 13 errata-xmlrpc 2022-03-15 10:20:03 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8

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

Comment 14 Product Security DevOps Team 2022-03-15 15:01:31 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-31566