Kestrel
대시보드로 돌아가기
CVE-2026-59217MEDIUM· 4.3MITRENVDGHSA대응게시일: 2026. 07. 09.수정일: 2026. 07. 24.

Open WebUI: Upload `metadata.knowledge_id` bypasses the knowledge-base write-access check (read-only users can add files to KB)

Auth

위협 신호 · CVSS · EPSS · KEV

정기 패치· 높은 악용 신호 없음
CVSS
4.3medium

이론적 심각도 점수

EPSS
0.3%상위 78.6%

30일 내 악용 확률 예측

KEV
미등재

실측 악용 기록 없음

권장 대응 기한60일 이내CISA SSVC 기준

계획된 패치 주기 내 조치(60일 이내)

외부 노출· KEV 미등재 · 자동화 어려움 · 부분 영향 · 외부 노출

CVSS 벡터 · 메트릭

악용 경로
공격 벡터네트워크
공격 복잡도낮음
필요 권한낮음
사용자 상호작용불필요
범위불변
영향
기밀성 영향없음
무결성 영향낮음
가용성 영향없음
버전별 점수
CVSS 3.14.3MODERATE
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N

상세 설명

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.knowledge_id value and inserts a knowledge_file 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={"knowledge_id":"<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/open_webui/routers/knowledge.py
  • add_file_to_knowledge_by_id
  • 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/open_webui/routers/files.py
  • process_uploaded_file
  • Lines 178-186 read knowledge_id from upload metadata and immediately call Knowledges.add_file_to_knowledge_by_id(...).
  • Lines 187-192 call process_file(... collection_name=knowledge_id ...) after the insert.

The model method inserts the relationship without validating the caller's write access to the knowledge base:

  • backend/open_webui/models/knowledge.py
  • add_file_to_knowledge_by_id
  • Lines 646-677 create and commit a KnowledgeFile row for the supplied knowledge_id, file_id, and user_id.

The later vector write check exists, but it runs too late:

  • backend/open_webui/routers/retrieval.py
  • process_file
  • Lines 1587-1592 call _validate_collection_access(..., access_type='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/open_webui/routers/files.py lines 194-195 and logs a warning while leaving the row in place.

The unauthorized relationship affects file access decisions:

  • backend/open_webui/utils/access_control/files.py
  • has_access_to_file
  • 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:
text
1POST /api/v1/knowledge/<knowledge_id>/file/add
2Authorization: Bearer <reader token>
3Content-Type: application/json
4
5{"file_id":"<reader-owned-file-id>"}

Expected and observed behavior for the normal route: it rejects the request because reader lacks knowledge-base write access.

  1. As reader, upload a new file with the same target knowledge ID embedded in upload metadata:
text
1POST /api/v1/files/?process=true&process_in_background=false
2Authorization: Bearer <reader token>
3Content-Type: multipart/form-data
4
5file=@attacker-note.txt
6metadata={"knowledge_id":"<knowledge_id>"}
  1. Observe that the upload request succeeds and returns the uploaded file record.
  2. As owner, request the knowledge-base files:
text
1GET /api/v1/knowledge/<knowledge_id>/files
2Authorization: Bearer <owner token>
  1. Observe that attacker-note.txt appears in the target knowledge base even though reader did not have write access.
  2. As owner, request the file content:
text
1GET /api/v1/files/<attacker_file_id>/content
2Authorization: Bearer <owner token>
  1. Observe that the file is retrievable because has_access_to_file 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 directory_id, if present, must belong to the target knowledge base.
  • The KnowledgeFile association should only be inserted after authorization and processing succeed.

Actual Behavior

metadata.knowledge_id causes Knowledges.add_file_to_knowledge_by_id(...) 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.add_file_to_knowledge_by_id.
  3. Validate that directory_id, 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.

AI 심층 분석

공격 시나리오 · 재현 가능한 PoC 페이로드 · 즉시 적용 가능한 차단 패치를 한 번에 받아 보세요. 보안 운영팀이 그대로 점검·티켓팅에 쓸 수 있는 형태로 정리해 드립니다.