/

CVE-2026-25636

Severity:

HIGH RISK

(8.2)

Path Traversal in Calibre EPUB Conversion CipherReference

CVE-2026-25636

Analyzed

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22, CWE-73, CWE-94

Impact:

Arbitrary File Corruption / Overwrite in Local Context

Severity:

HIGH RISK

(8.2)

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

A path traversal vulnerability in Calibre's EPUB conversion pipeline allows a crafted EPUB to reference files outside the temporary extraction directory via CipherReference URIs in META-INF/encryption.xml.

When exploited, this can cause Calibre to open and corrupt arbitrary files writable by the Calibre process, potentially damaging user data or application state during conversion.

Affected context

The issue occurs in Calibre when processing EPUB files for conversion in versions 9.1.0 and earlier.

Specifically, it impacts environments where:

  • Users import or convert EPUB files obtained from untrusted or semi-trusted sources.
  • The Calibre process has write access to sensitive files (such as user documents, configuration files, or shared libraries) on the same system.
  • The EPUB contains a crafted META-INF/encryption.xml with CipherReference URIs that can resolve to absolute or traversed filesystem paths.

The vulnerability manifests during the internal conversion workflow rather than during normal reading of EPUB content.

Exploit preconditions

  • Attack surface: Local file processing through the Calibre EPUB conversion feature.
  • Required access: Ability to supply or induce a user to open/convert a malicious EPUB file with Calibre.
  • Trigger point: Running the EPUB through Calibre's conversion engine, which processes META-INF/encryption.xml and resolves CipherReference URIs.
  • Why exploitation is possible:
  • The conversion logic resolves CipherReference URIs to absolute filesystem paths without constraining them to the conversion extraction directory.
  • The identified files are opened in read-write mode even when located outside the intended sandbox, allowing corruption of arbitrary writable files.

Why this happens

The root cause is insufficient validation of file paths derived from metadata inside the EPUB (META-INF/encryption.xml).

CipherReference URIs are treated as trusted, and the conversion component resolves them to absolute filesystem locations without enforcing a confinement policy.

This behavior aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory, because attacker-controlled input can escape the expected extraction directory and reference arbitrary paths.

Related aspects include CWE-73 (External Control of File Name or Path) due to external control of filesystem targets, and a potential for downstream integrity or code-related impacts if critical configuration or executable-adjacent files are corrupted.

Conceptually, the insecure pattern is: "take a path-like value from untrusted content, normalize/resolve it on the host filesystem, and open it in read-write mode without enforcing directory boundaries or access policies."

Potential impact

  • Corruption of arbitrary files writable by the Calibre process (e.g., user documents, data files, or application configuration).
  • Disruption or malfunction of Calibre or other applications if their configuration or state files are overwritten.
  • Increased risk of follow-on security issues where corrupted configuration or script files could later be used in other attack chains.
  • Potential denial of service for the user, via damage to important local data or application settings.

General mitigation guidance

Mitigation typically focuses on constraining file access during EPUB processing and reducing trust in embedded metadata.

Useful defensive patterns include:

  • Enforcing strict directory confinement: ensure all paths resolved from CipherReference URIs are canonicalized and verified to reside within the designated extraction / working directory before opening.
  • Normalizing and validating all URI/paths derived from EPUB contents, rejecting absolute paths and any use of directory traversal patterns such as ...
  • Opening files in the least-privilege mode necessary (e.g., read-only where possible) and avoiding read-write access when not strictly required.
  • Structuring the conversion pipeline to operate within a sandboxed workspace (e.g., chroot, container, or dedicated restricted directory) with minimal filesystem permissions.
  • Applying a "deny by default" policy for external file references in encryption or metadata files, only allowing explicitly sanctioned patterns and locations.

These approaches reduce the impact of any malicious EPUB content and limit the blast radius of file operations during conversion.

How teams detect issues like this

Detection can rely on both code-centric and behavior-centric approaches:

  • Static analysis: Define rules to flag file operations where:
  • Paths originate from EPUB metadata or other untrusted inputs (such as encryption.xml).
  • Canonicalization and directory-bound checks are missing or incomplete.
  • Absolute paths or path traversal sequences are allowed without scrutiny.
  • Code review cues: Review conversion and import pipelines for:
  • Direct use of URIs/paths from META-INF/encryption.xml or similar files.
  • Use of file open operations in read-write mode outside clearly bounded directories.
  • Lack of centralized path validation utilities or reusable sandboxing mechanisms.
  • Runtime monitoring (optional): On hardened systems, watch for EPUB conversion processes accessing files outside their expected working directories, using OS-level auditing or sandbox policy violations as indicators.
  • Automated tooling: Integrate security-focused linters and SAST tools into CI to detect externalized path usage patterns and missing path validation checks in file-processing components.

Sources

SourceLink
github.comgithub.com/kovidgoyal/calibre/commit/9484ea82c6ab226c18e6ca5aa000fa16de598726
github.comgithub.com/kovidgoyal/calibre/security/advisories/GHSA-8r26-m7j5-hm29
0x5t.raptx.org0x5t.raptx.org/posts/calibre-epub-rce

Frequently asked

questions

Not in a traditional networked sense. Exploitation occurs when a user locally opens or converts a malicious EPUB file with Calibre. However, attackers can distribute such EPUB files via the internet, email, or online libraries to reach victims.

The attacker only needs to get a victim to process a crafted EPUB with a vulnerable Calibre version. The attack then runs with the filesystem permissions of the Calibre process on that user's system, limited by what that process can write.

The best fix is to enforce strict path confinement for all file references derived from EPUB content. All CipherReference URIs should be canonicalized and verified to stay within a fixed working directory, with absolute paths and traversal attempts rejected outright, and file access reduced to the minimum privileges required.

Treat all paths and URIs from user-controlled content as untrusted. Centralize path validation logic, enforce directory whitelisting, avoid opening externally-derived paths in read-write mode by default, and add static analysis or review gates specifically targeting filesystem access patterns in content-processing pipelines.

Find out what's already
exploitable in your codebase.