open-webui/backend/open_webui/retrieval
Claude ddec5556dd
fix: reject collection names with unsafe characters in RAG ACL
Open WebUI's collection ACL accepted any unknown name as a
legacy/ephemeral collection. In Milvus multi-tenancy mode that name
becomes the `resource_id` and is interpolated unescaped into a SQL-like
Milvus expression — `resource_id == '<name>'` — so a name like
  x' or resource_id != '' or resource_id == 'x
turns the filter into a tautology and returns every tenant's chunks
from the shared collection.

All collection names Open WebUI generates are UUIDs, SHA-256 hex
digests, or fixed-prefix variants of those — they all fit
[A-Za-z0-9_-]. Add a strict format check in
filter_accessible_collections (utils.py) that drops any name outside
that set before any ACL or vector-store lookup, applied even on the
admin bypass path. _validate_collection_access then surfaces the dropped
name as a 403.

As defense in depth, MilvusClient now validates resource_id at every
expression-construction site and escapes single quotes / backslashes in
any other string interpolated into a filter (delete ids, metadata
filter values). Non-string filter values are typed-checked instead of
str()-formatted.
2026-05-21 11:08:59 +00:00
..
loaders fix: log expected fetch/transcript/tool-server failures as warnings (#24903) 2026-05-19 21:55:40 +04:00
models refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
vector fix: reject collection names with unsafe characters in RAG ACL 2026-05-21 11:08:59 +00:00
web fix: mitigate DNS rebinding in web loader fetch paths (#24759) 2026-05-19 23:57:12 +04:00
utils.py fix: reject collection names with unsafe characters in RAG ACL 2026-05-21 11:08:59 +00:00