Bug 2293959 (CVE-2024-33870)

Summary: CVE-2024-33870 ghostscript: path traversal to arbitrary files if the current directory is in the permitted paths
Product: [Other] Security Response Reporter: Robb Gatica <rgatica>
Component: vulnerabilityAssignee: Product Security <prodsec-ir-bot>
Status: NEW --- QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedKeywords: Security
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: ghostscript 10.03.1 Doc Type: ---
Doc Text:
A flaw was found in Ghostscript. When the `gp_validate_path_len` function validates a path, it distinguishes between absolute and relative paths. In the case of relative paths, it will check the path with and without the current-directory-prefix ("foo" and "./foo"). This does not take into account paths with a parent-directory-prefix. Therefore, a path like "../../foo" is also tested as "./../../foo" and if the current directory "./" is in the permitted paths, it will pass the check, which may allow arbitrary file access.
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: 2293960    
Bug Blocks: 2278776    

Description Robb Gatica 2024-06-24 16:06:23 UTC
When the `gp_validate_path_len` function validates a path, it distinguishes between absolute and relative paths. In the case of relative paths, it will check the path with and without the current-directory-prefix ("foo" and "./foo").

The problem is that it doesn't take into account paths with a parent-directory-prefix. So a path like "../../foo" is also tested as "./../../foo" and if the current directory "./" is in the permitted paths, it will pass the check and you can access arbitrary files.

References:
ttps://ghostscript.readthedocs.io/en/gs10.03.1/News.html
https://bugs.ghostscript.com/show_bug.cgi?id=707686

Upstream commit:
https://cgit.ghostscript.com/cgi-bin/cgit.cgi/ghostpdl.git/commit/?id=79aef19c685984dc3da2dc090450407d9fbcff80

Comment 1 Robb Gatica 2024-06-24 16:08:11 UTC
Created ghostscript tracking bugs for this issue:

Affects: fedora-all [bug 2293960]

Comment 3 errata-xmlrpc 2024-09-03 10:24:57 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 9

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

Comment 4 errata-xmlrpc 2024-09-09 01:31:32 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 9.2 Extended Update Support

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