Merged
Conversation
- Add sanitizeChatContent utility to restrict img src to same-origin, relative, or data: URLs only - Block external URLs in img tags (e.g. prompt injection embedding conversation history) - Apply sanitization to all chat/AI content rendering: markdown-content, floating-chat-widget, highlight-markdown, search views, chunk cards - Mitigates vulnerability where malicious instructions (from KB, custom prompt, agent, etc.) could exfiltrate user conversations to attacker-controlled servers Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a centralized, security-focused HTML sanitization utility for AI/chat-rendered content to mitigate prompt-injection-driven data exfiltration via externally loaded images, and updates both frontend rendering and backend-generated image URLs to align with same-origin expectations.
Changes:
- Introduces
sanitizeChatContent(DOMPurify-based) with an image URL restriction hook. - Replaces multiple direct
DOMPurify.sanitize(...)call sites withsanitizeChatContent(...)across search/markdown/chunk rendering. - Switches parser-generated image URLs to relative paths and stops committing
web/.env(now ignored).
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| web/src/utils/sanitize.ts | New centralized sanitizer that attempts to restrict <img> URL loading to prevent exfiltration. |
| web/src/pages/search/index.tsx | Uses the centralized sanitizer for rendering highlight HTML. |
| web/src/pages/next-search/search-view.tsx | Uses the centralized sanitizer for rendering highlight/content snippets. |
| web/src/pages/next-search/markdown-content/index.tsx | Uses the centralized sanitizer for markdown-related HTML rendering. |
| web/src/pages/dataflow-result/components/chunk-card/index.tsx | Uses the centralized sanitizer for chunk HTML rendering. |
| web/src/pages/chunk/parsed-result/add-knowledge/components/knowledge-chunk/components/chunk-card/index.tsx | Uses the centralized sanitizer for chunk HTML rendering. |
| web/src/components/next-markdown-content/index.tsx | Uses the centralized sanitizer for markdown-related HTML rendering. |
| web/src/components/markdown-content/index.tsx | Uses the centralized sanitizer for markdown-related HTML rendering. |
| web/src/components/highlight-markdown/index.tsx | Sanitizes markdown input before preprocessing/rendering. |
| web/src/components/floating-chat-widget-markdown.tsx | Sanitizes chat content and citation popover HTML rendering. |
| web/.gitignore | Adds /.env to ignored files. |
| web/.env | Removes committed env file from the repo. |
| powerrag/parser/vllm_parser.py | Emits relative /v1/... image URLs so the frontend treats them as same-origin/proxied. |
| powerrag/parser/mineru_parser.py | Emits relative /api/... image URLs so the frontend treats them as same-origin/proxied. |
whhe
approved these changes
Feb 25, 2026
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
To address the issue of security vulnerabilities, there is an attack process as follows:
Solution Description