Skip to content

Security: Potential XSS in HTML rendering bridge (unsanitized attributes/URLs)#1009

Open
tomaioo wants to merge 2 commits intoijry:3.xfrom
tomaioo:fix/security/potential-xss-in-html-rendering-bridge-u
Open

Security: Potential XSS in HTML rendering bridge (unsanitized attributes/URLs)#1009
tomaioo wants to merge 2 commits intoijry:3.xfrom
tomaioo:fix/security/potential-xss-in-html-rendering-bridge-u

Conversation

@tomaioo
Copy link
Copy Markdown

@tomaioo tomaioo commented Apr 24, 2026

Summary

Security: Potential XSS in HTML rendering bridge (unsanitized attributes/URLs)

Problem

Severity: High | File: src/static/app-plus/mp-html/js/handler.js:L1

The mp-html bridge renderer builds DOM nodes from provided content and applies attributes directly via setAttribute without a visible allowlist/sanitization step. If untrusted HTML/content reaches window.setContent(...), attacker-controlled attributes such as dangerous href/src values (e.g., javascript: / data: payloads depending on runtime behavior) or other injected markup could execute script in the embedded webview context.

Solution

Add strict sanitization before DOM construction: use an allowlist of tags and attributes, explicitly strip event-handler attributes (on*), and validate URL-bearing attributes (src, href, xlink:href) to only permit safe schemes (e.g., https:). Consider using a vetted sanitizer (DOMPurify-equivalent for the target runtime) before calling setContent.

Changes

  • src/static/app-plus/mp-html/js/handler.js (modified)
  • src/static/app-plus/up-canvas/local.html (modified)

tomaioo added 2 commits April 23, 2026 23:18
The mp-html bridge renderer builds DOM nodes from provided content and applies attributes directly via `setAttribute` without a visible allowlist/sanitization step. If untrusted HTML/content reaches `window.setContent(...)`, attacker-controlled attributes such as dangerous `href/src` values (e.g., `javascript:` / `data:` payloads depending on runtime behavior) or other injected markup could execute script in the embedded webview context.

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
The mp-html bridge renderer builds DOM nodes from provided content and applies attributes directly via `setAttribute` without a visible allowlist/sanitization step. If untrusted HTML/content reaches `window.setContent(...)`, attacker-controlled attributes such as dangerous `href/src` values (e.g., `javascript:` / `data:` payloads depending on runtime behavior) or other injected markup could execute script in the embedded webview context.

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

2 participants