Skip to content

Sanitizer: block data:/vbscript: URLs (XSS hardening)#42549

Merged
mdo merged 5 commits into
v6-devfrom
mdo/sanitizer-block-data-url
Jun 28, 2026
Merged

Sanitizer: block data:/vbscript: URLs (XSS hardening)#42549
mdo merged 5 commits into
v6-devfrom
mdo/sanitizer-block-data-url

Conversation

@mdo

@mdo mdo commented Jun 24, 2026

Copy link
Copy Markdown
Member

Problem (security)

The HTML sanitizer's SAFE_URL_PATTERN only rejected javascript:, so a data:text/html,… (or vbscript:) URL in an href/src passed the attribute allowList. Via data-bs-title/data-bs-content (with html: true or a permissive allowList) that's an XSS vector.

Fix

  • SAFE_URL_PATTERN now also rejects data: and vbscript:.
  • Restored a DATA_URL_PATTERN (as in earlier Bootstrap) that re-allows only safe base64 image/video/audio data URLs, so legitimate data:image/* sources keep working while data:text/html is blocked.

Verification

  • Added the dangerous URLs (data:text/html,…, base64 text/html, vbscript:) to the sanitizer's invalid-URL test; existing valid data:image|video|audio base64 URLs still pass.
  • Full unit suite passes; lint clean.

Fixes #42443.

The sanitizer's SAFE_URL_PATTERN only rejected javascript:, so a
data:text/html (or vbscript:) URL in an href/src passed the allowList —
an XSS vector via data-bs-title/data-bs-content. Reject data: and
vbscript: in SAFE_URL_PATTERN and re-allow only safe base64 image/video/
audio data URLs via a restored DATA_URL_PATTERN. Fixes #42443.
@mdo mdo requested a review from a team as a code owner June 24, 2026 17:07
Comment thread js/src/util/sanitizer.js Fixed
@mdo mdo added this to v6.0.0 Jun 27, 2026
@github-project-automation github-project-automation Bot moved this to Inbox in v6.0.0 Jun 27, 2026
mdo added 3 commits June 27, 2026 14:49
…-data-url

# Conflicts:
#	.bundlewatch.config.json
\d already matches 0-9, so the explicit 0-9 in the same class was dead
weight. Functionally identical; clears the CodeQL overly-permissive-range
alert on the overlap.
@mdo mdo merged commit 947f112 into v6-dev Jun 28, 2026
12 checks passed
@mdo mdo deleted the mdo/sanitizer-block-data-url branch June 28, 2026 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Inbox

Development

Successfully merging this pull request may close these issues.

2 participants