[GH-ISSUE #2951] [Issue]: Card-CSS theme-token guard misses --popover/--sidebar and lists a token that doesn't exist #1527

Closed
opened 2026-10-21 05:38:00 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Jun 28, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2951

Originally assigned to: @SpicyMarinara on GitHub.

What's wrong

Card CSS is blocked from redefining the app's theme color tokens, so a malicious or sloppy card can't repaint the whole app through them. That blocklist has drifted out of sync with the real tokens:

  • It's missing --popover, --popover-foreground, and the base --sidebar — all real, defined, used app tokens — so a card can override them.
  • It lists --sidebar-background, which isn't defined anywhere in the app, so that entry matches nothing.

Impact is bounded (card CSS is scoped to the chat container), but it's a real gap in a guard that's meant to be exhaustive, plus a dead entry.

How to reproduce (try it yourself)

  1. In a card's creator-notes <style>: :root { --background: red; --popover: red; --sidebar: lime; }
  2. Open a chat with card CSS enabled and inspect #marinara-card-css.

You'll see (verified by running the actual sanitizer):

.mari-card-css {  --popover: red; --sidebar: lime; }

--background is correctly stripped, but --popover and --sidebar survive.
Expected: all app theme tokens — including --popover, --popover-foreground, and --sidebar — are stripped from card CSS.

Where it is

packages/client/src/lib/card-css.ts — THEME_TOKEN_BLOCKLIST lines 111-149 (lists --sidebar-background at 130; lacks --popover, --popover-foreground, and bare --sidebar), consumed by the theme-strip pass at 402-408. The tokens are defined in packages/client/src/styles/globals.css (--popover line 184, --popover-foreground 185, --sidebar 200) and consumed via --color-popover: var(--popover) / --color-sidebar: var(--sidebar) (113-114, 128). --sidebar-background is defined nowhere in the stylesheet.

What's happening

The token list is hand-maintained and drifted from the actual CSS-variable set, and --sidebar-background was never a real token (the app uses bare --sidebar).

Suggested fix

Add --popover, --popover-foreground, and --sidebar (and audit for any other base globals.css tokens not listed); drop the non-existent --sidebar-background. Better still: derive the blocklist from the tokens actually declared in the shipped themes, or block any --color-* / known-prefix custom property, instead of enumerating by hand so it can't drift again.


AI-investigated against v2.0.6; reproduced by running the real sanitizer. Please confirm before fixing.

Originally created by @kolacheee on GitHub (Jun 28, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2951 Originally assigned to: @SpicyMarinara on GitHub. **What's wrong** Card CSS is blocked from redefining the app's theme color tokens, so a malicious or sloppy card can't repaint the whole app through them. That blocklist has drifted out of sync with the real tokens: - It's **missing** `--popover`, `--popover-foreground`, and the base `--sidebar` — all real, defined, used app tokens — so a card **can** override them. - It **lists** `--sidebar-background`, which isn't defined anywhere in the app, so that entry matches nothing. Impact is bounded (card CSS is scoped to the chat container), but it's a real gap in a guard that's meant to be exhaustive, plus a dead entry. **How to reproduce (try it yourself)** 1. In a card's creator-notes `<style>`: `:root { --background: red; --popover: red; --sidebar: lime; }` 2. Open a chat with card CSS enabled and inspect `#marinara-card-css`. **You'll see** (verified by running the actual sanitizer): ``` .mari-card-css { --popover: red; --sidebar: lime; } ``` `--background` is correctly stripped, but `--popover` and `--sidebar` survive. **Expected:** all app theme tokens — including `--popover`, `--popover-foreground`, and `--sidebar` — are stripped from card CSS. **Where it is** `packages/client/src/lib/card-css.ts` — `THEME_TOKEN_BLOCKLIST` lines 111-149 (lists `--sidebar-background` at 130; lacks `--popover`, `--popover-foreground`, and bare `--sidebar`), consumed by the theme-strip pass at 402-408. The tokens are defined in `packages/client/src/styles/globals.css` (`--popover` line 184, `--popover-foreground` 185, `--sidebar` 200) and consumed via `--color-popover: var(--popover)` / `--color-sidebar: var(--sidebar)` (113-114, 128). `--sidebar-background` is defined nowhere in the stylesheet. **What's happening** The token list is hand-maintained and drifted from the actual CSS-variable set, and `--sidebar-background` was never a real token (the app uses bare `--sidebar`). **Suggested fix** Add `--popover`, `--popover-foreground`, and `--sidebar` (and audit for any other base `globals.css` tokens not listed); drop the non-existent `--sidebar-background`. Better still: derive the blocklist from the tokens actually declared in the shipped themes, or block any `--color-*` / known-prefix custom property, instead of enumerating by hand so it can't drift again. --- *AI-investigated against v2.0.6; reproduced by running the real sanitizer. Please confirm before fixing.*
Author
Owner

@SpicyMarinara commented on GitHub (Jun 28, 2026):

Fixed on staging: the card-CSS theme-token guard now strips popover/sidebar theme tokens and related color aliases.

<!-- gh-comment-id:4827784870 --> @SpicyMarinara commented on GitHub (Jun 28, 2026): Fixed on staging: the card-CSS theme-token guard now strips popover/sidebar theme tokens and related color aliases.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1527
No description provided.