Skip to content

themes: sanitize CSS in GetCSS for edited or manually installed themes #45

Open

Description

@DarkLabsStudio

Summary

GetCSS returns the theme stylesheet as raw file bytes. Sanitization only runs during installation, so editing an installed theme.css or copying a theme folder into the themes directory bypasses the CSS sanitizer entirely.

Current behavior

  • pkg/theme/installer.go:111 calls SanitizeCSS when installing a .theme package.
  • pkg/theme/manager.go:60-80 (GetCSS) reads the file and returns string(data) without sanitizing.
  • The frontend injects that result into <style id="aether-theme-overwrite">.

This means the protections documented in docs/THEMES.md (blocked url(), overlays, window controls, etc.) can be bypassed by editing the installed file or placing a theme folder directly in the data directory.

Proposed fix

  • Run SanitizeCSS in GetCSS before returning the stylesheet, or re-sanitize when a theme is activated.
  • scopeSelector already avoids double-prefixing selectors that start with #aether-root, so sanitizing an already-installed stylesheet should be idempotent; add a regression test for that.
  • Alternatively, document that manual edits are unsupported and enforce a read-only installed file, but sanitizing on read is the safer default.

Related

Testing

Add a test that writes a theme.css containing a blocked rule after install, calls GetCSS, and asserts the rule is removed.

Activity

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