Security: DOM XSS risk from unescaped plugin template fields in clear_button#1018
Open
tuanaiseo wants to merge 2 commits into
Open
Conversation
…ields The default `html` renderer builds an HTML string using `className`, `title`, `role`, and `tabindex` via string interpolation, then parses it with `getDom()`. If any of these option values are attacker-controlled (for example, passed from untrusted JSON config), attribute injection and script execution are possible. Affected files: plugin.ts, plugin.ts Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
…ields The default `html` renderer builds an HTML string using `className`, `title`, `role`, and `tabindex` via string interpolation, then parses it with `getDom()`. If any of these option values are attacker-controlled (for example, passed from untrusted JSON config), attribute injection and script execution are possible. Affected files: plugin.ts, plugin.ts Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
xJuvi
suggested changes
Apr 6, 2026
| html: (data:CBOptions) => { | ||
| const div = document.createElement('div'); | ||
| const className = (data.className || '').split(/\s+/).filter(token => /^[A-Za-z0-9_-]+$/.test(token)).join(' '); | ||
| const role = data.role === 'button' ? data.role : 'button'; |
Contributor
There was a problem hiding this comment.
This is every time "button"? When data.role is button, then we use here data.role, otherwise it's hard coded 'button'. It doesn't make sense i think.
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.
Problem
The default
htmlrenderer builds an HTML string usingclassName,title,role, andtabindexvia string interpolation, then parses it withgetDom(). If any of these option values are attacker-controlled (for example, passed from untrusted JSON config), attribute injection and script execution are possible.Severity:
highFile:
src/plugins/clear_button/plugin.tsSolution
Avoid string-built HTML for option-driven values. Create elements with
document.createElement, assigntextContent, and set attributes viasetAttributeafter strict allowlisting/validation (roleenum, numerictabindex, safe class token pattern). If templating is required, escape all interpolated values.Changes
src/plugins/clear_button/plugin.ts(modified)src/plugins/dropdown_header/plugin.ts(modified)Testing