{"id":"PYSEC-2026-2766","summary":"Open WebUI: Cross-user file disclosure via /api/chat/completions image_url field","details":"## summary\n\n`POST /api/chat/completions` accepts an `image_url.url` value that, when it does NOT start with `http://`, `https://`, or `data:image/`, is interpreted as a file id and resolved against the global file table with no ownership check. An authenticated user can therefore set `image_url.url` to another user's file id, the server reads that file from disk, base64-encodes it, and injects the data URI into the LLM request. The user then prompts the LLM to describe / OCR the file and reads the content back.\n\nSame class as CVE-2026-44560 (RAG cross-user access) and the multiple `has_access_to_file` checks added in `routers/files.py` -- the auth boundary was tightened on the file router but not on this conversion path.\n\n## affected code\n\n`backend/open_webui/utils/middleware.py:2113-2150` -- `convert_url_images_to_base64`:\n\n```python\nasync def convert_url_images_to_base64(form_data):\n    messages = form_data.get('messages', [])\n    for message in messages:\n        content = message.get('content')\n        if not isinstance(content, list):\n            continue\n        new_content = []\n        for item in content:\n            if not isinstance(item, dict) or item.get('type') != 'image_url':\n                new_content.append(item)\n                continue\n            image_url = item.get('image_url', {}).get('url', '')\n            if image_url.startswith('data:image/'):\n                new_content.append(item)\n                continue\n            try:\n                base64_data = await get_image_base64_from_url(image_url)  # \u003c-- no `user` passed\n                if base64_data:\n                    new_content.append({'type': 'image_url',\n                                        'image_url': {'url': base64_data}})\n```\n\ncalled from the main chat completion middleware at `middleware.py:2357`:\n\n```python\nform_data = await convert_url_images_to_base64(form_data)\n```\n\n`backend/open_webui/utils/files.py:57-95` -- `get_image_base64_from_url`:\n\n```python\nasync def get_image_base64_from_url(url: str) -\u003e Optional[str]:\n    try:\n        if url.startswith('http'):\n            validate_url(url)\n            # ... SSRF-safe fetch with allow_redirects=AIOHTTP_CLIENT_ALLOW_REDIRECTS ...\n        else:\n            file = await Files.get_file_by_id(url)        # \u003c-- NO user_id filter\n            if not file:\n                return None\n            file_path = await asyncio.to_thread(Storage.get_file, file.path)\n            file_path = Path(file_path)\n            if file_path.is_file():\n                with open(file_path, 'rb') as image_file:\n                    encoded_string = base64.b64encode(image_file.read()).decode('utf-8')\n                    content_type = mimetypes.guess_type(file_path.name)[0] or (file.meta or {}).get('content_type')\n                    ...\n                    return f'data:{content_type};base64,{encoded_string}'\n```\n\n`Files.get_file_by_id` in `models/files.py:161` does a bare `db.get(File, id)` -- no ownership filter. there is a separate `Files.get_file_by_id_and_user_id` at line 172 that does filter on `user_id`, and the file router uses `has_access_to_file(id, 'read', user, db)` at `routers/files.py:626` etc. neither check exists on this path.\n\n## reproduction\n\n1. As user A, upload any file (image works cleanly, pdf works if a vision-capable model is configured). Note the file id from the upload response, e.g. `c7f1d8e3-...`.\n2. As user B, POST to `/api/v1/chat/completions` with body:\n\n```json\n{\n  \"model\": \"\u003cany vision model\u003e\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": [\n        {\"type\": \"text\", \"text\": \"transcribe everything you can see in this image\"},\n        {\"type\": \"image_url\", \"image_url\": {\"url\": \"c7f1d8e3-...\"}}\n      ]\n    }\n  ]\n}\n```\n\nServer reads user A's file from disk, base64-encodes it, and sends to the LLM as user B's image attachment. LLM response contains the file content.\n\n## file id discovery\n\nFile ids are UUIDs and not enumerable directly, but they leak via:\n\n- shared chats / channels containing the original upload\n- knowledge base members can see ids of files contributed by others\n- a user who can read a folder index sees the file ids of files inside\n- chat history exports (`/api/v1/chats/{id}`) include file ids\n- the user themselves can be tricked into pasting / sharing an id (less likely)\n\n## impact\n\nAny authenticated user can read any other user's file content (image and any file with an image-guess mimetype path) via this channel. Severity is bounded by what the LLM will accept in `image_url` -- in practice, image files work cleanly with any vision model; pdf / docx work with multi-modal providers that accept them.\n\n## suggested fix\n\nThread the authenticated user through to `get_image_base64_from_url` and resolve the file via `Files.get_file_by_id_and_user_id(id, user.id)` (or `has_access_to_file(id, 'read', user, db)` if shared-via-knowledge-base access is intended). Same pattern that's already used in `routers/files.py:626` and elsewhere.\n\nminimal patch sketch:\n\n```diff\n--- a/backend/open_webui/utils/files.py\n+++ b/backend/open_webui/utils/files.py\n@@ -57,7 +57,7 @@\n-async def get_image_base64_from_url(url: str) -\u003e Optional[str]:\n+async def get_image_base64_from_url(url: str, user=None) -\u003e Optional[str]:\n     try:\n         if url.startswith('http'):\n             ...\n         else:\n-            file = await Files.get_file_by_id(url)\n+            file = (await Files.get_file_by_id_and_user_id(url, user.id)\n+                    if user is not None else None)\n+            if file is None:\n+                # fall back to access-grant check for shared files\n+                file = await Files.get_file_by_id(url)\n+                if file and not await has_access_to_file(url, 'read', user):\n+                    return None\n```\n\nand pipe `user` through `convert_url_images_to_base64(form_data, user)` from the middleware caller. happy to send a PR once you confirm the fix shape you want.\n\n## variant note\n\nthis was found via patch-diffing existing advisories. the same bug class likely exists in any other site that calls `Files.get_file_by_id` without an adjacent `has_access_to_file` / `get_file_by_id_and_user_id` check. quick grep:\n\n```\ngit grep -n 'Files\\.get_file_by_id(' -- 'backend/open_webui/**'\n```\n\nworth a sweep across utils/ and routers/ for missed sites.\n\n## environment\n\nOpen-webui main branch as of commit `3660bc0` (2026-05-10). python 3.x backend. confirmed by reading the source; no instance stood up.","aliases":["CVE-2026-54009","GHSA-wch8-mhj5-9frg"],"modified":"2026-07-13T16:32:05.191490273Z","published":"2026-07-13T15:46:19.154289Z","references":[{"type":"WEB","url":"https://github.com/open-webui/open-webui/security/advisories/GHSA-wch8-mhj5-9frg"},{"type":"PACKAGE","url":"https://github.com/open-webui/open-webui"},{"type":"PACKAGE","url":"https://pypi.org/project/open-webui"},{"type":"ADVISORY","url":"https://github.com/advisories/GHSA-wch8-mhj5-9frg"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-54009"}],"affected":[{"package":{"name":"open-webui","ecosystem":"PyPI","purl":"pkg:pypi/open-webui"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"0.9.6"}]}],"versions":["0.1.124","0.1.125","0.2.0","0.2.1","0.2.2","0.2.3","0.2.4","0.2.5","0.3.0","0.3.1","0.3.10","0.3.12","0.3.13","0.3.14","0.3.15","0.3.16","0.3.17","0.3.17.dev2","0.3.17.dev3","0.3.17.dev4","0.3.17.dev5","0.3.18","0.3.19","0.3.2","0.3.20","0.3.21","0.3.22","0.3.23","0.3.24","0.3.25","0.3.26","0.3.27","0.3.27.dev1","0.3.27.dev2","0.3.27.dev3","0.3.28","0.3.29","0.3.3","0.3.30","0.3.30.dev1","0.3.30.dev2","0.3.31","0.3.31.dev1","0.3.32","0.3.33","0.3.33.dev1","0.3.34","0.3.35","0.3.4","0.3.5","0.3.6","0.3.7","0.3.8","0.3.9","0.4.0","0.4.0.dev1","0.4.0.dev2","0.4.1","0.4.2","0.4.3","0.4.4","0.4.5","0.4.6","0.4.6.dev1","0.4.7","0.4.8","0.5.0","0.5.0.dev1","0.5.0.dev2","0.5.1","0.5.10","0.5.11","0.5.12","0.5.13","0.5.14","0.5.15","0.5.16","0.5.17","0.5.18","0.5.19","0.5.2","0.5.20","0.5.3","0.5.3.dev1","0.5.4","0.5.5","0.5.6","0.5.7","0.5.8","0.5.9","0.6.0","0.6.1","0.6.10","0.6.11","0.6.12","0.6.13","0.6.14","0.6.15","0.6.16","0.6.18","0.6.19","0.6.2","0.6.20","0.6.21","0.6.22","0.6.23","0.6.24","0.6.25","0.6.26","0.6.26.dev1","0.6.27","0.6.28","0.6.29","0.6.3","0.6.30","0.6.31","0.6.32","0.6.33","0.6.34","0.6.35","0.6.36","0.6.37","0.6.38","0.6.39","0.6.4","0.6.40","0.6.41","0.6.42","0.6.43","0.6.5","0.6.6","0.6.6.dev1","0.6.7","0.6.8","0.6.9","0.7.0","0.7.1","0.7.2","0.8.0","0.8.1","0.8.10","0.8.11","0.8.12","0.8.2","0.8.3","0.8.4","0.8.5","0.8.6","0.8.7","0.8.8","0.8.9","0.9.0","0.9.1","0.9.2","0.9.3","0.9.4","0.9.5"],"database_specific":{"source":"https://github.com/pypa/advisory-database/blob/main/vulns/open-webui/PYSEC-2026-2766.yaml"}}],"schema_version":"1.7.5","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N"}]}