Skip to content

file_storage: ACTIVE_CONTENT_TYPES misses scriptable XML types and malformed content types #545

Closed

Description

@antosubash

file_storage.constants.ACTIVE_CONTENT_TYPES decides which uploads are always streamed with the restrictive CSP instead of being served inline/redirected. It misses XML types browsers render as scriptable documents: application/atom+xml, application/rss+xml, application/mathml+xml, text/xsl, application/vnd.wap.xhtml+xml, and in general any *+xml. A malformed value such as text/html, or one with parameters/odd casing may also slip past an exact-match check. With allowed_content_types=None (the default) an uploader controls the stored type.

Fix direction: normalise the media type (lower-case, strip parameters and trailing junk), treat any *+xml and text/xsl as active, or invert to an allow-list of types safe to serve inline. Add tests per type.

Found in the security review of #525 (pre-existing).

https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4

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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions