CVE-2025-27833
Executive Summary
CVE-2025-27833 is a heap-based buffer overflow vulnerability in Artifex Ghostscript, a widely used interpreter for the PostScript language and PDF file format. The flaw resides in the pdf/pdf_fmap.c file and is triggered when processing a PDF containing an overly long TrueType Font (TTF) name. An attacker can craft a malicious PDF file that, when processed by a vulnerable Ghostscript instance, causes a buffer overflow. This can lead to arbitrary code execution in the context of the application using Ghostscript, potentially allowing for system compromise, data exfiltration, or denial of service. The vulnerability affects all versions of Ghostscript prior to 10.05.0. No public proof-of-concept (PoC) or exploit code has been released at this time, and the EPSS score is 0.0%, indicating a low probability of exploitation in the wild currently.
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
Ghostscript is a critical dependency in many Linux distributions, document management systems, and print servers. It is often used by web applications (e.g., ImageMagick, LibreOffice) to process PDFs and images. A compromise of Ghostscript can lead to a supply chain attack, where a malicious PDF processed by an upstream service can compromise downstream systems. Organizations should audit their software bill of materials (SBOM) for Ghostscript versions below 10.05.0 and prioritize patching.
CVSS Breakdown & Threat Level
The CVSS score is listed as 0.0, which is likely a placeholder. Based on the vulnerability type (buffer overflow in a network-accessible service), a reasonable CVSS v3.1 vector would be:
- Attack Vector (AV): Network (AV:N) – The vulnerability can be triggered by processing a malicious PDF file, which can be delivered over a network.
- Attack Complexity (AC): Low (AC:L) – No special conditions are required beyond processing the file.
- Privileges Required (PR): None (PR:N) – An unauthenticated attacker can deliver the file.
- User Interaction (UI): Required (UI:R) – A user or automated system must open/process the PDF.
- Scope (S): Unchanged (S:U) – The vulnerable component is the Ghostscript process itself.
- Confidentiality (C): High (C:H) – Code execution can lead to data theft.
- Integrity (I): High (I:H) – Code execution can modify data.
- Availability (A): High (A:H) – Code execution can crash the service or system.
Estimated CVSS Score: 7.8 (High)
Threat Level: High. While no public exploit exists, the vulnerability is in a critical component and can be weaponized.
Deep Dive & Mechanics
The vulnerability is a classic heap-based buffer overflow in the pdf/pdf_fmap.c file of Ghostscript. When Ghostscript processes a PDF file, it parses embedded fonts. Specifically, for TrueType fonts, it reads the font name from the PDF's font dictionary. The code in pdf_fmap.c copies this font name into a fixed-size buffer on the heap without proper bounds checking.
Root Cause: The function responsible for handling TTF font names uses a static buffer size (e.g., 256 bytes) but does not validate the length of the font name string from the PDF. An attacker can embed a font name longer than the buffer, causing a heap overflow.
Attack Vector:
- An attacker creates a PDF file with a font dictionary containing a TTF font name that exceeds the expected buffer size.
- The victim (or automated service) opens the PDF with a vulnerable Ghostscript version.
- Ghostscript parses the PDF, reaches the font name, and copies it into the heap buffer.
- The overflow corrupts adjacent heap metadata or other data structures.
- The attacker can control the overflow data to overwrite function pointers or other critical data, leading to arbitrary code execution.
Impact:
- Code Execution: The attacker can execute arbitrary commands with the privileges of the Ghostscript process.
- Denial of Service: The overflow can cause a crash.
- Data Exfiltration: If Ghostscript is used in a web service (e.g., PDF conversion), the attacker can read files from the server.
Vulnerable vs. Patched Code
The vulnerable code is in pdf/pdf_fmap.c. The exact vulnerable function is not publicly disclosed, but the fix involves adding a length check before copying the font name.
Vulnerable Code (Conceptual):
char font_name[256];
// No length check
strcpy(font_name, pdf_font_name_from_dict);
Patched Code (Conceptual):
char font_name[256];
size_t name_len = strlen(pdf_font_name_from_dict);
if (name_len >= sizeof(font_name)) {
// Handle error, truncate, or reject
return_error("Font name too long");
}
strcpy(font_name, pdf_font_name_from_dict);
The patch ensures that the font name length is checked against the buffer size before copying, preventing the overflow.
Exploitation & Lab Setup
Red Team (Exploitation)
Prerequisites:
- A vulnerable Ghostscript version (< 10.05.0) installed.
- A target that processes PDFs (e.g., a web application using ImageMagick or a print server).
Exploitation Steps:
- Craft a Malicious PDF: Use a tool like
pdf-parser.pyor a hex editor to create a PDF with a font dictionary containing an overly long TTF font name. The overflow data should be crafted to overwrite a function pointer (e.g., a vtable pointer) with the address of a shellcode or a ROP chain. - Deliver the PDF: Send the PDF to the target via email, upload, or direct network transfer.
- Trigger the Overflow: The target processes the PDF, triggering the overflow.
- Achieve Code Execution: The overflow overwrites a critical pointer, redirecting execution to attacker-controlled code.
Example Payload Structure (Conceptual):
[PDF Header]
[Font Dictionary]
/FontName (AAAA...AAAA[overflow data])
[Rest of PDF]
Note: No public exploit code is available. This is a theoretical exploitation path.
Blue Team (Defense)
Detection:
- Monitor for PDF files with unusually long font names (e.g., > 256 characters).
- Use file integrity monitoring to detect changes to Ghostscript binaries.
- Deploy network detection rules (see Suricata below).
Prevention:
- Patch Immediately: Upgrade to Ghostscript 10.05.0 or later.
- Input Validation: If using Ghostscript in a web service, validate PDFs before processing (e.g., reject PDFs with font names exceeding a reasonable length).
- Sandboxing: Run Ghostscript in a sandboxed environment (e.g., Docker container with limited privileges, seccomp profiles).
- Disable Unnecessary Features: If possible, disable font processing or use a safer alternative like
pdfinfowith limited capabilities.
Indicators of Compromise (IOCs)
- File Hashes: (None available yet, but monitor for PDFs with suspicious font names)
- Network Traffic: PDF files with font names > 256 bytes.
- Process Behavior: Ghostscript process crashes or exhibits abnormal memory access patterns.
- Logs: Error messages related to font parsing in Ghostscript logs (e.g., "Font name too long" if patched, or crashes).
- YARA Rule: (See Detection Engineering)
Detection Engineering
YARA Rule
rule CVE_2025_27833_Ghostscript_TTF_Overflow {
meta:
description = "Detects PDF files with overly long TTF font names indicative of CVE-2025-27833"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2025-27833"
strings:
$font_name = /\/FontName\s*\([^)]{257,}\)/ nocase
$ttf_marker = /\/Subtype\s*\/TrueType/ nocase
condition:
$font_name and $ttf_marker
}
Sigma Rule
title: CVE-2025-27833 Ghostscript TTF Font Name Overflow
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects Ghostscript crashes or errors related to long TTF font names
author: Valters IT
date: 2025-04-10
logsource:
product: linux
service: syslog
detection:
selection:
- "Ghostscript: Error: /undefined in --run--"
- "Ghostscript: Fatal error: "
- "Segmentation fault (core dumped)"
condition: selection
falsepositives:
- Legitimate PDFs with very long font names (rare)
level: high
Suricata Rule
alert tcp $EXTERNAL_NET any -> $HOME_NET any (msg:"CVE-2025-27833 Ghostscript TTF Font Name Overflow Attempt"; flow:to_server,established; content:"/FontName"; nocase; content:"/TrueType"; nocase; pcre:"/\/FontName\s*\([^)]{257,}\)/"; classtype:attempted-admin; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Patch: Upgrade Ghostscript to version 10.05.0 or later. This is the only complete fix.
- Workaround: If patching is not immediately possible, restrict access to Ghostscript and avoid processing untrusted PDF files.
- Monitor: Implement the detection rules above to identify exploitation attempts.
Long-Term Mitigations:
- Least Privilege: Run Ghostscript with minimal user privileges.
- Application Sandboxing: Use containers (Docker) with read-only root filesystems and no network access.
- Web Application Firewall (WAF): If Ghostscript is used behind a web service, deploy a WAF to inspect uploaded PDFs for suspicious font names.
- Regular Audits: Keep Ghostscript and all dependencies up to date.
Valters IT
Securing your digital infrastructure, one CVE at a time.