Skip to content

fix(ssr): escape bq-text values on raw-text elements in pure renderer - #183

Merged
JosunLP merged 2 commits into
devfrom
fix/163-ssr-bq-text-raw-escape
Jul 6, 2026
Merged

fix(ssr): escape bq-text values on raw-text elements in pure renderer#183
JosunLP merged 2 commits into
devfrom
fix/163-ssr-bq-text-raw-escape

Conversation

@JosunLP

@JosunLP JosunLP commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #163 (Critical).

In the default pure SSR renderer, setText wrote bq-text values verbatim as text children, and serializeTree emits text inside raw-text elements (script/style/textarea/title) without escaping. An untrusted value like </textarea><img src=x onerror=alert(1)> closed the element and injected live markup — stored XSS in the default backend on Node/Bun/Deno.

Fix

setText now escapes via escapeText when the target element is raw (el.raw), exactly mirroring the pre-existing bq-model reflection handling (which already named this hazard). The bq-model call site now reuses the centralized logic.

Verification

  • Regression tests for <textarea bq-text> and <title bq-text> with the audit payloads, run against both backends (dom + pure), plus a no-double-escaping check for normal elements.
  • Confirmed the new tests fail on the unfixed code (2 failures on the pure backend) and pass with the fix.
  • Full SSR suite: 292 pass / 0 fail. tsc --noEmit clean.

🤖 Generated with Claude Code

setText wrote evaluated bq-text values verbatim as text children, and
serializeTree emits text inside raw-text elements (script/style/textarea/
title) without escaping. An untrusted value like
'</textarea><img src=x onerror=alert(1)>' could therefore close the
element and inject live markup (stored XSS in the default backend on
Node/Bun/Deno).

setText now escapes when the target is a raw-text element, mirroring the
existing bq-model reflection handling; the bq-model call site reuses it.

Fixes #163

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: 3df4f6df-9433-43a6-b0fe-2d82e02a3141

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/163-ssr-bq-text-raw-escape

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
JosunLP merged commit b5828a7 into dev Jul 6, 2026
5 of 6 checks passed
@JosunLP
JosunLP deleted the fix/163-ssr-bq-text-raw-escape branch July 6, 2026 19:10
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