fix(security): sanitize markdown in RenderMarkdownContent to prevent XSS — #190#214
Merged
Jagadeeshftw merged 2 commits intoJun 23, 2026
Conversation
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>
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! |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RenderMarkdownContentrendered external GitHub discussion content throughreact-markdownwith no sanitization — a direct XSS vector viajavascript:ordata:links.rehype-sanitizewith a strict protocol allowlist: onlyhttp,https, andmailtoare permitted inhref/srcattributes. All other schemes (includingjavascript:anddata:) are stripped.defaultSchemaas the base so all standard safe HTML is still rendered correctly.Test plan
javascript:alert(1)links are stripped from rendered outputdata:text/html,...image sources are blockedrehype-sanitizewas already a transitive dep ofreact-markdownCloses #190
🤖 Generated with Claude Code