open-webui/backend/open_webui
Classic298 ba78ebea27
fix: validate folder_id ownership on chat create + folder-update endpoints (#24588)
POST /api/v1/chats/new and POST /api/v1/chats/{id}/folder accepted a
caller-supplied folder_id with no validation — neither ownership, nor
existence, nor UUID format. The row was persisted with the supplied
value verbatim, so the DB ended up with chat rows whose folder_id
referenced another user's folder, a non-existent UUID, or even a
non-UUID string.

No read path surfaces this across users — every chat-folder read is
user_id-filtered on both sides — so this is referential-integrity
hardening rather than a security boundary fix. But there's no reason
to accept dangling references either, and the downstream consumers
shouldn't have to assume the column is clean.

Add a Folders.get_folder_by_id_and_user_id() lookup at both writers:
if a folder_id is supplied, it must match a folder owned by the
caller. None remains allowed (chat-without-folder is the default).
Non-existent and non-UUID values fall through to 404.

Reported by ShigekiTsuchiyama in GHSA-4vrg-2vcq-q7jc.

Co-authored-by: ShigekiTsuchiyama <ShigekiTsuchiyama@users.noreply.github.com>
2026-05-14 02:57:57 +09:00
..
data refac: mv backend files to /open_webui dir 2024-09-04 16:54:48 +02:00
internal refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
migrations feat: knowledge directory 2026-05-13 22:37:53 +09:00
models refac 2026-05-14 02:00:23 +09:00
retrieval refac 2026-05-14 02:56:44 +09:00
routers fix: validate folder_id ownership on chat create + folder-update endpoints (#24588) 2026-05-14 02:57:57 +09:00
socket refac 2026-05-13 12:44:12 +09:00
static refac 2026-05-12 03:04:35 +09:00
storage refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
tools refac 2026-05-14 02:08:35 +09:00
utils refac 2026-05-13 15:55:21 +09:00
__init__.py refac 2026-05-09 02:38:08 +09:00
alembic.ini fix: Alembic CLI commands from failing 2025-08-15 04:17:47 -04:00
config.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
constants.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
env.py refac 2026-05-14 02:56:44 +09:00
functions.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
main.py refac 2026-05-14 02:08:01 +09:00
tasks.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00