mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #2586] [MERGED] fix(chat): harden card CSS sanitizer against escape-sequence evasion #5671
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#5671
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?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2586
Author: @kolacheee
Created: 6/16/2026
Status: ✅ Merged
Merged: 6/16/2026
Merged by: @SpicyMarinara
Base:
staging← Head:feat/staging-cardcss-sanitizer-hardening📝 Commits (2)
e6fe37afix(chat): harden card CSS sanitizer against escape-sequence evasion3e8c3d9Merge branch 'staging' into feat/staging-cardcss-sanitizer-hardening📊 Changes
1 file changed (+30 additions, -1 deletions)
View changed files
📝
packages/client/src/components/chat/ChatMessage.tsx(+30 -1)📄 Description
Linked issue
Closes #2577
Why this change
stagingrenders creator card CSS through an inline<style>sanitizer inChatMessage.tsxthat is a regex blocklist over raw text. The CSS engine decodes escape sequences (\XXhex,\c), so a guard matching literal keyword text can be bypassed by spelling the token with escapes — e.g.\75rl(//evil)evades theurl()guard,po\73ition/expre\73sion(/@\69mport/beha\76ior:all slip past. This is the same gap #2020 fixed onrefactor; porting it closes it onstaging.What changed
canonicalizeKeywordEscapes()(withdecodeCssEscapes()+ aSTRING_OR_ESCAPEscanner) and run it at the top ofsanitizeChatCss, before the existing guards.@, or-, so the literal-text guards see the tokens the browser would actually parse..\32 xland.w-1\/2and legitcontent: "…"strings stay byte-exact.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Automated:
tsc -b+ ESLint pass for the client. Ran the exact ported sanitizer logic against a bypass/benign matrix — 7/7: escapedexpression(),javascript:,@import,behavior:, and a non-https escapedurl()are all neutralized; a digit-escape selector (.\32 xl) and an escape inside a string literal are preserved unchanged.To verify manually in-browser (TO-DO): put card CSS like
.x{ ba\63kground: \75rl(//example.test/p.png) }in a character's creator notes and confirm no external request is made / the rule is neutralized, and that a normal Tailwind-ish selector with an escaped digit still renders.Docs and release impact
Assessment (please confirm): internal hardening — no docs/version changes expected.
UI evidence (if applicable)
N/A — no visual change for well-formed CSS.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.