CVE-2024-4141
Executive Summary
CVE-2024-4141 is a low-severity (CVSS 2.9) out-of-bounds array write vulnerability in Xpdf versions 4.05 and earlier. The flaw is triggered by an invalid character code in a Type 1 font, where a bounds check is optimized away by modern compilers, leading to a potential denial of service (application crash). No public exploit code or proof-of-concept is currently available, and the vendor has not released a patch. The vulnerability is not related to any WordPress plugin or component; it is a standalone PDF viewer issue.
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 does not affect NPM, PyPI, Go, or Ruby packages. Xpdf is a standalone C++ application distributed via source code and binary packages for Linux and other Unix-like systems.
CVSS Breakdown & Threat Level
- CVSS Vector: CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:L
- Base Score: 2.9 (Low)
- Attack Vector: Local (AV:L) – requires the victim to open a malicious PDF file.
- Attack Complexity: Low (AC:L) – no special conditions needed.
- Privileges Required: None (PR:N)
- User Interaction: Required (UI:R) – victim must open the file.
- Scope: Unchanged (S:U)
- Confidentiality Impact: None (C:N)
- Integrity Impact: None (I:N)
- Availability Impact: Low (A:L) – application crash, no data corruption.
Threat Level: Low. Exploitation is difficult due to user interaction requirements and the lack of public exploit code. The primary risk is denial of service.
Deep Dive & Mechanics
The vulnerability resides in Xpdf’s handling of Type 1 fonts. When parsing a PDF file, Xpdf processes character codes to map glyphs. An invalid character code (e.g., a value outside the expected range) triggers an out-of-bounds write to an array. The root cause is a bounds check that modern compilers (e.g., GCC, Clang) optimize away because they assume the code path is unreachable based on static analysis. This is a classic example of undefined behavior in C++ where the compiler’s optimization removes a safety check.
Technical Details:
- The vulnerable code is in
FontInfo.ccor similar font handling routines. - The array write occurs when the character code is used as an index without proper validation.
- The compiler sees that the index is derived from a value that “should” be valid and removes the bounds check.
- An attacker can craft a PDF with a Type 1 font containing an invalid character code to trigger the write.
Impact: The out-of-bounds write can corrupt memory, leading to a crash. In theory, it could be leveraged for code execution, but no such exploit has been demonstrated.
Vulnerable vs. Patched Code
No official patch has been released. The following is a conceptual fix:
Vulnerable Code (Xpdf 4.05):
// In FontInfo.cc or similar
void FontInfo::setCharCode(int charCode, int glyphIndex) {
// Bounds check that may be optimized away
if (charCode < 0 || charCode >= maxCharCodes) {
// This check is removed by compiler optimization
return;
}
charCodeToGlyph[charCode] = glyphIndex; // Out-of-bounds write
}
Patched Code (Conceptual):
void FontInfo::setCharCode(int charCode, int glyphIndex) {
// Use volatile to prevent optimization
volatile int safeCharCode = charCode;
if (safeCharCode < 0 || safeCharCode >= maxCharCodes) {
return;
}
charCodeToGlyph[safeCharCode] = glyphIndex;
}
Alternatively, use a compiler barrier or disable optimization for this function.
Exploitation & Lab Setup
Red Team (Attack Simulation)
Prerequisites:
- Xpdf 4.05 or earlier installed on a Linux system.
- Ability to craft a malicious PDF with a Type 1 font containing an invalid character code.
Steps:
- Create a PDF with a Type 1 font using a tool like
pdftkor a hex editor. - Modify the font’s character code mapping to include a value > 255 (e.g., 0x100).
- Open the PDF with Xpdf:
xpdf malicious.pdf - Observe the crash (segmentation fault).
No public exploit code is available.
Blue Team (Defense & Detection)
Detection:
- Monitor for crashes of
xpdforpdftotextprocesses. - Use file integrity monitoring to detect malicious PDFs.
- Deploy endpoint detection and response (EDR) rules for out-of-bounds memory access.
Mitigation:
- Disable Xpdf or restrict its use.
- Use alternative PDF viewers (e.g., Evince, Okular).
- Apply compiler flags to prevent optimization of bounds checks (e.g.,
-fno-strict-overflow).
Indicators of Compromise (IOCs)
- File Hashes: No known malicious samples.
- Process Anomalies:
xpdforpdftotextcrashes with SIGSEGV. - Network: None (local vulnerability).
- Logs: System logs showing segmentation faults in Xpdf processes.
Detection Engineering
YARA Rule
rule CVE_2024_4141_Xpdf_Type1_Font {
meta:
description = "Detects PDF files exploiting CVE-2024-4141 via invalid Type 1 font character codes"
author = "Valters IT"
date = "2025-04-14"
reference = "https://nvd.nist.gov/vuln/detail/CVE-2024-4141"
strings:
$type1_font = "/Type1" nocase
$char_code = /\/CharCode\s+\d+/ nocase
$invalid_range = /\/CharCode\s+(256|257|258|259|260)/ nocase
condition:
$type1_font and $char_code and $invalid_range
}
Sigma Rule
title: Xpdf CVE-2024-4141 Exploitation Attempt
id: 8a9b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d
status: experimental
description: Detects crashes of Xpdf processes due to out-of-bounds write in Type 1 font handling
author: Valters IT
date: 2025-04-14
logsource:
category: process_creation
product: linux
detection:
selection:
Image|endswith: '/xpdf'
CommandLine|contains: '.pdf'
condition: selection
falsepositives:
- Legitimate PDF files with complex fonts
level: low
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"CVE-2024-4141 Xpdf Type 1 Font Exploit Attempt"; flow:to_server,established; content:"/Type1"; nocase; content:"/CharCode"; distance:0; within:100; pcre:"/\/CharCode\s+(25[6-9]|2[6-9]\d|[3-9]\d{2}|\d{4,})/"; classtype:attempted-dos; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Disable Xpdf or restrict its use to trusted PDFs only.
- Use alternative PDF viewers such as Evince, Okular, or MuPDF.
- Apply compiler workarounds if building from source: compile with
-fno-strict-overflowand-O0to prevent optimization of bounds checks.
Long-Term Fix:
- Await an official patch from Xpdf maintainers.
- Monitor the Xpdf website (https://www.xpdfreader.com/) for updates.
- Consider migrating to a more actively maintained PDF library.
No patch is currently available.
Valters IT
What is this? Security researchers use these exact search queries on Shodan.io (a search engine for internet-connected devices) to find vulnerable systems globally. You can copy these dorks to see if your organization's IP space is exposed.