open-webui/backend/open_webui
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
..
data refac: mv backend files to /open_webui dir 2024-09-04 16:54:48 +02:00
internal chore: format 2026-04-24 18:48:21 +09:00
migrations refac 2026-04-24 18:20:10 +09:00
models refac 2026-05-05 04:21:23 +09:00
retrieval chore: format 2026-04-24 18:48:21 +09:00
routers security: harden file serving endpoints against stored XSS 2026-05-05 02:39:34 -07:00
socket refac 2026-04-17 13:29:51 +09:00
static chore: format 2026-04-19 22:45:54 +09:00
storage refac 2026-04-12 19:08:30 -05:00
test refac 2026-03-17 17:58:01 -05:00
tools refac 2026-04-24 18:06:19 +09:00
utils refac 2026-05-05 04:05:15 +09: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 feat: add PaddleOCR-vl loader support and implement retrieval router infrastructure (#23945) 2026-04-24 15:19:37 +09:00
constants.py chore: format 2026-04-14 17:27:31 -05:00
env.py refac 2026-04-24 16:23:28 +09:00
functions.py refac 2026-04-21 14:31:04 +09:00
main.py chore: format 2026-04-24 18:48:21 +09:00
tasks.py refac 2026-03-17 17:58:01 -05:00