Skip to content

fix(ssr): validate bq-style declarations in the pure renderer - #196

Merged
JosunLP merged 3 commits into
devfrom
fix/176-bq-style-css-injection
Jul 6, 2026
Merged

fix(ssr): validate bq-style declarations in the pure renderer#196
JosunLP merged 3 commits into
devfrom
fix/176-bq-style-css-injection

Conversation

@JosunLP

@JosunLP JosunLP commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #176 (Low; CSS injection — no HTML breakout).

The DOM-free setStyle concatenated bq-style property names and values into the inline style attribute with no CSS-level validation. Attribute escaping prevents HTML breakout, but an untrusted style value like x;} body{display:none injected extra declarations/rules (UI-redress/clickjacking, exfiltration via background: url(...)).

Fix

setStyle (pure renderer) now drops any declaration whose property name is not a valid CSS identifier (--custom or kebab-case) or whose value contains injection characters (;, {, }, <). The DOM-backed renderer was already safe — it writes via CSSStyleDeclaration.setProperty, which rejects malformed values.

Verification

  • New tests across both backends: a malicious width: 'x;} body{display:none' is dropped; safe declarations (color, marginTop) pass through. The malicious case fails on the pre-fix pure renderer.
  • SSR suites: all pass. tsc --noEmit clean.

🤖 Generated with Claude Code

The DOM-free setStyle concatenated bq-style property names and values into
the inline style attribute with no CSS-level validation. Attribute
escaping stops HTML breakout, but an untrusted value like
'x;} body{display:none' still injected extra declarations/rules
(UI-redress, exfiltration via background url()).

setStyle now drops declarations whose property is not a valid CSS
identifier or whose value contains injection characters (; { } <). The
DOM-backed renderer was already safe (it writes via CSSStyleDeclaration).

Fixes #176

Co-Authored-By: Claude Fable 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 48a8baf5-1dd4-45ee-84ad-509068453fbe

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/176-bq-style-css-injection

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added tests Chenges to the tests ssr Changes to the ssr module labels Jul 6, 2026
JosunLP and others added 2 commits July 6, 2026 21:48
The dev merge concatenated the #176 and #163 EOF test appends and dropped
the closing braces of the #176 block, breaking type-check.

Co-Authored-By: Claude Fable 5 <[email protected]>
@JosunLP
JosunLP merged commit 4050f24 into dev Jul 6, 2026
9 checks passed
@JosunLP
JosunLP deleted the fix/176-bq-style-css-injection branch July 6, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ssr Changes to the ssr module tests Chenges to the tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant