Skip to content

fix: sanitize root component tags and props from markdown frontmatter#492

Open
farnabaz01 wants to merge 2 commits into
nuxt-content:mainfrom
farnabaz01:fix/xss-root-frontmatter
Open

fix: sanitize root component tags and props from markdown frontmatter#492
farnabaz01 wants to merge 2 commits into
nuxt-content:mainfrom
farnabaz01:fix/xss-root-frontmatter

Conversation

@farnabaz01

Copy link
Copy Markdown
Contributor

Root Cause

Frontmatter component field was merged directly into renderer data and used to select the root element and its props, bypassing the dangerous-tag and unsafe-prop checks that exist for child nodes.

Fix

  • Reject dangerous root tags (script, base, iframe) by falling back to div
  • Apply validateProps to root component props from frontmatter (blocks srcdoc, formaction, on* event handlers, unsafe href/src)

Tests

  • Integration test verifying SSR output blocks iframe/script root tags
  • Unit tests for validateProps sanitization of srcdoc and unsafe tags

The frontmatter component field bypassed dangerous-tag and unsafe-prop
checks that exist for child nodes, creating an XSS sink.

Payload example:
---
component:
  name: iframe
  props:
    srcdoc: "<script>...</script>"
---

Fix:
- Reject dangerous root tags (script, base, iframe) by falling back to div
- Apply validateProps to root component props from frontmatter (blocks
  srcdoc, formaction, on* event handlers, unsafe href/src)
@farnabaz01 farnabaz01 force-pushed the fix/xss-root-frontmatter branch from 4431fcb to 9487d36 Compare June 21, 2026 18:31
@farnabaz01

Copy link
Copy Markdown
Contributor Author

This PR is ready for review by @farnabaz.

@pkg-pr-new

pkg-pr-new Bot commented Jun 21, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@nuxtjs/mdc@492

commit: 9487d36

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.

1 participant