Bug 2234387 (CVE-2023-5189)

Summary: CVE-2023-5189 Ansible Automation Hub: insecure galaxy-importer tarfile extraction
Product: [Other] Security Response Reporter: Mauro Matteo Cascella <mcascell>
Component: vulnerabilityAssignee: Product Security <prodsec-ir-bot>
Status: NEW --- QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: adudiak, bbuckingham, bcourt, carnil, davidn, ehelms, epacific, jbreitwe, jcammara, jhardy, jneedle, jobarker, jsherril, kshier, lzap, mabashia, mhulan, nmoumoul, orabin, osapryki, pcreech, rchan, security-response-team, simaishi, sivel, smcdonal, stcannon, teagle, tfister, vinair, yguenane, zsadeh
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
A path traversal vulnerability exists in Ansible when extracting tarballs. An attacker could craft a malicious tarball so that when using the galaxy importer of Ansible Automation Hub, a symlink could be dropped on the disk, resulting in files being overwritten.
Story Points: ---
Clone Of: Environment:
Last Closed: 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: 2234389, 2260392    
Bug Blocks: 2234388    

Description Mauro Matteo Cascella 2023-08-24 09:23:04 UTC
A vulnerability was found in the galaxy importer of Ansible Automation Hub. The tarball extraction code is open to abuse in several ways (relative paths in the middle of a path, as well as symlinks that target arbitrary paths). If used to extract user-provided tarballs, this flaw could lead to arbitrary file overwrite.

Comment 2 Salvatore Bonaccorso 2023-11-05 19:51:19 UTC
Are there any details you can share about this issue? Is there an upstream report about it? Is an upstream fix known?

Comment 3 Mauro Matteo Cascella 2023-11-06 09:09:32 UTC
Redirecting NEEDINFO to Vipul who worked on this CVE and should be able to shed some light on it. As far as I know, the affected code can be found in _extract_archive() in galaxy-importer/collection.py. I do not know if there is a patch or any upstream discussions about it, though.

Comment 4 Vipul Nair 2023-11-14 17:00:58 UTC
The affected code can be found at https://github.com/ansible/galaxy-importer/blob/2c5c7c05fdfb0835878234b36de32902c703616d/galaxy_importer/collection.py#L160-L165

It does not protect against `..` in the middle of paths, nor does it protect against directory traversals in `linkname` only `name`.

Comment 5 Salvatore Bonaccorso 2023-11-20 06:24:45 UTC
Thanks

Comment 7 errata-xmlrpc 2023-12-13 08:32:21 UTC
This issue has been addressed in the following products:

  Red Hat Ansible Automation Platform 2.4 for RHEL 8
  Red Hat Ansible Automation Platform 2.4 for RHEL 9

Via RHSA-2023:7773 https://access.redhat.com/errata/RHSA-2023:7773

Comment 8 errata-xmlrpc 2024-03-27 13:18:48 UTC
This issue has been addressed in the following products:

  Red Hat Satellite 6.14 for RHEL 8

Via RHSA-2024:1536 https://access.redhat.com/errata/RHSA-2024:1536

Comment 9 errata-xmlrpc 2024-04-23 17:14:10 UTC
This issue has been addressed in the following products:

  Red Hat Satellite 6.15 for RHEL 8

Via RHSA-2024:2010 https://access.redhat.com/errata/RHSA-2024:2010