mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2944] [Issue]: Shared themes can silently phone home — theme/extension CSS skips the safety filter the code requires #1523
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1523
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Jun 28, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2944
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
Custom themes look harmless — a theme has a CSS field and no JavaScript field, so people treat a shared theme as "just colors and fonts." But the app injects theme CSS into the page completely raw, with no safety filtering. The codebase already ships a CSS safety filter,
stripDangerousCss, and its own comment says theme and extension CSS must be run through it — but none of the theme/extension CSS paths actually call it.So a shared theme can quietly phone home: a single
background-image: url("https://attacker/...")makes the victim's browser hit an attacker's server the moment the theme is active (leaking that they use the app, their IP, rough timing — and it can be used as a tracking/exfil beacon). No JavaScript needed.The same missing-filter gap is in four places, all one root cause:
addStyle()helper handed to extension JS.The important context: character-card CSS (also untrusted, also shared between users) is already run through
stripDangerousCss+ scoping. Themes and extensions are the exact same threat model — content authored by someone else and shared around (the UI even points users to Discord for them) — they just never got wired through the filter.How to reproduce (try it yourself)
evil-theme.csscontaining:You'll see: an outbound GET to
attacker.examplefire immediately (and again on every keystroke while editing, and permanently once you Save — saving auto-activates the theme).Expected: a cosmetic theme makes no outbound network requests. The existing filter would rewrite the external
url()tourl(about:invalid), exactly as it already does for card CSS.Accurate note on the shipped CSP (so this isn't over-claimed): the production server sets a Content-Security-Policy that already blocks the remote
@importand remote@font-facevariants of this — good. Butimg-srcis'self' data: blob: https:, so thebackground-image: url(https://…)beacon above still goes through in production. And in dev mode (pnpm dev, where Vite serves the HTML) there is no CSP at all, so every variant fires — which matters for contributors testing each other's themes.Secondary, related (not fixed by the filter): the same raw injection lets a theme paint a full-window
position: fixedoverlay (e.g. a fake login box).stripDangerousCssintentionally allows positioning because legitimate full-app themes need it, so the filter won't stop an overlay — if overlay/clickjacking from themes is a concern, that's a separate design call. The exfiltration above is the clean, filter-fixable part.Where it is
All four sinks bypass the filter:
packages/client/src/components/layout/CustomThemeInjector.tsx:74— active theme:style.textContent = normalizeThemeCss(activeTheme.css)packages/client/src/components/panels/SettingsPanel.tsx:3359— live preview:style.textContent = normalizeThemeCss(themeCss)(effect at 3347-3366; fires fromopenEditThemeat 3375;livePreviewdefaultstrueat 3345)CustomThemeInjector.tsx:93— extension CSS:style.textContent = ext.cssCustomThemeInjector.tsx:150-157— theaddStyle()extension API:style.textContent = cssnormalizeThemeCss(packages/client/src/lib/theme-css.ts) only de-escapes\n \r \t; it does zero security filtering. The filter that should run,stripDangerousCss, lives atpackages/client/src/lib/card-css.ts:322, and the contract is spelled out right there atcard-css.ts:311-321("…app-level theme and extension CSS … so it must be run through THIS function…"). A repo-wide search showsstripDangerousCssis only ever called fromsanitizeChatCss(card CSS), never for themes or extensions.What's happening
The theme/extension CSS injection paths were written to use the cosmetic
normalizeThemeCss(or rawext.css) instead of the security filter, so externalurl(),@import,:visited,expression(), etc. all reach a document-level<style>unmodified. The filter exists and already handles all of this for cards — it just isn't called here.Suggested fix
Wrap each of the four sinks in the existing filter, e.g.:
Use
stripDangerousCss, notsanitizeChatCss/scopeChatCss— those add card-only scoping and neuterposition:fixed, which would break legitimate full-app themes.stripDangerousCsskeeps theme tokens,!important, and positioning while removing the network/exfiltration constructs (externalurl(),@import,@namespace, non-data@font-face,:visited,expression(),javascript:/vbscript:,behavior,-moz-binding). A single shared wrapper for all four sites keeps them consistent. Optionally also sanitize server-side inthemes.storage.tson write for defense-in-depth.AI-investigated against v2.0.6; all cited lines were read and the repro verified. Please confirm before fixing.
@SpicyMarinara commented on GitHub (Jun 28, 2026):
Fixed on staging: app-level theme/extension CSS sinks now run through the shared dangerous-CSS filter before injection, including active themes, live preview, extension CSS, and extension
addStyle().