`<style>` and `<script>` children inside MathML are not escaped in SSR (and static DOM templates), allowing markup injection

オープン
#4,704 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@santhiprakash がすでに取り組んでいます。

2026年11月7日 から。

  • #598 @santhiprakash による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript, typescript
領域
frontend, security

調査の方向性

Start in packages/babel-plugin-jsx-dom-expressions/src/shared/utils.js at isRawTextElement(path) and read the existing SVG handling and related tests. Reproduce the MathML case in both SSR and static DOM template generation, including the noted integration points. Done means dynamic children are escaped in those cases while the reported SVG behavior remains correct.

索引モデルが issue の本文から書いたものです。

説明

In solid-js 1.9.18 (babel-preset-solid 1.9.16 / babel-plugin-jsx-dom-expressions 0.40.11, Node v24.14.1), renderToString (compiled with generate: "ssr") and static DOM templates (generate: "dom") treat <style> and <script> children inside MathML (<math>) as raw text (doNotEscape), omitting HTML escaping of < and & and allowing dynamic text children to break out of <style>/<script> and <math> to inject arbitrary HTML markup.

// Compiled with babel-preset-solid { generate: "ssr" }
import { renderToString } from "solid-js/web";

const MathStyle = (props) => <math><style>{props.x}</style></math>;
const MathScript = (props) => <math><script>{props.x}</script></math>;
const SvgStyle = (props) => <svg><style>{props.x}</style></svg>;

console.log(renderToString(() => <MathStyle x="</style><b>x</b>" />));
console.log(renderToString(() => <MathScript x="</script><b>x</b>" />));
console.log(renderToString(() => <SvgStyle x="</style><b>x</b>" />));

Expected:

<math><style>&lt;/style>&lt;b>x&lt;/b></style></math>
<math><script>&lt;/script>&lt;b>x&lt;/b></script></math>
<svg><style>&lt;/style>&lt;b>x&lt;/b></style></svg>

Actual:

<math><style></style><b>x</b></style></math>
<math><script></script><b>x</b></script></math>
<svg><style>&lt;/style>&lt;b>x&lt;/b></style></svg>

Per the WHATWG HTML parsing specification (§13.2.5.54 / §13.2.6.5), <script> and <style> only switch the tokenizer into rawtext/script data states in the HTML namespace; inside foreign content (both SVG and MathML), they remain in the normal data state where < and & are parsed as markup and character references.

In packages/babel-plugin-jsx-dom-expressions/src/shared/utils.js, isRawTextElement(path) checks for <svg> and SVGElements (added in ryansolid/dom-expressions#590) to keep SVG <style>/<script> children escaped, but does not check <math> or MathML elements (nor MathML HTML/MathML integration points like <annotation-xml>), so MathML falls through to doNotEscape = true. (Relatedly, for HTML <style>{props.x}</style>, dynamic children are emitted verbatim without neutralizing closing </style>/</script> sequences.)

Credit: https://ucsbplse.github.io/

主要言語
TypeScript
スター
36.2k
フォーク
1.1k
平均マージ
9時間
マージ済み PR(30日)
463

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

solidjs/solid のほかの issue

solidjs/solid の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。