Skip to content

fix(web): escape fenced code language attributes - #10

Draft
lukisch wants to merge 1 commit into
mainfrom
fix/code-fence-language-escape-20261015
Draft

lukisch wants to merge 1 commit into
mainfrom
fix/code-fence-language-escape-20261015

Conversation

@lukisch

@lukisch lukisch commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

The web renderer inserts a fenced code block's language string directly into a quoted HTML class attribute. A quote followed by an img tag breaks out of that attribute and becomes additional markup in the preview. Escape this string with the existing HTML-escaping function before interpolation.

Add six Node built-in renderer tests that execute the shipped render functions without evaluating their HTML. Four malicious/attribute-special-character cases fail on exact base 0aea162 and pass after the fix. Ordinary language/body escaping and Unicode remain covered. Run these tests explicitly with Node22 in the existing eight native Windows/Linux CI cells.

Validation: 6 renderer cases and 9 existing web-companion tests pass locally; workflow YAML parses; git diff --check passes. Native CI and independent review remain pending. No version, dependencies of the application, release, service-worker cache or runtime mirror change.

Related to CodeQL alert3's preview HTML sink. This fixes the reproduced code-fence attribute injection only; it does not establish complete sanitizer safety or resolve every alert flow. Do not dismiss the alert on this evidence alone. No browser exploit was executed.

Author model: gpt-6.1-sol (Codex). Draft only; merges disabled. Independent model review pending.

Generated-with: gpt-6.1-sol (Codex)

lukisch commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

Zweitprüfung (Cloud-Bot), Head 10ab7ed: Code freigabereif, CI-Stand veraltet.

  • Fix: escapeHtml(codeBlockLang) im Fence-Renderer (web_companion/app.js) schließt den Attribut-Ausbruch über class="language-…". Der Körper wurde schon vorher escaped; es ist die einzige Stelle, an der codeBlockLang ungeprüft eingesetzt wurde.
  • Tests: tests/test_web_renderer.cjs führt den ausgelieferten Renderer in vm aus und wertet das HTML nicht aus. Die Assertion prüft die exakte Tag-Folge (<pre>, ein <code class=…>, </code>, </pre>). Damit fällt ein eingeschleustes <img> sicher auf. Die Fälle ">``&lt;img …&gt;'``, " onmouseover=", '<> &und">…` decken Quote-Breakout und Doppel-Escaping ab.
  • CI: Alle Windows-Zellen, Linux 3.12/3.13, Flutter und CodeQL sind grün. Rot sind nur Linux 3.10/3.11. Das ist die PySide6-6.12.0-Regression (none_dealloc in highlightBlock), nicht dieser Diff. Die Gegenmaßnahme !=6.12.0 liegt laut Kommentar in fix(deps): exclude Qt 6.12.0 highlighter refcount regression #11 bereits in main.
  • Offen: Der Head basiert auf 0aea162, main ist seitdem weitergelaufen. Bitte main einmergen und die CI neu laufen lassen. Der Node-Schritt ist dabei der eigentliche Nachweis, denn die Renderer-Tests laufen nur dort.
  • CodeQL-Alert 3: Wie in der Beschreibung steht, belegt das nur diesen Sink. Den Alert nicht allein darauf schließen.

Ein formales Approve ist nicht möglich, weil der PR vom selben Account stammt. Der Draft-/Merge-Hold bleibt unberührt.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant