Skip to content

Security: Potential XSS risk in markdown rendering helper if reused with untrusted input#478

Merged
gre merged 1 commit intogre:masterfrom
tuanaiseo:contribai/fix/security/potential-xss-risk-in-markdown-rendering
Apr 8, 2026
Merged

Security: Potential XSS risk in markdown rendering helper if reused with untrusted input#478
gre merged 1 commit intogre:masterfrom
tuanaiseo:contribai/fix/security/potential-xss-risk-in-markdown-rendering

Conversation

@tuanaiseo
Copy link
Copy Markdown
Contributor

Problem

The markdown utility renders markdown through remark().use(remark-react) and returns React elements. If this helper is ever called with user-controlled markdown (instead of static literals), untrusted markdown/HTML handling may introduce scriptable content depending on parser/plugin behavior and version defaults.

Severity: medium
File: packages/cookbook/src/markdown.js

Solution

Enforce sanitization explicitly by adding a sanitizer pipeline (e.g., rehype-sanitize/equivalent) and disallow raw HTML. Document that this helper must only process trusted content unless sanitization is enabled.

Changes

  • packages/cookbook/src/markdown.js (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

…per if

The markdown utility renders markdown through `remark().use(remark-react)` and returns React elements. If this helper is ever called with user-controlled markdown (instead of static literals), untrusted markdown/HTML handling may introduce scriptable content depending on parser/plugin behavior and version defaults.

Affected files: markdown.js

Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
Copy link
Copy Markdown
Owner

@gre gre left a comment

Choose a reason for hiding this comment

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

thanks

@gre gre merged commit c520210 into gre:master Apr 8, 2026
2 of 3 checks passed
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