Skip to content

fix(security): sanitize markdown in RenderMarkdownContent to prevent XSS — #190#214

Merged
Jagadeeshftw merged 2 commits into
Grainlify:mainfrom
leocagli:fix/render-markdown-190-xss-sanitize
Jun 23, 2026
Merged

fix(security): sanitize markdown in RenderMarkdownContent to prevent XSS — #190#214
Jagadeeshftw merged 2 commits into
Grainlify:mainfrom
leocagli:fix/render-markdown-190-xss-sanitize

Conversation

@leocagli

Copy link
Copy Markdown
Contributor

Summary

  • RenderMarkdownContent rendered external GitHub discussion content through react-markdown with no sanitization — a direct XSS vector via javascript: or data: links.
  • Adds rehype-sanitize with a strict protocol allowlist: only http, https, and mailto are permitted in href/src attributes. All other schemes (including javascript: and data:) are stripped.
  • Uses defaultSchema as the base so all standard safe HTML is still rendered correctly.

Test plan

  • javascript:alert(1) links are stripped from rendered output
  • data:text/html,... image sources are blocked
  • Normal markdown (links, images, headings, code blocks) renders unchanged
  • TypeScript compiles cleanly; rehype-sanitize was already a transitive dep of react-markdown

Closes #190

🤖 Generated with Claude Code

leocagli and others added 2 commits June 23, 2026 13:32
IssuesTab renders external GitHub discussion content through react-markdown
with no sanitization, creating an XSS vector. Adds rehype-sanitize with a
strict protocol allowlist (http, https, mailto only) that blocks javascript:
and data: URLs in links and image sources while preserving safe markup.

Closes Grainlify#190

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Jagadeeshftw Jagadeeshftw merged commit abf7f61 into Grainlify:main Jun 23, 2026
@Jagadeeshftw

Copy link
Copy Markdown
Contributor

sanitizing the markdown via rehype-sanitize is an important xss hardening for RenderMarkdownContent, good catch. rebased on latest main and confirmed the new dep resolves cleanly. thanks!

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.

Sanitize markdown in maintainers IssuesTab discussion rendering (RenderMarkdownContent)

3 participants