Repository navigation
Conversation
SearchResult inserted project text (file names, model descriptions) into the DOM via dangerouslySetInnerHTML after wrapping matches in <b> tags, so markup in that text could execute in the UI origin. highlightMatch now returns plain text parts, and a HighlightedText component renders them as React text nodes with matches wrapped in <b> elements. Both dangerouslySetInnerHTML assignments are removed. Signed-off-by: mday-io <mdaytn@gmail.com>
Signed-off-by: mday-io <mdaytn@gmail.com>
Exercise both SearchList display branches instead of the HighlightedText helper, so the XSS tests fail on the pre-fix code for the intended reason (a real <img> element is created) and HighlightedText no longer needs to be exported only for tests. Drop the highlightMatch unit tests, which asserted the exact parts array rather than rendered output. Signed-off-by: mday-io <mdaytn@gmail.com>
cmgoffena13
reviewed
Oct 26, 2026
| @@ -0,0 +1,66 @@ | |||
| import { describe, it, expect, vi } from 'vitest' | |||
Collaborator
There was a problem hiding this comment.
Need the # SPDX-License-Identifier: Apache-2.0 header on new files
cmgoffena13
reviewed
Oct 26, 2026
cmgoffena13
left a comment
Collaborator
There was a problem hiding this comment.
I don't really know typescript / javascript, but I can rubber stamp this. Need the header for the new file, could be something to have the AI check for, I've noticed people keep forgetting
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.
Description
SearchResultinweb/client/src/library/components/search/SearchList.tsxrendered search results withdangerouslySetInnerHTML, using the output ofhighlightMatch. That function wrapped matches in<b>tags but never escaped the surrounding project text. A filename or model description containing markup (e.g.'<img src=x onerror=...>') could therefore execute script in the UI origin when someone searched for nearby text (CWE-79).Changes:
highlightMatch(search/help.ts) now returns plain{ text, isMatch }parts instead of an HTML string. An empty search returns the source unchanged; previouslyreplaceAll('', ...)inserted<b></b>between every character.HighlightedTextcomponent renders those parts as React text nodes, wrapping matches in<b>with the same classes as before.dangerouslySetInnerHTMLassignments inSearchResultare removed. No otherdangerouslySetInnerHTMLremains inweb/client/src.Highlighting stays case-sensitive, matching the previous behavior.
Test Plan
web/client/src/library/components/search/tests/SearchList.spec.tsx. It rendersSearchList, types a search, and inspects the results, for both display branches (showIndextrue and false):<img onerror=...>payload in the project text is rendered as text, with only the match highlighted;<img>element is created. The highlighting test passes on both versions, confirming parity.NODE_ENV=testing npx vitest --watch=falseinweb/client: 11 files, 78 tests passed.tscreports no errors in the search directory.Checklist
make styleand fixed any issues (ran ESLint and Prettier on the changed web files)make fast-test) (ran the web client unit tests; no Python code changed)git commit -s) per the DCOSummary by CodeRabbit