CVE-2026-59217: Open WebUI: Upload `metadata.knowledge_id` bypasses the knowledge-base write-access check (read-only users can add files to KB)
Open WebUI upload metadata can add files to knowledge bases without write permission
Summary
Open WebUI's file upload background processing trusts the client-supplied metadata.knowledgeid value and inserts a knowledgefile association before validating that the uploading user has write access to the target knowledge base.
A verified user with only read access to a knowledge base can upload an arbitrary file and set metadata={"knowledgeid":"<target knowledge id>"}. The normal /api/v1/knowledge/{id}/file/add endpoint correctly requires knowledge-base write access, but the upload auto-link path bypasses that authorization check.
The immediate result is unauthorized modification of the target knowledge base's file membership. The attached attacker-controlled file becomes visible through /api/v1/knowledge/{id}/files, and readers/owners of that knowledge base can retrieve the file through the normal file endpoints because file access is derived from KnowledgeFile membership.
Affected Version
- Repository: open-webui/open-webui - Tested source commit: 02dc3e689ceac915a870b373318b99c029ddf603 - Package version observed in package.json: 0.9.6 - Package name: open-webui
Impact
A read-only knowledge-base collaborator can perform a write operation against that knowledge base by attaching arbitrary uploaded files.
Security impact:
- Unauthorized knowledge-base membership modification. - Integrity impact on shared knowledge-base file listings. - Attacker-controlled files become readable to other users who can read the target knowledge base. - If an owner/admin later reprocesses or globally reindexes the knowledge base, the unauthorized file can be indexed into the knowledge collection, turning the membership bypass into RAG/content poisoning.
This is not an unauthenticated issue. It requires a verified Open WebUI account and a valid target knowledge-base ID. The clearest exploit path is a user who legitimately has read access to a knowledge base but not write access.
Source Evidence
The normal single-file knowledge add endpoint checks write permission before processing or inserting the relationship:
- backend/openwebui/routers/knowledge.py - addfiletoknowledgebyid - Lines 714-728 reject callers who are not owner, admin, or granted write access. - Lines 750-766 then process and insert the file only after that authorization gate.
The upload auto-link path does not perform the same check:
- backend/openwebui/routers/files.py - processuploadedfile - Lines 178-186 read knowledgeid from upload metadata and immediately call Knowledges.addfiletoknowledgebyid(...). - Lines 187-192 call processfile(... collectionname=knowledgeid ...) after the insert.
The model method inserts the relationship without validating the caller's write access to the knowledge base:
- backend/openwebui/models/knowledge.py - addfiletoknowledgebyid - Lines 646-677 create and commit a KnowledgeFile row for the supplied knowledgeid, fileid, and userid.
The later vector write check exists, but it runs too late:
- backend/openwebui/routers/retrieval.py - processfile - Lines 1587-1592 call validatecollectionaccess(..., accesstype='write') when a collection is supplied.
Because the unauthorized KnowledgeFile row is already committed before that check runs, the failed vector processing does not undo the knowledge-base file association. The upload code catches the exception at backend/openwebui/routers/files.py lines 194-195 and logs a warning while leaving the row in place.
The unauthorized relationship affects file access decisions:
- backend/openwebui/utils/accesscontrol/files.py - hasaccesstofile - Lines 41-53 grant file access when a file is associated with a knowledge base the user can access.
So once the attacker's file is inserted into the target KnowledgeFile table, target knowledge-base readers/owners can see and fetch that file through normal knowledge/file routes.
Reproduction Steps
Use a local Open WebUI instance with two verified users:
1. As user owner, create a knowledge base. 2. Grant user reader read access to the knowledge base, but do not grant write access. 3. As reader, confirm the normal add-file endpoint is blocked:
http POST /api/v1/knowledge/<knowledgeid>/file/add Authorization: Bearer <reader token> Content-Type: application/json
{"fileid":"<reader-owned-file-id>"}
Expected and observed behavior for the normal route: it rejects the request because reader lacks knowledge-base write access.
4. As reader, upload a new file with the same target knowledge ID embedded in upload metadata:
http POST /api/v1/files/?process=true&processinbackground=false Authorization: Bearer <reader token> Content-Type: multipart/form-data
file=@attacker-note.txt metadata={"knowledgeid":"<knowledgeid>"}
5. Observe that the upload request succeeds and returns the uploaded file record. 6. As owner, request the knowledge-base files:
http GET /api/v1/knowledge/<knowledgeid>/files Authorization: Bearer <owner token>
7. Observe that attacker-note.txt appears in the target knowledge base even though reader did not have write access. 8. As owner, request the file content:
http GET /api/v1/files/<attackerfileid>/content Authorization: Bearer <owner token>
9. Observe that the file is retrievable because hasaccesstofile derives access from the unauthorized knowledge-base membership.
Expected Behavior
The upload auto-link path should enforce the same authorization contract as /api/v1/knowledge/{id}/file/add:
- The target knowledge base must exist. - The caller must be the knowledge owner, an admin, or have write access. - The supplied directoryid, if present, must belong to the target knowledge base. - The KnowledgeFile association should only be inserted after authorization and processing succeed.
Actual Behavior
metadata.knowledgeid causes Knowledges.addfiletoknowledgebyid(...) to insert a KnowledgeFile row before write authorization is checked. The later collection write validation can fail, but the unauthorized membership row remains committed.
Suggested Fix
Move knowledge-base authorization before the insert in the upload auto-link path. The upload path should share the same write-access and directory validation logic used by the dedicated knowledge endpoints.
One safe pattern:
1. Load the target knowledge base. 2. Require owner/admin/write access before calling Knowledges.addfiletoknowledgebyid. 3. Validate that directoryid, if supplied, belongs to the same knowledge base. 4. Run vector processing before inserting the membership row, or wrap processing plus insertion in a transaction/compensating cleanup so a denied or failed process cannot leave a stale unauthorized row.
Other sources
Open WebUI is an extensible, feature-rich, and user-friendly self-hosted AI platform. Prior to 0.10.0, the file upload path accepted metadata.knowledgeid and auto-linked uploaded files to a target knowledge base without applying the write-access check used by /api/v1/knowledge//file/add, allowing read-only knowledge-base users to add arbitrary files. This issue is fixed in version 0.10.0.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/open-webuito a version that resolves this vulnerability.Fixed in 0.10.0 - Upgrade
Upgrade
open-webui/open-webuito a version that resolves this vulnerability.Fixed in 0.10.0 - Configuration
Move knowledge-base authorization and directory_id validation ahead of inserting the KnowledgeFile membership row in the upload auto-link path that uses client-supplied metadata.knowledge_id. Ensure the path enforces the same write-access authorization contract as /api/v1/knowledge/<knowledge_id>/file/add.
Open WebUI backend file upload auto-link path (backend/open_webui/routers/files.py / backend/open_webui/models/knowledge.py) metadata.knowledge_id handling = Require owner/admin/write access before calling Knowledges.add_file_to_knowledge_by_id(...); validate directory_id belongs to the target knowledge base before inserting KnowledgeFile association - Configuration
Change the upload auto-link logic so that vector processing occurs before the KnowledgeFile row is inserted, or ensure insertion and processing are atomic (transaction) so denied/failed processing cannot leave a stale unauthorized KnowledgeFile row.
Open WebUI KnowledgeFile association + file/vector processing (backend/open_webui/models/knowledge.py) order of operations = Process vector/file before inserting KnowledgeFile membership row OR wrap processing + insertion in a transaction/compensating cleanup
Event History
Frequently Asked Questions
What is the severity of CVE-2026-59217?
The severity of CVE-2026-59217 is classified as medium with a score of 4.3.
How do I fix CVE-2026-59217?
CVE-2026-59217 can be fixed by updating Open WebUI to version 0.10.0 or later.
What type of users are affected by CVE-2026-59217?
CVE-2026-59217 affects read-only users who can upload files to the knowledge base without proper access checks.
What is the risk associated with CVE-2026-59217?
CVE-2026-59217 poses a risk by allowing unauthorized file uploads to the knowledge base, potentially compromising data integrity.
What components are involved in CVE-2026-59217?
CVE-2026-59217 involves the Open WebUI file upload functionality that incorrectly handles metadata.knowledge_id.