CVE-2026-45272
Admin can inject Python code via unchecked SOCIAL_AUTH keys, leading to RCE.
- CVSS 9.4
- CWE-94
- Input Validation and Sanitization
- Remote
MyBooks is an enhanced and easy-to-use personal ebook management web server also known as Talebook. In 3.41.2 and earlier, the AdminSettings.post handler in webserver/handlers/admin.py accepts SOCIAL_AUTH key names without validating quotes or newline characters, and SettingsLoader.dumpfile in webserver/loader.py concatenates those names into the generated Python source file auto.py without escaping them. An administrator can submit a crafted SOCIAL_AUTH key name that closes the settings dictionary and injects arbitrary Python statements. The application later executes those statements because SettingsLoader.loadfile imports auto.py as a module, and setting autoreload to true invokes restart_async so a process supervisor restarts the service and triggers the import. Successful exploitation executes commands with the privileges of the application service account and can disclose data, modify files, establish persistence, or disrupt the service. Related authorization and registration vulnerabilities can reduce the effective privilege requirement in a chained attack, but the standalone vulnerability requires administrator access. This issue is fixed in version 3.42.0.
- CWE
- CWE-94
- CVSS base score
- 9.4
- Published
- 2026-08-19
- OWASP
- A03 Injection
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Input Validation and Sanitization
- Subcategory
- Command Injection
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- Python
Solution
Upgrade MyBooks/Talebook to version 3.42.0 or later.
Vulnerable code sample
import os
import json
class SettingsLoader:
def __init__(self, path):
self.path = path
def dumpfile(self, settings):
# VULNERABLE: directly concatenates untrusted key into Python source
lines = ["settings = {"]
for k, v in settings.items():
lines.append(f' "{k}": {json.dumps(v)},')
lines.append("}")
with open(os.path.join(self.path, "auto.py"), "w") as f:
f.write("\n".join(lines))
def loadfile(self):
import importlib.util, sys
spec = importlib.util.spec_from_file_location("auto", os.path.join(self.path, "auto.py"))
module = importlib.util.module_from_spec(spec)
sys.modules["auto"] = module
spec.loader.exec_module(module)
return module.settings
class AdminSettings:
def __init__(self, loader):
self.loader = loader
def post(self, request_json):
# VULNERABLE: accepts any SOCIAL_AUTH key name without sanitization
new_settings = {}
for key, value in request_json.get("SOCIAL_AUTH", {}).items():
new_settings[key] = value
self.loader.dumpfile({"SOCIAL_AUTH": new_settings})Patched code sample
import os
import json
import shlex
class SettingsLoader:
def __init__(self, path):
self.path = path
def dumpfile(self, settings):
# FIX: escape key names to prevent code injection
lines = ["settings = {"]
for k, v in settings.items():
safe_key = k.replace('\\', '\\\\').replace('"', '\\"')
lines.append(f' "{safe_key}": {json.dumps(v)},')
lines.append("}")
with open(os.path.join(self.path, "auto.py"), "w") as f:
f.write("\n".join(lines))
def loadfile(self):
import importlib.util, sys
spec = importlib.util.spec_from_file_location("auto", os.path.join(self.path, "auto.py"))
module = importlib.util.module_from_spec(spec)
sys.modules["auto"] = module
spec.loader.exec_module(module)
return module.settings
class AdminSettings:
def __init__(self, loader):
self.loader = loader
def post(self, request_json):
# FIX: validate key names contain only allowed characters
new_settings = {}
for key, value in request_json.get("SOCIAL_AUTH", {}).items():
if not key.isidentifier():
continue
new_settings[key] = value
self.loader.dumpfile({"SOCIAL_AUTH": new_settings})Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- fix: patch 5 vulnerabilities in GHSA-wrwr-q83h-jrjg (PoxenStudio/mybooks)
webserver/handlers/admin.py,webserver/handlers/base.py · BaseHandler.process_auth_header,webserver/handlers/user.py · SignUp.post,webserver/loader.py · SettingsLoader.dumpfile
Cite this entry
@misc{vaitp:cve202645272,
title = {{Admin can inject Python code via unchecked SOCIAL_AUTH keys, leading to RCE.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-45272},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-45272/}}
}
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 ::
