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

CVE-2025-26240: Python-pdfkit RCE Vulnerability

CVE-2025-26240 is a remote code execution vulnerability in python-pdfkit 1.0.0 that allows JavaScript execution and local file exfiltration. This post covers technical details, affected versions, security impact, and mitigation.

Published:

CVE-2025-26240 Overview

CVE-2025-26240 affects JazzCore python-pdfkit version 1.0.0, a popular Python wrapper around wkhtmltopdf used to render HTML into PDF documents. The from_string method processes attacker-controlled HTML without restricting embedded JavaScript or local file access. An attacker who can supply input to from_string can execute JavaScript inside the rendering context and read local files from the host running the server application. The flaw maps to [CWE-120] and impacts confidentiality, integrity, and availability of the host process.

Critical Impact

Attackers can execute arbitrary JavaScript inside the PDF rendering context and exfiltrate local files from servers using python-pdfkit 1.0.0 to render untrusted HTML.

Affected Products

  • JazzCore python-pdfkit 1.0.0
  • Applications invoking pdfkit.from_string() on user-controlled HTML
  • Server-side PDF generation pipelines built on wkhtmltopdf via python-pdfkit

Discovery Timeline

  • 2026-06-17 - CVE-2025-26240 published to NVD
  • 2026-06-17 - Last updated in NVD database

Technical Details for CVE-2025-26240

Vulnerability Analysis

The python-pdfkit library wraps the wkhtmltopdf binary to convert HTML strings, files, or URLs into PDF files. The from_string entry point passes caller-supplied HTML directly to the underlying renderer without disabling JavaScript execution or restricting local resource loading. As a result, HTML containing <script> blocks executes in the rendering process, and references such as <iframe src="file:///etc/passwd"> resolve against the server's filesystem.

An attacker who controls any portion of the HTML payload can read sensitive files, including configuration files, private keys, and application secrets, then embed their contents into the generated PDF or transmit them to an external endpoint via XMLHttpRequest or fetch. The vulnerability is classified [CWE-120] and carries a local attack vector with high impact on confidentiality, integrity, and availability.

Root Cause

The root cause is insecure default configuration in the HTML-to-PDF conversion path. python-pdfkit does not enforce options such as --disable-javascript or --disable-local-file-access when invoking wkhtmltopdf. Calls to from_string therefore render attacker-supplied markup with full scripting and filesystem access enabled by default.

Attack Vector

Exploitation requires that an application pass attacker-influenced HTML into pdfkit.from_string. Typical scenarios include invoice generators, report builders, and templated document services that accept user input such as names, addresses, comments, or rich-text fields. The attacker injects an HTML payload containing JavaScript that reads local files using file:// URIs or XMLHttpRequest, then exfiltrates the data through embedded links, image requests, or hidden form posts. Refer to Habuon's CVE-2025-26240 Analysis and the CSIRT Python PDFKit Vulnerability Report for proof-of-concept details.

Detection Methods for CVE-2025-26240

Indicators of Compromise

  • Outbound HTTP requests originating from the wkhtmltopdf process to unexpected destinations during PDF generation.
  • Generated PDF files containing references to local paths such as /etc/passwd, /proc/self/environ, or application configuration files.
  • Process telemetry showing wkhtmltopdf reading files outside the application working directory.
  • HTML payloads submitted to PDF endpoints that contain <script>, file://, or XMLHttpRequest constructs.

Detection Strategies

  • Inspect application logs for HTML inputs to pdfkit.from_string containing script tags, file:// URIs, or remote src attributes.
  • Monitor wkhtmltopdf child processes for file reads outside expected directories using endpoint telemetry.
  • Deploy application-layer filters that reject HTML containing scripting or local resource references before invoking the PDF pipeline.

Monitoring Recommendations

  • Capture process execution events for wkhtmltopdf and alert on command lines lacking --disable-javascript and --disable-local-file-access.
  • Track egress connections from PDF rendering hosts and baseline expected destinations.
  • Audit dependency manifests (requirements.txt, poetry.lock) for python-pdfkit==1.0.0 across the estate.

How to Mitigate CVE-2025-26240

Immediate Actions Required

  • Identify all services using python-pdfkit 1.0.0 and inventory code paths that call from_string with user-influenced input.
  • Pass explicit wkhtmltopdf options that disable JavaScript and local file access on every conversion call.
  • Sanitize or strictly allowlist HTML submitted to PDF generation endpoints, stripping <script>, <iframe>, and file:// references.
  • Isolate PDF rendering in a sandboxed container or restricted user account without access to sensitive files or network egress.

Patch Information

No vendor patch is referenced in the NVD entry at publication time. Consult the project repository and the CSIRT Python PDFKit Vulnerability Report for fixed releases or maintained forks. Until a patched version is available, apply the configuration-level mitigations described below.

Workarounds

  • Invoke wkhtmltopdf with --disable-javascript and --disable-local-file-access through the options parameter of pdfkit.from_string.
  • Render PDFs inside a network-isolated container with read-only access only to required template files.
  • Replace from_string with from_file using server-controlled templates and inject user data through a templating engine that performs HTML escaping.
bash
# Configuration example: enforce safe wkhtmltopdf options in Python
python - <<'EOF'
import pdfkit

options = {
    "disable-javascript": "",
    "disable-local-file-access": "",
    "load-error-handling": "ignore",
}

pdfkit.from_string(user_html, "output.pdf", options=options)
EOF

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

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

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.