Skip to content

fix: strip object/embed tags in sanitizeHtmlForMdx - #7530

Merged
hivecommons-hive[bot] merged 1 commit into
mainfrom
sec/fix-sanitize-object-embed
Oct 28, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
mainfrom
sec/fix-sanitize-object-embed

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Security Fix

sanitizeHtmlForMdx (the primary XSS defense for user-supplied MDX content) stripped <script>, <style>, and <iframe> tags but left <object> and <embed> tags completely untouched, including dangerous javascript:/data: URIs in their data=/src= attributes. This change strips both tags using the same open/close pair + lone-opener pattern already used for <iframe>, in both the early removal pass and the stripDangerousPatterns stability loop (for spacer-attack resistance), plus unit tests that fail without the fix.

Fixes #7529


Filed by sec-check agent (ACMM L6 — full mode)

— hive: agent=sec-check backend=copilot model=claude-opus-4.7 copilot=1.0.88

These tags were not covered by the existing <script>/<style>/<iframe>
stripping, allowing e.g. <object data="javascript:..."> or
<embed src="data:text/html,..."> to survive sanitization and execute
same-origin in rendered MDX content.

Signed-off-by: sec-check <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 28, 2026
@kubestellar-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify

netlify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for kubestellar-docs ready!

Name Link
🔨 Latest commit 556f211
🔍 Latest deploy log https://app.netlify.com/projects/kubestellar-docs/deploys/6ae25bd5097f1c5e32e7b0d5
😎 Deploy Preview https://deploy-preview-7530--kubestellar-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@kubestellar-prow kubestellar-prow Bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 28, 2026
@kubestellar-prow

Copy link
Copy Markdown

Hi @hivecommons-hive[bot]. Thanks for your PR.

I'm waiting for a kubestellar member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read the sanitizer at merge base and the full diff. Verified at base src/lib/sanitizeHtml.ts that <object>/<embed> were indeed never stripped anywhere (only script/style/iframe, meta/link/base), so the gap in #7529 is real. The fix mirrors the existing iframe idiom exactly: early-pass stripUntilStable pair+lone-opener removal (src/lib/sanitizeHtml.ts:251-258) plus the same patterns inside the stripDangerousPatterns stability loop (src/lib/sanitizeHtml.ts:156-163), so spacer reconstruction (e.g. <obj<script>…</script>ect>) is caught on the next outer iteration. Tests fail without the fix and cover both paired and self-closing forms.

One parity note (info, not a defect): like <iframe>, a truncated opener with no closing > at end-of-input (e.g. <object data="javascript:… at EOF) is not removed — only script/style get the pass-3 partial-opener treatment via stripTagUntilClean. An unterminated tag doesn't render, and the fuzz gate passed, so this is fine as-is; worth folding iframe/object/embed into stripTagUntilClean someday for uniformity.

Looks correct to me. CI (unit, fuzz, CodeQL) is green; a maintainer can take it from here.

— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88

@hivecommons-hive
hivecommons-hive Bot merged commit e880ea7 into main Oct 28, 2026
19 of 20 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the sec/fix-sanitize-object-embed branch October 28, 2026 21:19
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author
Evidence bundle `#7530556f211` sha256:fd3c11cec9e64bf1d142ad7959929d724cb20edfde14af863d9f82c46156c44c — download from the dashboard or `hivectl review evidence #7530`.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

@hivecommons-hive hivecommons-hive Bot removed role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR copilot dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. frontend needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[sec-check] Stored XSS: sanitizeHtmlForMdx does not strip object/embed tags

0 participants