Skip to content

fix: sanitize search snippets to prevent XSS from indexed summaries - #2

Closed
farce1 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-fts-xss-vulnerability
Closed

fix: sanitize search snippets to prevent XSS from indexed summaries#2
farce1 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-fts-xss-vulnerability

Conversation

@farce1

Copy link
Copy Markdown
Owner

Motivation

  • The FTS upsert concatenates user-editable or LLM-generated summary content into the meetings_fts.transcript_text column which is later used by SQLite snippet() and returned as raw HTML.
  • Search snippets were rendered with dangerouslySetInnerHTML without sanitization, creating an XSS vector if a summary contains HTML/JS.

Description

  • Added sanitizeSearchSnippetHtml to src/views/LibraryView.tsx which HTML-escapes snippet content and then allowlists the <mark> tag so FTS highlight markup still renders.
  • Updated renderSearchSnippet to return sanitized HTML via the new sanitizer while preserving existing dangerouslySetInnerHTML usage.
  • Change is minimal and client-side only and keeps search highlighting behavior while preventing arbitrary HTML/JS execution from snippets.

Testing

  • Ran npm test which completed successfully (14 tests passed).
  • Ran npm run build; the first build failed due to use of String.replaceAll, then the sanitizer was adjusted to use regex replace calls and the subsequent npm run build succeeded.
  • Confirmed the change updates src/views/LibraryView.tsx and that search UI still renders with highlight marks while snippet content is escaped.

Codex Task

@farce1

Copy link
Copy Markdown
OwnerAuthor

Closing as superseded by #3, which takes the stronger approach: eliminates dangerouslySetInnerHTML entirely and uses non-HTML sentinel tokens rendered as React nodes (text + ) — no HTML ever enters the DOM pipeline, no regex-based sanitization to maintain. This PR's approach (escape + allowlist ) works but keeps dangerouslySetInnerHTML, which is a weaker security posture.

@farce1farce1 closed this Apr 19, 2026
farce1 added a commit that referenced this pull request Apr 19, 2026
Fixes XSS in library search snippets by replacing dangerouslySetInnerHTML
with React-rendered <mark> nodes driven by non-HTML sentinel tokens at the
SQLite snippet() layer. No HTML ever enters the DOM pipeline.
Supersedes #2.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@farce1