/

CVE-2025-65875

Severity:

HIGH RISK

(8.8)

Arbitrary File Upload in FPDF AddFont() Function

CVE-2025-65875

Analyzed

Vulnerability type

Category:

Arbitrary File Upload

CWE:

CWE-434

Impact:

Remote Code Execution

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

An arbitrary file upload vulnerability in the AddFont() function of FPDF v1.86 and earlier allows attackers to upload crafted PHP files to the server.

When the uploaded files are placed in a web-accessible directory and executed by the PHP interpreter, this can lead to remote code execution under the web server's privileges.

Affected context

This vulnerability appears in PHP applications that integrate FPDF v1.86 or earlier and expose functionality that ultimately calls AddFont() with user-influenced data.

It becomes especially risky when:

  • Uploaded font definition files are stored in directories served by the web server, and
  • The application or library does not enforce strict file type and extension checks, and
  • PHP code in uploaded files can be executed by the interpreter.

Not all deployments will be affected in the same way; the risk depends on how and where generated or uploaded files are stored and executed.

Exploit preconditions

  • Attack surface: Web-facing endpoints or features that invoke FPDF's AddFont() and allow users to upload or influence font files.
  • Required access: Ability to interact with the vulnerable endpoint (often unauthenticated or low-privileged authenticated access, depending on the application).
  • Trigger point: Uploading a crafted PHP file through the AddFont() workflow so that it is stored as part of the font assets.
  • Why exploitation is possible: The AddFont() handling insufficiently restricts or validates the uploaded file type, content, and extension, allowing executable PHP code to be saved in a location that can later be invoked via HTTP.

Why this happens

The underlying flaw maps to CWE-434: Unrestricted Upload of File with Dangerous Type.

The AddFont() function, as used in affected setups, does not adequately validate or sanitize user-controlled file uploads, allowing files with executable content (e.g., PHP code) to be stored on the server.

Instead of enforcing a strict allowlist of safe file types, validated extensions, and non-executable storage locations, the logic trusts the provided file, treating it as a font definition.

This trust boundary failure between user input and server-side file system operations enables attackers to plant server-side scripts that the PHP runtime can execute.

Potential impact

  • Remote execution of arbitrary PHP code on the server
  • Full compromise of the affected web application
  • Access to or modification of application data and configuration
  • Use of the compromised server as a pivot point for further network attacks
  • Installation of backdoors or web shells for persistent access
  • Defacement or manipulation of generated PDF content and related assets

General mitigation guidance

Effective mitigation generally focuses on constraining file uploads and separating executable code from user-controlled content:

  • Enforce a strict allowlist of permitted file types for any AddFont()-related uploads, validating both MIME type and file extension server-side.
  • Verify file content signatures (e.g., checking for expected font definition formats) rather than relying solely on filenames or client-side checks.
  • Store any user-controlled or dynamically generated files outside of web-accessible directories and ensure they are not interpreted as PHP or other executable code.
  • Disable script execution (e.g., via web server configuration) in directories where uploads or generated assets are stored.
  • Apply least-privilege to the web server's filesystem permissions so uploaded content cannot overwrite code or sensitive configuration.
  • Centralize and reuse hardened upload handlers instead of ad-hoc file handling logic around FPDF.

How teams detect issues like this

To detect and monitor for this class of issue, organizations can:

  • Use static application security testing (SAST) to flag calls that:
  • Write user-controlled data to the filesystem, and
  • Use FPDF AddFont() or similar APIs without strict validation or path controls.
  • Add code review checkpoints for any file upload workflows, ensuring reviewers look for:
  • Lack of content validation and extension checks
  • Storage of user files under webroot or executable directories
  • Direct use of user input in filesystem paths
  • Enable runtime application security monitoring to detect anomalous requests that:
  • Access uploaded files with .php or other executable extensions
  • Invoke newly created scripts or unusual URLs under upload directories
  • Periodically scan the webroot and upload directories for unexpected executable files using security tools or custom scripts.

Sources

SourceLink
fpdf.orgfpdf.org
advisories.gitlab.comadvisories.gitlab.com/pkg/composer/tecnickcom/tc-lib-pdf-font/CVE-2024-56520/
github.comgithub.com/Setasign/FPDF

Frequently asked

questions

Yes, in typical deployments it is remotely exploitable when an attacker can access a web endpoint that uses FPDF AddFont() with insufficient upload restrictions. The attacker does not need local server access; they interact via HTTP.

The attacker generally needs the same level of access required to reach the vulnerable feature—this may be anonymous/public access or any authenticated role that can upload or define fonts. No special system privileges are required beyond that.

The safest approach is to strictly validate and constrain all files used with AddFont(): only accept expected font definition formats, store them outside of executable directories, and ensure the web server does not interpret them as PHP or other code. Treat all user-influenced files as untrusted content and segregate them from application code.

Adopt a standard, hardened file upload framework across the application, enforce allowlists for file types, validate content rather than just filenames, and ensure that no user-controlled file is ever placed in a directory where it can be executed. Combine these practices with automated security testing and code review guidelines focused on file handling.

Find out what's already
exploitable in your codebase.