CVE-2023-38559 Overview
A buffer overflow vulnerability has been identified in Artifex Ghostscript, a widely-used interpreter for PostScript and PDF files. The flaw exists in the devn_pcx_write_rle() function located in base/gdevdevn.c at line 1973. This vulnerability allows a local attacker to trigger a denial of service condition by crafting a malicious PDF file that targets a DEVN device when processed with Ghostscript (gs).
Ghostscript is commonly used in document processing workflows, print servers, and PDF conversion utilities across enterprise environments. The buffer overflow occurs during RLE (Run-Length Encoding) compression operations when handling specially crafted input, potentially causing application crashes and service disruptions.
Critical Impact
Local attackers can cause denial of service by supplying a crafted PDF file to Ghostscript, disrupting document processing workflows and print services.
Affected Products
- Artifex Ghostscript (all versions prior to the security patch)
- Red Hat Enterprise Linux 8.0 and 9.0
- Fedora 37 and 38
- Debian Linux 10.0
Discovery Timeline
- 2023-08-01 - CVE-2023-38559 published to NVD
- 2024-11-21 - Last updated in NVD database
Technical Details for CVE-2023-38559
Vulnerability Analysis
The vulnerability resides in the devn_pcx_write_rle() function within Ghostscript's device output handling code. This function is responsible for writing PCX image data using Run-Length Encoding compression when outputting to DEVN (device-independent color) devices.
The buffer overflow condition occurs when the function processes malformed or specially crafted input data that exceeds the expected buffer boundaries. The flaw is categorized under CWE-120 (Buffer Copy without Checking Size of Input) and CWE-125 (Out-of-Bounds Read), indicating that the vulnerable code fails to properly validate input size before performing memory operations.
When exploited, this vulnerability causes the Ghostscript process to crash, resulting in denial of service. While the attack requires local access and user interaction (opening a malicious PDF), it can be leveraged to disrupt automated document processing pipelines and print servers that rely on Ghostscript.
Root Cause
The root cause stems from insufficient bounds checking in the devn_pcx_write_rle() function at line 1973 of base/gdevdevn.c. During RLE compression of PCX output data, the function does not adequately validate the size of input data against the destination buffer capacity. This allows crafted PDF input to trigger memory operations that exceed buffer boundaries, leading to memory corruption and subsequent application crash.
Attack Vector
The attack requires local access to the target system and user interaction to process a malicious PDF file. An attacker would craft a PDF document with specific content designed to trigger the vulnerable code path when Ghostscript processes the file for a DEVN device output. The attack sequence involves:
- Creating a specially crafted PDF file with malicious content targeting the PCX RLE encoding routine
- Convincing a user or automated system to process the PDF using Ghostscript with a DEVN device
- The vulnerable function attempts to write RLE-encoded data, triggering the buffer overflow
- The application crashes, causing denial of service
The vulnerability affects systems where Ghostscript is used for document conversion, print processing, or automated PDF handling workflows.
Detection Methods for CVE-2023-38559
Indicators of Compromise
- Unexpected Ghostscript (gs) process crashes during PDF processing operations
- Core dump files generated by Ghostscript with stack traces pointing to gdevdevn.c or devn_pcx_write_rle()
- Abnormal PDF files with unusual structure or embedded content targeting PCX output
- System logs showing repeated segmentation faults in Ghostscript processes
Detection Strategies
- Monitor for Ghostscript process crashes and segmentation faults in system logs
- Implement file integrity monitoring on PDF files before processing with Ghostscript
- Deploy endpoint detection rules to identify crash patterns consistent with buffer overflow exploitation
- Audit document processing workflows for unusual PDF file submissions
Monitoring Recommendations
- Enable crash reporting and core dump collection for Ghostscript processes
- Configure centralized logging to capture Ghostscript execution errors across document processing infrastructure
- Implement anomaly detection for PDF file characteristics in document upload systems
- Monitor system resource utilization patterns that may indicate repeated crash-restart cycles
How to Mitigate CVE-2023-38559
Immediate Actions Required
- Update Ghostscript to the latest patched version from your distribution's package repository
- Apply vendor security patches from Red Hat, Fedora, or Debian as applicable to your environment
- Review and restrict access to systems running Ghostscript document processing services
- Implement input validation for PDF files before processing with Ghostscript
Patch Information
The vulnerability has been addressed by Artifex in commit d81b82c70bc1. Multiple Linux distributions have released security updates:
- Red Hat Enterprise Linux: Patches available via RHSA-2023:6544 and RHSA-2023:7053
- Fedora: Updates available through standard package repositories
- Debian: Security advisory published in Debian LTS Announce August 2023
The official patch commit is available in the Ghostscript Git repository.
Workarounds
- Isolate Ghostscript processing in sandboxed environments or containers with limited system access
- Avoid processing untrusted PDF files with DEVN device outputs until patches are applied
- Implement application-level input filtering to reject potentially malicious PDF structures
- Consider using alternative PDF processing tools for critical workflows until the environment is fully patched
# Update Ghostscript on Red Hat/CentOS/RHEL systems
sudo yum update ghostscript
# Update Ghostscript on Fedora systems
sudo dnf update ghostscript
# Update Ghostscript on Debian/Ubuntu systems
sudo apt-get update && sudo apt-get upgrade ghostscript
# Verify installed Ghostscript version
gs --version
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

