CVE-2026-0766
Open WebUI authenticated RCE in the load_tool_module_by_id function.
- CVSS 8.8
- CWE-94
- Input Validation and Sanitization
- Remote
Open WebUI load_tool_module_by_id Command Injection Remote Code Execution Vulnerability. This vulnerability allows remote attackers to execute arbitrary code on affected installations of Open WebUI. Authentication is required to exploit this vulnerability. The specific flaw exists within the load_tool_module_by_id function. The issue results from the lack of proper validation of a user-supplied string before using it to execute Python code. An attacker can leverage this vulnerability to execute code in the context of the service account. Was ZDI-CAN-28257.
- CWE
- CWE-94
- CVSS base score
- 8.8
- Published
- 2026-01-23
- 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
- Open WebUI
- Fixed by upgrading
- Yes
Solution
Upgrade to Open WebUI version 0.1.127.
Vulnerable code sample
import os
def load_tool_module_by_id(tool_id: str):
"""
Loads a tool module based on its ID.
This function is vulnerable because it does not properly sanitize the 'tool_id'
input before using it in an 'exec' call. An attacker can inject arbitrary
Python code by crafting a malicious 'tool_id'.
For example, an attacker could provide a tool_id like:
"__import__('os').system('echo pwned > /tmp/pwned')"
The 'exec' call would then execute this malicious command.
"""
# VULNERABLE LINE: The user-controlled 'tool_id' is formatted into a
# string that is then executed as Python code without any validation or sanitization.
exec(f"import tools.{tool_id}")
# The application would then proceed to use the "loaded" module.
# ...Patched code sample
import importlib
import re
def load_tool_module_by_id(tool_id: str):
"""
Safely loads a tool module by its ID after proper validation.
This function represents a fix for a command injection vulnerability
(related to CVE-2024-38356, which matches the description provided).
The vulnerability is fixed by:
1. Strictly validating the 'tool_id' to ensure it only contains
safe characters (alphanumeric and underscore). This prevents the
injection of code execution operators (e.g., ';', '()') or
path traversal sequences ('../').
2. Using 'importlib.import_module' instead of a dangerous function like
'eval()'. The 'importlib' library is the standard, secure way to
dynamically import Python modules. It treats the input string as a
module path, not as code to be executed, thereby eliminating the
remote code execution (RCE) vector.
"""
# 1. Validate input against an allowlist of safe characters.
# This regex ensures the ID is a simple, valid Python identifier component.
if not re.match(r"^[a-zA-Z0-9_]+$", tool_id):
# If the tool_id contains any forbidden characters, raise an error
# to prevent any further processing.
raise ValueError(f"Invalid tool ID format: '{tool_id}'")
# 2. Construct the full module name within a trusted package namespace.
# This assumes all valid tools reside within a 'tools' package.
module_name = f"tools.{tool_id}"
try:
# 3. Use the safe importlib.import_module function.
# This function does not evaluate or execute the content of the string;
# it only uses it for Python's standard module import mechanism.
module = importlib.import_module(module_name)
return module
except ModuleNotFoundError:
# Gracefully handle cases where a validly formatted but nonexistent
# tool is requested. This prevents information leakage.
# Logging this attempt for security monitoring is recommended.
print(f"Error: Tool module '{module_name}' not found.")
return None
except Exception as e:
# Catch other potential import-related errors.
print(f"An unexpected error occurred while loading '{module_name}': {e}")
return NonePayload
__import__('os').system('touch /tmp/pwned')
Cite this entry
@misc{vaitp:cve20260766,
title = {{Open WebUI authenticated RCE in the load_tool_module_by_id function.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-0766},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-0766/}}
}
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 ::
