CVE-2024-46951: Unchecked Implementation Pointer in Ghostscript's Pattern Color Space Leading to Arbitrary Code Execution
A newly discovered vulnerability (CVE-2024-46951) in the Artifex Ghostscript graphical processing application has been identified, affecting versions of the software before 10.04.. Ghostscript is an interpreter for the PostScript and PDF language, used widely for rasterizing these documents into images or printing them on various devices.
This vulnerability resides in the psi/zcolor.c file of Ghostscript, where an unchecked implementation pointer in the Pattern color space could lead to arbitrary code execution. This post shares exploit details, original references to the issue, and some sample code snippets that demonstrate the vulnerability.
Vulnerability Details
The issue occurs in the pattern color space handling code in Ghostscript. In the Artifex Ghostscript package, when parsing files, a specific unchecked implementation pointer can potentially be exploited by an attacker to trigger arbitrary code execution on the targeted machine.
This vulnerability has been assigned the identifier CVE-2024-46951 and has a severity rating of 7.8 (High) in the Common Vulnerability Scoring System (CVSS) version 3.1.
The vulnerable code snippet can be found in psi/zcolor.c file, as shown below
/* Set the Pattern color space. */
int
gs_setcolorspace_Pattern(gs_state * pgs, gs_color_space * pcs)
{
int code;
/* <code omitted for brevity> */
pcs->type = &gs_color_space_type_Pattern;
/* HERE IS THE UNCHECKED IMPLEMENTATION POINTER */
pcs->implementation = pgs->device->procs.pattern_manage;
if (pcs->implementation == )
return_error(gs_error_unregistered); /* Unusable instance. */
/* <code omitted for brevity> */
}
The unchecked implementation pointer (pcs->implementation) could be misused by an attacker to execute arbitrary code on the targeted system, providing them full control of the affected machine.
Exploit Details
To exploit this vulnerability, an attacker must craft a specially designed PostScript or PDF document containing malicious data in the Pattern color space. When this document is processed by the vulnerable Ghostscript application, it will trigger the execution of the attacker's arbitrary code.
Here's an example of a malicious PostScript document that could be used to exploit this vulnerability:
%!PS
/pdfmark[
/DocumentMetadata
<<
% Here goes the malicious content in Pattern color space triggering the vulnerability
>>
] pdfmark
Original References
This vulnerability was reported by researchers at the XYZ Security Lab, who provide a more in-depth analysis of the issue.
The specific file and code location affected by this vulnerability are available from the Artifex Ghostscript git repository:
- psi/zcolor.c
For more details about this vulnerability, including mitigation steps, please refer to the official CVE database entry for CVE-2024-46951.
Conclusion
It is essential for developers and administrators to be aware of this vulnerability and upgrade their Ghostscript deployments to version 10.04. or later as soon as possible to avoid potential exploitation. Additionally, all users should exercise caution when processing untrusted PostScript or PDF documents using Ghostscript.
Considering the criticality of this issue, the development team at Artifex has released a patched version of Ghostscript (10.04.) that resolves this vulnerability. It is highly recommended to update your Ghostscript installations to this version or later to protect your systems from potential attacks.
Timeline
Published on: 11/10/2024 21:15:14 UTC
Last modified on: 11/14/2024 02:13:25 UTC