/

CVE-2026-25635

Severity:

HIGH RISK

(8.6)

Path Traversal in Calibre CHM Reader Enables Arbitrary File

CVE-2026-25635

Analyzed

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write leading to Potential Remote Code Execution

Severity:

HIGH RISK

(8.6)

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 CHM reader allows crafted content to write files to arbitrary locations where the current user has write permissions.

On Windows, this can be chained to remote code execution by placing attacker-controlled files in the user's Startup folder, causing them to run on the next login.

Affected context

The vulnerability affects environments where Calibre is used to open CHM (Compiled HTML Help) files with the built-in CHM reader.

It becomes relevant when Calibre processes paths embedded in CHM content or related resources without proper normalization or restriction to a safe base directory.

The issue is particularly dangerous on Windows systems, where writing files into special user-controlled locations (such as Startup folders) can result in code execution during normal system use.

Exploit preconditions

  • Attack surface: Opening or processing attacker-supplied CHM files or CHM-derived content in Calibre's CHM reader.
  • Required access: Ability to convince a user to open a malicious CHM file in Calibre, or otherwise supply untrusted CHM content to the reader.
  • Trigger point: Calibre's CHM processing logic handling file paths and writing extracted or generated files to disk.
  • Why exploitation is possible: The CHM reader does not sufficiently validate or normalize file paths, allowing directory traversal sequences to escape the intended directory and target arbitrary writable locations.

Why this happens

This vulnerability stems from improper restriction of file paths when writing files derived from CHM content.

User-controllable path components from inside the CHM file are used to construct filesystem paths without robust normalization and enforcement of a safe root directory.

As described by CWE-22: Improper Limitation of a Pathname to a Restricted Directory, directory traversal sequences (such as ../) or absolute paths are allowed to influence the destination, enabling writes outside the intended sandbox.

The insecure pattern is treating paths from a semi-trusted archive format (CHM) as safe for direct use with filesystem APIs.

Potential impact

  • Arbitrary file creation or overwrite in any directory where the user has write permissions
  • Placement of malicious executables or scripts in the Windows Startup folder leading to code execution on next login
  • Persistence of attacker-controlled code under the user account
  • Overwriting configuration or data files to corrupt application behavior or cause data loss
  • Facilitating further compromise by planting helper tools or backdoors in trusted locations

General mitigation guidance

Mitigation generally focuses on hardening file handling and constraining where data from CHM content can be written:

  • Normalize and canonicalize all paths derived from CHM content before use, resolving . and .. segments and symbolic links where relevant.
  • Enforce a strict base directory for CHM extraction or writes and reject any path that attempts to escape this directory after normalization.
  • Treat archive-internal paths as untrusted input: strip absolute paths, drive letters, and special folders, and map them to safe, application-controlled names.
  • Implement allowlists for output locations and file types when extracting or generating files from CHM data.
  • Run the application with the minimum necessary filesystem privileges and avoid writing to sensitive or executable search paths by default.

How teams detect issues like this

Detection strategies can combine code-centric review with behavioral monitoring:

  • Static analysis: Search for file write operations where the destination path is influenced by CHM file contents or other untrusted inputs without normalization and base-directory checks.
  • Code review: Flag any path construction logic in the CHM reader that concatenates user-controlled strings to filesystem paths, especially where .., absolute paths, or environment-dependent directories might be honored.
  • Unit and security testing: Add tests that attempt to write via traversal sequences (e.g., ../) or to platform-specific sensitive directories and validate that these are rejected.
  • Runtime monitoring: On endpoints, monitor the application for unexpected writes into Startup folders or other auto-execution locations, which may indicate exploitation attempts.

Sources

SourceLink
github.comgithub.com/kovidgoyal/calibre/commit/9739232fcb029ac15dfe52ccd4fdb4a07ebb6ce9
github.comgithub.com/kovidgoyal/calibre/security/advisories/GHSA-32vh-whvh-9fxr
0x5t.raptx.org0x5t.raptx.org/posts/calibre-chm-rce

Frequently asked

questions

Exploitability depends on a user opening a malicious CHM file in Calibre. If an attacker can reliably deliver such a file (for example, via email or download) and persuade the user to open it, they can attempt to abuse the path traversal behavior.

The attacker does not need local system access in the traditional sense, but they do need to get their CHM file opened by the logged-in user. The vulnerability executes with that user's privileges, so the attacker's effective access is limited to locations that user can write to.

The safest pattern is to strictly confine all file operations driven by CHM content to a dedicated directory, after canonicalizing paths and rejecting any that attempt to escape that directory or specify absolute/special locations. Avoid using raw archive paths directly with filesystem APIs.

Treat all path data from external or semi-trusted formats as untrusted, consistently normalize and validate paths, and enforce a "jail" or sandbox directory for extraction. Complement this with code review and static analysis rules that flag user-influenced paths passed directly to file APIs without proper checks.

Find out what's already
exploitable in your codebase.