fix(security): prevent XSS via dangerouslySetInnerHTML in MCP description and search results#13893
Merged
kangfenmao merged 2 commits intoCherryHQ:mainfrom Mar 31, 2026
Conversation
Contributor
There was a problem hiding this comment.
Looks good to me. This patch closes two clear XSS paths around dangerouslySetInnerHTML with minimal, targeted changes: sanitizing rendered README HTML and escaping search-result text before applying highlight markup. I don't see any blocking issue in the current implementation.
DeJeune
approved these changes
Mar 30, 2026
kangfenmao
approved these changes
Mar 31, 2026
ab7341f to
4a4e2eb
Compare
NPM package README content is rendered via markdown-it and injected with dangerouslySetInnerHTML without sanitization. A malicious NPM package could include XSS payloads (<script>, <img onerror=...>) in its README that execute in the Electron renderer context. Fix: sanitize the rendered HTML with DOMPurify (already a project dependency) before injecting it into the DOM. CWE-79: Cross-Site Scripting (XSS)
…tored XSS Message text from LLM responses is injected via dangerouslySetInnerHTML without escaping. If an LLM response contains HTML like <img onerror=...>, it executes in the renderer context when the user searches chat history. Fix: escape HTML entities in the text before applying highlight markup. CWE-79: Stored Cross-Site Scripting
4a4e2eb to
ce31ffb
Compare
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
This PR fixes two XSS vulnerabilities where untrusted content is injected via
dangerouslySetInnerHTMLwithout sanitization.1. NPM README XSS in MCP Description — CWE-79
File:
src/renderer/src/pages/settings/MCPSettings/McpDescription.tsxNPM package README content (fetched from the npm registry) is rendered through
markdown-itand injected directly into the DOM. A malicious NPM package could include XSS payloads in its README:Fix: Sanitize the rendered HTML with
DOMPurify(already a project dependency) before injection:2. Stored XSS in Search Result Highlighting — CWE-79
File:
src/renderer/src/pages/history/components/SearchResults.tsxLLM response text is injected via
dangerouslySetInnerHTMLwithout HTML escaping. If an LLM response contains HTML (via prompt injection or adversarial input), it will execute when the user searches chat history:Fix: Escape HTML entities before applying highlight markup:
Impact
Both vulnerabilities allow arbitrary JavaScript execution in the Electron renderer process. Combined with
sandbox: falsein the current BrowserWindow configuration, this could escalate to full system access.