/

CVE-2026-26064

Severity:

HIGH RISK

(8.8)

Path Traversal in Calibre extract_pictures Arbitrary File

CVE-2026-26064

Analyzed

Vulnerability type

Category:

Path Traversal / Directory Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write leading to Potential 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

A path traversal flaw in Calibre's extract_pictures function allows ZIP entries to write files outside the intended Pictures directory, anywhere the current user has write permissions.

On Windows, an attacker can leverage this to place a malicious file in the Startup folder, which is executed on the next login, effectively leading to remote code execution under the user's context.

Affected context

This vulnerability affects Calibre installations that handle archives (or similar data) using the extract_pictures functionality.

The issue appears when file paths from an archive are trusted if they merely start with "Pictures" and are then written using manual file handling instead of the hardened ZipFile.extractall() path sanitation routine.

The vulnerability is most impactful on systems where user-writable locations like the Windows Startup folder or other sensitive directories are reachable under the user's permissions.

Exploit preconditions

  • Attack surface: Calibre's picture extraction mechanism that processes paths from ZIP (or ZIP-like) archives.
  • Required access: Ability to supply or influence the archive content or metadata processed by extract_pictures (e.g., a crafted ebook or archive file).
  • Trigger point: User opens, imports, or otherwise processes a crafted file that causes extract_pictures to run.
  • Why exploitation is possible: The function only checks that the path starts with "Pictures" and does not normalize or reject .. path components, allowing attacker-controlled paths to escape the intended directory and target arbitrary locations writable by the user.

Why this happens

The underlying bug is an input validation failure where file paths extracted from an archive are insufficiently sanitized before being used for filesystem writes.

Instead of relying on Calibre's hardened _get_targetpath() logic in utils/zipfile.py (which strips or rejects .. sequences), extract_pictures manually reads archive entries and writes them using open() after a simple startswith('Pictures') check.

This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where adversary-controlled path elements can break out of the intended directory sandbox and overwrite or create files in arbitrary user-writable locations.

Potential impact

  • Creation or overwrite of files in arbitrary directories where the current user has write permissions.
  • On Windows, placing executables, scripts, or shortcuts in the user's Startup folder that execute automatically on next login.
  • Persistence of attacker code or tooling under the user account.
  • Potential tampering with application configuration, user documents, or other local data.
  • Indirect escalation to remote code execution scenarios when malicious files are later executed by the system or other applications.

General mitigation guidance

Effective mitigation typically focuses on robust path normalization and confinement:

  • Ensure all archive extraction code paths use a centralized, hardened routine for joining and validating paths (e.g., a function that normalizes paths, rejects .. segments and absolute paths, and enforces a fixed base directory).
  • Avoid manual file writes based on archive entry names unless the paths are canonicalized and explicitly verified to remain within a designated directory.
  • Treat all archive metadata (including filenames and paths) as untrusted input; apply strict validation and disallow path constructs that can escape the intended extraction root.
  • Run client applications like Calibre with least privilege and avoid granting them access to sensitive directories beyond what is required for normal operation.
  • Where possible, isolate processing of untrusted content using separate profiles, accounts, or sandboxing techniques to limit the blast radius of any file-write issues.

How teams detect issues like this

Detection efforts can combine code-level and behavioral approaches:

  • Static analysis: Define rules or patterns to flag any use of archive or user-supplied filenames being concatenated directly into filesystem paths, especially when .., absolute paths, or environment-dependent directories may be reachable.
  • Code review: Look for custom extraction logic that bypasses standard, hardened helpers (e.g., calls to read() + open() instead of centralized extract/extractall() wrappers) and verify that all such paths are normalized and checked against a fixed base directory.
  • Policy enforcement: Introduce development guidelines requiring all path operations on untrusted filenames to go through utility functions that perform canonicalization and directory containment checks.
  • Runtime monitoring (optional): On high-assurance systems, monitor applications for unexpected writes into sensitive directories (Startup folders, configuration directories, or other auto-execution locations) when processing untrusted content.

Sources

SourceLink
github.comgithub.com/kovidgoyal/calibre/commit/e1b5f9b45a5e8fa96c136963ad9a1d35e6adac62
github.comgithub.com/kovidgoyal/calibre/security/advisories/GHSA-72ch-3hqc-pgmp

Frequently asked

questions

It can be remotely exploitable in practice when a user is tricked into opening or processing attacker-crafted content (such as a malicious ebook or archive) with Calibre. The attacker's control is indirect but can originate from remote delivery channels like email, downloads, or shared files.

The attacker must be able to supply or influence the archive or ebook that Calibre processes with extract_pictures. They do not need direct filesystem access; the vulnerable application performs the file write using the attacker-controlled paths.

Centralize all path handling for archive extraction into a single utility that normalizes paths, strips dangerous components like .., rejects absolute paths, and enforces that the final resolved path is a descendant of an intended base directory. Avoid ad hoc checks such as simple prefix matching on filenames.

Adopt a defensive design for file I/O where all paths derived from user or content input are treated as untrusted, must pass through canonicalization and containment checks, and are always joined under a trusted base directory using well-reviewed helper functions. Enforce these patterns via code review, static analysis rules, and engineering guidelines for any archive or file upload handling code.

Find out what's already
exploitable in your codebase.