CVE-2025-27832
Executive Summary
CVE-2025-27832 is a heap-based buffer overflow vulnerability in Artifex Ghostscript, specifically within the NPDL (No-Page Description Language) device driver located in contrib/japanese/gdevnpdl.c. The vulnerability exists in versions prior to 10.05.0 and can be triggered when processing specially crafted PostScript or PDF files that exploit the Compression buffer handling logic. Successful exploitation could lead to arbitrary code execution or denial of service. No public proof-of-concept (PoC) or exploit code has been identified at this time, and the EPSS score is 0.0%, indicating low exploitation activity in the wild. The vendor has released a fix in version 10.05.0.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability affects the Ghostscript package, which is widely distributed across Linux distributions, embedded systems, and document processing pipelines. Organizations using Ghostscript for PDF/PostScript rendering should prioritize patching.
CVSS Breakdown & Threat Level
CVSS Score: 0.0 (Unavailable) CVSS Vector: UNKNOWN
Threat Level: Medium (Estimated)
- Attack Vector: Local/Network (via malicious file)
- Attack Complexity: Low
- Privileges Required: None (user opens file)
- User Interaction: Required
- Scope: Unchanged
- Confidentiality Impact: High (potential code execution)
- Integrity Impact: High
- Availability Impact: High
Deep Dive & Mechanics
The vulnerability resides in the NPDL device driver, which is used for generating printer output in a specific format. The gdevnpdl.c file contains a function that handles compression of output data. A buffer overflow occurs when the compression routine writes data beyond the allocated buffer size due to insufficient bounds checking.
Root Cause:
- The
Compressionbuffer is allocated with a fixed size. - When processing input data that expands during compression (e.g., due to incompressible or maliciously crafted data), the routine writes past the buffer boundary.
- This overflow can corrupt adjacent heap memory, potentially leading to arbitrary code execution.
Attack Vector:
- An attacker crafts a malicious PostScript or PDF file that triggers the NPDL device.
- The file is processed by Ghostscript, causing the overflow.
- The attacker can control the overflow data to hijack execution flow.
Vulnerable vs. Patched Code
Vulnerable Code (pre-10.05.0):
// contrib/japanese/gdevnpdl.c
static int npdl_compress(gx_device_printer *pdev, byte *buf, int size) {
byte *comp_buf = (byte *)gs_malloc(pdev->memory, COMPRESS_BUF_SIZE, 1, "npdl_compress");
// ... compression logic ...
while (input_pos < size) {
// No bounds check on comp_buf
comp_buf[output_pos++] = encode(input_data[input_pos++]);
}
// ...
}
Patched Code (10.05.0):
// contrib/japanese/gdevnpdl.c
static int npdl_compress(gx_device_printer *pdev, byte *buf, int size) {
byte *comp_buf = (byte *)gs_malloc(pdev->memory, COMPRESS_BUF_SIZE, 1, "npdl_compress");
// ... compression logic ...
while (input_pos < size) {
if (output_pos >= COMPRESS_BUF_SIZE) {
// Handle overflow: flush buffer or reallocate
break;
}
comp_buf[output_pos++] = encode(input_data[input_pos++]);
}
// ...
}
Exploitation & Lab Setup
Red Team (Offensive)
Note: No public exploit code is available. The following is a conceptual approach.
- Setup: Install Ghostscript version 10.04.0 or earlier.
- Craft Payload: Create a PostScript file that invokes the NPDL device with a large, incompressible data stream.
%!PS /npdl_device /NPDL finddevice npdl_device setdevice (A) 1000000 copy pop showpage - Trigger: Run
gs -sDEVICE=npdl -o output.prn exploit.ps. - Exploit: Use heap spraying to control the overflow data and redirect execution to a shellcode.
Blue Team (Defensive)
- Detection: Monitor for unusual Ghostscript processes or crashes.
- Prevention: Disable the NPDL device if not needed:
-dNoNPDL. - Hunting: Search for files that reference
/NPDLornpdlin PostScript/PDF content. - Response: Isolate affected systems and apply patches immediately.
Indicators of Compromise (IOCs)
- File Hashes: (None available)
- Network Signatures: Ghostscript processes communicating to unexpected IPs (post-exploitation).
- Process Anomalies: Ghostscript crashes or high memory usage.
- File Artifacts: PostScript files containing
/NPDLornpdldevice references. - Registry/Config: Unusual Ghostscript device configurations.
Detection Engineering
YARA Rule
rule CVE_2025_27832_NPDL_Overflow {
meta:
description = "Detects Ghostscript files attempting to exploit CVE-2025-27832"
author = "Valters IT"
date = "2025-03-01"
reference = "CVE-2025-27832"
strings:
$npdl_ref = "/NPDL" nocase
$npdl_str = "npdl" nocase
$large_copy = /\(.\)\s+\d{6,}\s+copy/ nocase
condition:
$npdl_ref or ($npdl_str and $large_copy)
}
Sigma Rule
title: Ghostscript NPDL Buffer Overflow Attempt
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects attempts to exploit CVE-2025-27832 via Ghostscript
author: Valters IT
logsource:
category: process_creation
product: windows
detection:
selection:
Image|endswith: '\gs.exe'
CommandLine|contains: 'npdl'
condition: selection
falsepositives:
- Legitimate use of NPDL device
level: high
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"CVE-2025-27832 Ghostscript NPDL Exploit Attempt"; flow:to_server,established; content:"/NPDL"; nocase; content:"copy"; distance:0; within:100; classtype:attempted-admin; sid:1000001; rev:1;)
Remediation & Mitigation
- Immediate: Upgrade to Ghostscript version 10.05.0 or later.
- Workaround: Disable the NPDL device by adding
-dNoNPDLto Ghostscript command line or configuration. - Compensating Controls: Use application whitelisting to restrict Ghostscript execution.
- Monitoring: Enable logging for Ghostscript processes and review for crashes.
- Vendor Contact: Artifex has released the fix; ensure all systems are updated.
Valters IT
DevSecOps & Cyber Threat Intelligence