[PR #2425] [MERGED] Strip style attribute from game AnimatedText sanitizer #5603

Closed
opened 2026-10-22 04:17:44 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2425
Author: @Romuromylus
Created: 6/6/2026
Status: ✅ Merged
Merged: 6/6/2026
Merged by: @Romuromylus

Base: refactor ← Head: fix/animatedtext-no-style-attr


📝 Commits (1)

  • 4160809 Strip style attribute from game AnimatedText sanitizer

📊 Changes

2 files changed (+39 additions, -3 deletions)

View changed files

📝 src/features/modes/game/components/AnimatedText.tsx (+5 -3)
📝 src/styles/globals.css (+34 -0)

📄 Description

Linked issue

Closes #2367

Why this change

  • Game-mode AnimatedText renders raw model choice/map text and allowed the style attribute in its DOMPurify config. Model output could therefore inject style="position:fixed;background:url(...)" — a CSS-exfil beacon (the URL fires on render; tauri.conf.json has security.csp = null) or a clickjacking overlay. The sibling game-narration-format.ts already allows only ["class"].

What changed

  • src/features/modes/game/components/AnimatedText.tsx: dropped "style" from both DOMPurify ALLOWED_ATTR arrays (the component useMemo and animateTextHtml), so they now allow class only — matching the sibling narration formatter.
  • The one legitimate inline-style use (a per-character wave-animation delay) is relocated onto pre-defined index-bucket CSS classes anim-text-wave-char-0…9 (char index mod 10) in src/styles/globals.css, so the wave animation is unchanged while arbitrary style is stripped.

Refactor impact

Primary owner: game mode

Impact areas reviewed:

  • src/features/modes/game/components/AnimatedText.tsx (both sanitizer configs + wave wrapping)
  • src/styles/globals.css (wave-delay buckets)

Boundary notes:

  • None. The only inline-style carriers in this component were the attacker vector and the wave delay (now class-driven). No Rust touched. Mod-10 bucketing is identical for ≤10-char wave spans and cosmetically repeats the cascade for longer spans.

Pressure points touched:

  • GameSurface (AnimatedText is a game-mode render component).

Validation

  • Matching validation command passes locally
  • Full pnpm check passes before PR push/handoff
  • Human/manual validation completed by contributor or reviewer

Manual verification notes

  • pnpm vitest run (jsdom AnimatedText) — local-only tests confirmed a malicious style="position:fixed;background:url(evil…)" choice string renders with no style attribute / no position:fixed / no beacon URL in the DOM (text content preserved), and the per-char wave spans still carry their anim-text-wave-char-N delay classes with no inline style.
  • pnpm exec tsc -b — clean.

Feature Discoverability

  • Updated src/features/shell/discovery/
  • N/A because this PR is a security hardening fix.

Reason:

  • No new discoverable surface; the wave animation is visually unchanged.

Docs and release impact

  • No docs changes needed

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/2425 **Author:** [@Romuromylus](https://github.com/Romuromylus) **Created:** 6/6/2026 **Status:** ✅ Merged **Merged:** 6/6/2026 **Merged by:** [@Romuromylus](https://github.com/Romuromylus) **Base:** `refactor` ← **Head:** `fix/animatedtext-no-style-attr` --- ### 📝 Commits (1) - [`4160809`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4160809a8838107ea3f3db19dcaf3a3238a7120a) Strip style attribute from game AnimatedText sanitizer ### 📊 Changes **2 files changed** (+39 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/features/modes/game/components/AnimatedText.tsx` (+5 -3) 📝 `src/styles/globals.css` (+34 -0) </details> ### 📄 Description ## Linked issue Closes #2367 ## Why this change - Game-mode `AnimatedText` renders raw model choice/map text and allowed the `style` attribute in its DOMPurify config. Model output could therefore inject `style="position:fixed;background:url(...)"` — a CSS-exfil beacon (the URL fires on render; `tauri.conf.json` has `security.csp = null`) or a clickjacking overlay. The sibling `game-narration-format.ts` already allows only `["class"]`. ## What changed - `src/features/modes/game/components/AnimatedText.tsx`: dropped `"style"` from both DOMPurify `ALLOWED_ATTR` arrays (the component `useMemo` and `animateTextHtml`), so they now allow `class` only — matching the sibling narration formatter. - The one legitimate inline-style use (a per-character wave-animation delay) is relocated onto pre-defined index-bucket CSS classes `anim-text-wave-char-0…9` (char index mod 10) in `src/styles/globals.css`, so the wave animation is unchanged while arbitrary `style` is stripped. ## Refactor impact Primary owner: game mode Impact areas reviewed: - `src/features/modes/game/components/AnimatedText.tsx` (both sanitizer configs + wave wrapping) - `src/styles/globals.css` (wave-delay buckets) Boundary notes: - None. The only inline-`style` carriers in this component were the attacker vector and the wave delay (now class-driven). No Rust touched. Mod-10 bucketing is identical for ≤10-char wave spans and cosmetically repeats the cascade for longer spans. Pressure points touched: - GameSurface (AnimatedText is a game-mode render component). ## Validation - [x] Matching validation command passes locally - [ ] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes - `pnpm vitest run` (jsdom AnimatedText) — local-only tests confirmed a malicious `style="position:fixed;background:url(evil…)"` choice string renders with no `style` attribute / no `position:fixed` / no beacon URL in the DOM (text content preserved), and the per-char wave spans still carry their `anim-text-wave-char-N` delay classes with no inline style. - `pnpm exec tsc -b` — clean. ## Feature Discoverability - [ ] Updated `src/features/shell/discovery/` - [x] N/A because this PR is a security hardening fix. Reason: - No new discoverable surface; the wave animation is visually unchanged. ## Docs and release impact - [x] No docs changes needed --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:17:44 +07:00
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#5603
No description provided.