Fix XSS in semantic HTML export: escape code-block language#4818
Open
LeeSeungjae00 wants to merge 1 commit into
Open
Fix XSS in semantic HTML export: escape code-block language#4818LeeSeungjae00 wants to merge 1 commit into
LeeSeungjae00 wants to merge 1 commit into
Conversation
The language value was interpolated into the data-language attribute without escaping, allowing XSS via getSemanticHTML(). Fixes slab#4789
|
Review (via AI-assisted code review): APPROVE This is a correct, minimal fix for a real XSS vector.
Notes (non-blocking): this overlaps with #4774 (which contains the identical one-line syntax fix plus broader changes) and #4788 — whichever lands first, the others should rebase and drop the duplicate hunk. No CI runs have executed on this fork head, so please trigger the unit suite before merge. |
This was referenced Jul 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4789.
SyntaxCodeBlockContainer.html()interpolates the code block's language value into thedata-languageattribute without escaping, while the code content itself goes throughescapeText(). The language can be set to an arbitrary string viaformatLine(0, 1, 'code-block', value)(or crafted pasted content), so a value like"><img src=x onerror="alert(1)">breaks out of the attribute and executes script wherever the output ofgetSemanticHTML()is rendered.This is the remaining code path not covered by #4774, which fixes the same pattern in the formula and video formats. Related advisory: GHSA-v3m3-f69x-jf25 (CVE-2025-15056).
Fix
Wrap the language value with the existing
escapeText()helper — the same one-line pattern already used for the code content on the next line.Testing
<imgpayload present in the output; with the fix it passes.🤖 Generated with Claude Code