Skip to main content
Vulnerability Database/CVE-2025-54869

CVE-2025-54869: FPDI PHP Library DOS Vulnerability

CVE-2025-54869 is a denial of service flaw in FPDI PHP library that allows attackers to crash servers through malicious PDF uploads. This post explains its impact, affected versions, and mitigation steps.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2025-54869 Overview

FPDI is a PHP library that reads pages from existing PDF documents and reuses them as templates in FPDF. Versions 2.6.2 and earlier contain a resource exhaustion flaw (CWE-770) triggered when the parser processes crafted PDF structures. An attacker can upload a small malicious PDF that forces the server-side script to exhaust available memory and crash. Repeated submissions produce sustained denial of service against any application that hands user-supplied PDFs to FPDI. The maintainers addressed the issue in version 2.6.3.

Critical Impact

Any web application accepting user-supplied PDFs through FPDI can be crashed with a compact, low-effort payload, leading to sustained service unavailability.

Affected Products

  • Setasign FPDI versions 2.6.2 and earlier
  • PHP applications processing untrusted PDFs via FPDI
  • FPDF-based document workflows relying on FPDI for template import

Discovery Timeline

  • 2025-08-06 - CVE CVE-2025-54869 published to the National Vulnerability Database (NVD)
  • 2026-06-17 - Last updated in NVD database

Technical Details for CVE-2025-54869

Vulnerability Analysis

The vulnerability is a denial-of-service condition caused by unbounded recursion during PDF object resolution. FPDI walks PDF object graphs to resolve indirect references and to enumerate the pages tree. When a crafted PDF contains cyclic indirect object references or a self-referencing pages dictionary, the parser follows the cycle repeatedly. Each traversal step allocates additional stack frames and object state until the PHP process exhausts its configured memory limit and terminates.

Because the malicious PDF can be small, the attack cost is asymmetric. A few kilobytes of input can consume hundreds of megabytes of server memory. On shared hosts or containerized workers, this rapidly starves other requests and can cascade into worker restarts.

Root Cause

The root cause is missing recursion tracking in two code paths: PdfType::resolve() in src/PdfParser/Type/PdfType.php and the pages-tree walker in src/PdfReader/PdfReader.php. Neither path recorded previously visited indirect object identifiers, so a reference cycle produced infinite recursion. The CWE-770 classification (Allocation of Resources Without Limits or Throttling) accurately describes the missing bound.

Attack Vector

Exploitation requires the ability to submit a PDF to an endpoint that invokes FPDI parsing. Common exposure points include invoice upload forms, document merge services, and PDF template import flows. No authentication bypass or memory corruption is involved; the attacker simply supplies a PDF whose object graph contains a cycle.

php
// Patch excerpt: src/PdfParser/Type/PdfType.php
     * @param PdfType $value
     * @param PdfParser $parser
     * @param bool $stopAtIndirectObject
+    * @param array $ensuredObjectsList A list of all ensured indirect objects to prevent recursion
     * @return PdfType
     */
-   public static function resolve(PdfType $value, PdfParser $parser, $stopAtIndirectObject = false)
-   {
+   public static function resolve(
+       PdfType $value,
+       PdfParser $parser,
+       $stopAtIndirectObject = false,
+       array &$ensuredObjectsList = []
+   ) {
+       if ($value instanceof PdfIndirectObjectReference) {
+           $value = $parser->getIndirectObject($value->value);
+       }
+
        if ($value instanceof PdfIndirectObject) {
            if ($stopAtIndirectObject === true) {
                return $value;
            }
-           return self::resolve($value->value, $parser, $stopAtIndirectObject);
-       }
-
-       if ($value instanceof PdfIndirectObjectReference) {
-           return self::resolve($parser->getIndirectObject($value->value), $parser, $stopAtIndirectObject);
// Source: https://github.com/Setasign/FPDI/commit/ba671ba9221cffd32c2dda87316c19f522a1c5f0

The fix threads an $ensuredObjectsList through resolve() and adds an $alreadyReadKids guard in the pages walker that throws PdfReaderException('Recursive pages dictionary detected.') when a cycle is encountered.

Detection Methods for CVE-2025-54869

Indicators of Compromise

  • PHP-FPM or CLI workers terminating with Allowed memory size of X bytes exhausted errors while processing PDF uploads
  • Repeated PdfReaderException or generic parser exceptions originating from FPDI classes after applying the patch
  • Small PDF uploads (under 100 KB) correlated with sudden spikes in memory consumption on application servers

Detection Strategies

  • Instrument PDF ingestion endpoints with per-request memory and CPU accounting, then alert on outliers relative to file size
  • Add a static pre-check that inspects PDF cross-reference tables for cyclic indirect references before handing content to FPDI
  • Review application logs for stack traces referencing FPDI\PdfParser\Type\PdfType::resolve occurring in rapid succession from the same source

Monitoring Recommendations

  • Track worker restart counts and out-of-memory kills on PHP application servers processing user-supplied documents
  • Correlate WAF logs of PDF uploads with backend 5xx responses to identify repeat abusive sources
  • Baseline expected PDF parse time and memory footprint, then flag deviations for investigation

How to Mitigate CVE-2025-54869

Immediate Actions Required

  • Upgrade Setasign FPDI to version 2.6.3 or later across all PHP application dependencies
  • Audit composer.lock files and CI pipelines to confirm the patched version is deployed everywhere FPDI is used
  • Enforce request-level memory limits and execution timeouts on endpoints that accept PDF uploads

Patch Information

The fix is delivered in FPDI 2.6.3 via commit ba671ba. See the GitHub Security Advisory GHSA-jxhh-4648-vpp3 for the maintainer's disclosure. Update the dependency with composer require setasign/fpdi:^2.6.3 and redeploy affected services.

Workarounds

  • Restrict PDF upload size and require authentication on ingestion endpoints to reduce exposure
  • Isolate PDF parsing in short-lived worker processes with hard memory ceilings so a crash does not affect other requests
  • Add a pre-parse validator that rejects PDFs containing self-referential object trees before invoking FPDI
bash
# Update FPDI to the patched release
composer require setasign/fpdi:^2.6.3
composer update setasign/fpdi

# Constrain PHP memory for PDF-processing workers (php.ini)
memory_limit = 128M
max_execution_time = 30

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.