Skip to content

Stored XSS in admin dashboards + active content served on the admin origin via unauthenticated /files/upsert #175

Open

Description

@9xj89gzrtw-hue

Summary

POST /files/upsert is unauthenticated, so stored content must be treated as untrusted user data everywhere it is rendered. Two spots currently allow script execution on the file-server origin — the same origin where the /admin dashboards live:

  1. Stored XSS in admin pages. routes/admin/files/list.ts renders ${file.file_path}, and routes/admin/files/get.ts renders ${file.file_path}, ${file.file_id}, ${file.created_at} unescaped; routes/admin/events/list.ts renders ${event_type} and the JSONified rest payload (which includes the user-supplied initiator and file_path). Writing a file with path /<script>alert(1)</script>/poc.html executes when an admin opens the files list/details pages; <img src=x onerror=...> via initiator executes on the events page.
  2. Active content served on the admin origin. /files/static serves stored content with text/html, image/svg+xml, text/javascript (and application/xml), so a file uploaded by anyone becomes a script running on the file-server origin when navigated to directly.

Reproduction

POST /files/upsert
{ "file_path": "/<script>alert(1)</script>/poc.html", "text_content": "x" }
# then open: /admin (File Management) or /admin/files/list → script runs

Proposed fix (small, contained)

  • escapeHtml() util applied to every user-controlled interpolation in the admin templates (display strings; href attribute values escaped without changing normal-path URLs).
  • /files/static: X-Content-Type-Options: nosniff on every response; Content-Security-Policy: sandbox on active content types (text/html, text/javascript, image/svg+xml, application/xml), including proxied responses. Bytes/type are unchanged; existing static-route behavior for normal files is preserved.

Tests included with the fix

  • route-level: admin pages escape a scripted file_path and a scripted initiator; normal file rendering unchanged
  • route-level: static route returns sandbox CSP + nosniff for .html/.svg/.js, nosniff-only for .txt; bytes unchanged

Activity

  1. 9xj89gzrtw-hue commented on Oct 24, 2026

    @9xj89gzrtw-hue
    Author

    /attempt #175

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions