open-webui/backend/open_webui
Classic298 e7ff4768f8
fix: Add ownership checks to global task endpoints (#23454)
* Add ownership checks to global task endpoints

- Restrict GET /api/tasks and POST /api/tasks/stop/{task_id} to admin-only
- Add new scoped POST /api/tasks/chat/{chat_id}/stop endpoint with ownership
  check so regular users can stop their own chat tasks
- Allow admins to access the scoped chat task endpoints alongside owners
- Update frontend to use the new scoped stop endpoint when a chatId is available

https://claude.ai/code/session_01K7zPDvvjRu8AxJ4Br2HhZc

* Handle temporary (local:) chat IDs in scoped task endpoints

Temporary chats use local:<socketId> as chat_id which doesn't exist in
the DB. The scoped endpoints now skip ownership checks for local: IDs
(they aren't enumerable) and use {chat_id:path} to handle the colon in
the URL path.

https://claude.ai/code/session_01K7zPDvvjRu8AxJ4Br2HhZc

* Verify session ownership for local: chat IDs and URL-encode chat_id

- For local:<socketId> chat IDs, look up the socket's owner in
  SESSION_POOL and verify it matches the requesting user (or admin)
- URL-encode chat_id in frontend fetch calls to handle special
  characters (colon in local: IDs) safely

https://claude.ai/code/session_01K7zPDvvjRu8AxJ4Br2HhZc

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-04-12 17:56:43 -05:00
..
data refac: mv backend files to /open_webui dir 2024-09-04 16:54:48 +02:00
internal refac: async db 2026-04-12 14:22:11 -05:00
migrations refac 2026-04-01 18:26:46 -05:00
models refac: async db 2026-04-12 14:22:11 -05:00
retrieval fix: use ipaddress stdlib for IPv6 SSRF protection (#23453) 2026-04-12 16:34:13 -05:00
routers refac 2026-04-12 17:22:06 -05:00
socket fix: invalidate stale Socket.IO sessions on role change and user deletion (#23642) 2026-04-12 16:19:38 -05:00
static refac 2026-03-23 23:39:52 -05:00
storage refac 2026-04-12 12:36:21 -05:00
test refac 2026-03-17 17:58:01 -05:00
tools refac 2026-04-12 14:39:23 -05:00
utils refac 2026-04-12 17:22:06 -05:00
__init__.py refac (#22987) 2026-03-24 15:41:26 -05:00
alembic.ini fix: Alembic CLI commands from failing 2025-08-15 04:17:47 -04:00
config.py enh: automation 2026-04-11 17:06:58 -06:00
constants.py refac 2026-03-25 17:29:57 -05:00
env.py refac 2026-04-12 17:22:06 -05:00
functions.py refac: async db 2026-04-12 14:22:11 -05:00
main.py fix: Add ownership checks to global task endpoints (#23454) 2026-04-12 17:56:43 -05:00
tasks.py refac 2026-03-17 17:58:01 -05:00