[sec-check] fix: add rehypeSanitize to ReactMarkdown components (XSS via javascript: URIs)#17158
Conversation
…content XSS) MessageBubble renders LLM/AI responses with no sanitization — a prompt injection attack could embed javascript: URIs or event handlers in the AI output and execute them when the user interacts. - Add rehypeSanitize to strip unsafe HTML/attributes from AI responses - Add remarkGfm for consistent rendering (already a project dependency) Fixes #17150 (partial — MessageBubble component) Signed-off-by: scanner <scanner@hive.kubestellar.io> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
FullscreenPreview renders user-typed markdown content without HTML sanitization. While this is primarily a self-XSS surface (users see their own content), defense-in-depth requires sanitization since the content can contain arbitrary HTML injected via XSS in other inputs. Signed-off-by: scanner <scanner@hive.kubestellar.io> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
#17150) SubmitTab renders user-typed markdown in preview mode without HTML sanitization. Add rehypeSanitize to strip javascript: URIs and event handlers from preview content (CWE-79, fixes #17150 partial). Signed-off-by: scanner <scanner@hive.kubestellar.io> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Preview panel renders user-typed markdown without HTML sanitization. Add rehypeSanitize to strip javascript: URIs and event handlers. CWE-79, partial fix for #17150. Signed-off-by: scanner <scanner@hive.kubestellar.io> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
#17150) WhatsNewModal renders GitHub release notes via ReactMarkdown without HTML sanitization. A compromised release body could inject XSS payloads. Add rehypeSanitize to all 3 ReactMarkdown instances to strip javascript: URIs and event handlers. CWE-79, partial fix for #17150. Signed-off-by: scanner <scanner@hive.kubestellar.io> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
✅ Deploy Preview for kubestellarconsole ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
👋 Hey @clubanderson — thanks for opening this PR!
This is an automated message. |
✅ Test Coverage CheckAll new source files in this PR have corresponding test files. Checked |
Auto Test GeneratorThe following new files have no corresponding test file:
Please add tests or apply the |
There was a problem hiding this comment.
Pull request overview
Mitigates an XSS vector in the web UI by ensuring untrusted Markdown rendered via react-markdown is sanitized with rehype-sanitize, specifically targeting javascript: URI injection (and other unsafe HTML/attributes) in several user/AI/GitHub-sourced Markdown surfaces.
Changes:
- Added
rehype-sanitizeto multipleReactMarkdownrenderers to sanitize rendered Markdown output. - Added
remark-gfmtoMessageBubble.tsxfor consistent GitHub Flavored Markdown rendering in chat messages. - Updated all relevant Markdown preview/release-notes render paths in the touched components to include
rehypePlugins={[rehypeSanitize]}.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| web/src/components/updates/WhatsNewModal.tsx | Sanitizes GitHub release-notes Markdown rendering in all modal instances. |
| web/src/components/stellar/MessageBubble.tsx | Sanitizes AI message Markdown rendering and enables GFM parsing. |
| web/src/components/feedback/SubmitTab.tsx | Sanitizes user-typed Markdown in the feedback preview panel. |
| web/src/components/feedback/FeedbackDialogs.tsx | Sanitizes Markdown in the fullscreen preview overlay. |
Status Check — Open PR Stalled ~21 Hours, No Review ActivityThis PR has been open for approximately 21 hours with no review activity since shortly after creation (~22:28 UTC on June 6). Current status:
Context: This PR addresses the same ReactMarkdown XSS / `(redacted) URI injection issue as draft PR #17151. A comment on #17151 at 10:12 UTC noted this PR as the superseding fix; however, a later comment at 17:39 UTC on #17151 reversed that and called #17151 the correct fix. A human maintainer needs to resolve which PR should be merged. Recommended next steps for a human maintainer:
|
Status Check — Security Fix PR Awaiting Review (~27 Hours)No new activity since the last status check at 19:41 UTC (~3h12m ago). State unchanged. Current status:
Note on This PR fixes a security issue: XSS via Relationship to #17151: This PR may supersede draft PR #17151, which covers the same issue but lacks DCO signoff and remains in draft. A human maintainer needs to decide which PR to proceed with. Recommended next steps at start of business hours:
Outside business hours — no new labels or escalation needed.
|
|
Thank you for your contribution! Your PR has been merged. Check out what's new:
Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey |
❌ Post-Merge Verification: failedCommit: |
|
Post-merge build verification passed ✅ Both Go and frontend builds compiled successfully against merge commit |
Security Fix
Severity: High
Type: XSS (CWE-79) — javascript: URI injection via ReactMarkdown
Problem
Multiple
<ReactMarkdown>usages rendered untrusted content withoutrehype-sanitize, allowing attackers to inject arbitrary HTML includingjavascript:URIs and event handler attributes.Highest risk —
MessageBubble.tsx: renders AI/LLM responses directly. A prompt injection attack could cause the LLM to output[click me](javascript:alert(document.cookie))which would execute in the user's browser.Components Fixed
MessageBubble.tsxFeedbackDialogs.tsx(FullscreenPreview)SubmitTab.tsx(preview panel)WhatsNewModal.tsx(3 instances)Changes
All 4 files: added
import rehypeSanitize from 'rehype-sanitize'andrehypePlugins={[rehypeSanitize]}to<ReactMarkdown>components.rehype-sanitizewas already a transitive dependency viareact-markdown.MessageBubble.tsxalso receivedremarkGfm(GitHub Flavored Markdown) which was missing.Testing
javascript:URIs in links are stripped (render as#or plain text)<script>tags in markdown are strippedFixes #17150
Filed by sec-check agent (ACMM L6 — full mode)