open-webui/backend/open_webui/routers
Sebastien Tardif fd8361217f security: harden file serving endpoints against stored XSS
Prevent stored XSS attacks through file-serving endpoints by:

1. Adding a safe content-type allowlist (SAFE_INLINE_CONTENT_TYPES) for
   inline serving. Content types not on the allowlist are replaced with
   application/octet-stream and forced to Content-Disposition: attachment,
   preventing browsers from executing uploaded HTML/JS files.

2. Adding Content-Security-Policy sandbox header to the /content/html
   endpoint to block script execution even for legitimately served HTML.

3. Adding X-Content-Type-Options: nosniff to all file-serving responses
   to prevent MIME-type sniffing attacks.

4. Forcing application/octet-stream on the /content/{file_name} download
   endpoint which is always served as attachment.

Previously, the /content endpoint passed through the uploader-controlled
Content-Type header directly to the response, allowing a user to upload
a file with Content-Type: text/html containing malicious scripts. The
/content/html endpoint served files with their OS-inferred content type
and no CSP restrictions, enabling full same-origin script execution.
2026-05-05 02:39:34 -07:00
..
analytics.py chore: format 2026-04-12 18:12:59 -05:00
audio.py refac 2026-04-24 15:03:29 +09:00
auths.py chore: format 2026-04-24 18:48:21 +09:00
automations.py refac 2026-04-21 13:46:39 +09:00
calendar.py chore: format 2026-04-21 15:52:00 +09:00
channels.py refac 2026-04-21 15:41:07 +09:00
chats.py refac 2026-05-05 03:33:47 +09:00
configs.py chore: format 2026-04-21 15:52:00 +09:00
evaluations.py chore: format 2026-04-12 18:12:59 -05:00
files.py security: harden file serving endpoints against stored XSS 2026-05-05 02:39:34 -07:00
folders.py chore: format 2026-04-12 18:12:59 -05:00
functions.py chore: format 2026-04-21 15:52:00 +09:00
groups.py refac: async db 2026-04-12 14:22:11 -05:00
images.py refac 2026-04-17 11:48:17 +09:00
knowledge.py chore: format 2026-04-19 22:45:54 +09:00
memories.py chore: format 2026-04-17 14:28:18 +09:00
models.py refac 2026-04-24 18:20:10 +09:00
notes.py refac 2026-04-14 17:22:54 -05:00
ollama.py refac 2026-04-24 15:35:59 +09:00
openai.py refac 2026-04-24 15:35:59 +09:00
pipelines.py refac 2026-04-20 08:53:06 +09:00
prompts.py refac 2026-04-13 14:08:58 -05:00
retrieval.py feat: add PaddleOCR-vl loader support and implement retrieval router infrastructure (#23945) 2026-04-24 15:19:37 +09:00
scim.py refac: async db 2026-04-12 14:22:11 -05:00
skills.py refac: async db 2026-04-12 14:22:11 -05:00
tasks.py refac 2026-04-13 14:08:58 -05:00
terminals.py refac 2026-04-20 08:36:24 +09:00
tools.py chore: format 2026-04-24 18:48:21 +09:00
users.py refac 2026-04-24 16:17:46 +09:00
utils.py refac 2026-04-13 14:08:58 -05:00