mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #1989] Card CSS sanitizer: escape sequences can bypass regex guards (needs tokenizer-level normalization) #974
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#974
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 2, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1989
Originally assigned to: @kolacheee on GitHub.
Summary
The card-CSS sanitizer in
src/shared/lib/chat-css.ts(sanitizeChatCss) is regex-based. CSS identifier escape sequences (\XXhex escapes and\cliteral escapes) let untrusted card CSS spell guarded tokens in a form the regexes don't match but the engine still parses. This is a pre-existing limitation of the regex approach, surfaced during review of #1812.Known bypass vectors
background: \75rl(https://tracker.test/pixel)parses asurl(...)but evades theurl(allowlist → external request. Same idea for@import.@font-facesource gate:src: l\6f cal("Inter")parses aslocal(...)and evades the literallocal(rejection.po\73ition: fixed,--back\67round: red, and escaped!importantevade the fixed→absolute conversion, theme-token blocklist, and!importantstrip respectively.Why this wasn't fixed in #1812
Both regex-only approaches fail:
w-1\/2class, escaped code points incontentstrings).Robust coverage needs a CSS tokenizer/parser pass: decode escapes per-token for the dangerous-construct checks, but re-emit benign tokens verbatim. That's a focused change to a security-critical function and is out of scope for the #1812 feature PR, so it was reverted there (see eee7e004) and split out here.
Suggested approach
Tokenize declarations/at-rules/selectors, run the existing guards against an escape-decoded analysis form, and reserialize preserving original benign tokens. (CodeRabbit/Bunny review threads on #1812 have detailed write-ups of each vector.)
Scope note
Card CSS is already scoped + DOMPurify-sanitized at the HTML layer; this is about the CSS sanitizer's network/anti-spoofing guards specifically. Relates to #1812.
@kolacheee commented on GitHub (Jun 2, 2026):
gonna work on it tomorrow 🛌