Repository navigation
Conversation
The Slides view builds a prompt asking the model to generate a single HTML slide, extracts HTML from the response with a few regexes, and renders the result via dangerouslySetInnerHTML with no sanitization. Repository content can steer what the model outputs here (prompt injection), and a slide whose own output already contains a <style> tag skips the page's default-styling wrapper entirely, using the model's raw output as-is. An onerror/onclick handler or <script> tag the model is induced to emit executes in the DeepWiki origin when the victim opens that repository's Slides view. Sanitize the extracted slide body with DOMPurify immediately after extraction (before the default-styling wrapper, whose own trusted mermaid/Chart.js init script is unaffected since it's appended after sanitization), and strip all tags from the slide title (also model-derived) before interpolating it into <h1>. dompurify was already a transitive dependency (pulled in by mermaid for its own output); this adds it as a direct dependency at the same version range already resolved in yarn.lock, so no new package version needed locking. Validated with the real dompurify package against the exact payload shape demonstrated for this finding (an img onerror handler and a script tag), confirming both are stripped; tsc --noEmit and a full next build both pass. No frontend test runner exists in this repo to add a persistent automated test alongside this fix.
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
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.
The Slides view builds a prompt asking the model to generate a single HTML slide, extracts HTML from the response with a few regexes, and renders the result via
dangerouslySetInnerHTMLwith no sanitization. Repository content can steer what the model outputs here (prompt injection), and a slide whose own output already contains a<style>tag skips the page's default-styling wrapper entirely, using the model's raw output as-is. Anonerror/onclickhandler or<script>tag the model is induced to emit executes in the DeepWiki origin when the victim opens that repository's Slides view.Sanitizes the extracted slide body with DOMPurify immediately after extraction (before the default-styling wrapper, whose own trusted mermaid/Chart.js init script is unaffected since it's appended after sanitization), and strips all tags from the slide title (also model-derived) before interpolating it into
<h1>.dompurifywas already a transitive dependency (pulled in by mermaid for its own output); this adds it as a direct dependency at the same version range already resolved inyarn.lock, so no new package version needed locking.Test plan
dompurifypackage against the exact payload shape demonstrated for this finding (animg onerrorhandler and ascripttag), confirming both are stripped.npx tsc --noEmit: passes.npx next build: full production build passes.