Sanitize rich HTML rendering in webchat and forms - #58
Merged
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b11bcf5536
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b11bcf5. Configure here.
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
hellotext-iconcontract while removing executable markup and unsafe URLsWhy
The SDK inserted remote content through raw
innerHTMLassignments. Although regular message HTML is sanitized by the current Rails producer, the browser package trusted that producer contract completely and interpreted teaser text as markup.Impact
Rich content keeps its intended formatting, links, Stimulus attributes, custom icons, and SVG paths while scripts, event handlers, dangerous URLs,
foreignObject, and iframe content are removed.Note
Medium Risk
Touches all paths that render untrusted HTML in the embedded webchat and forms; incorrect sanitization could break carousels/Stimulus or leave XSS gaps, though behavior is heavily test-covered.
Overview
Hardens the SDK against XSS by sanitizing remote HTML before it reaches the DOM, instead of trusting server output via raw
innerHTML.A new
sanitize_htmlmodule applies two DOMPurify policies: rich text (messages, paginated history, form headers/footers) strips scripts, handlers,javascript:URLs, and Stimulusdata-*while keeping formatting and safe links; webchat components (Rails-rendered carousels) additionally keepsdata-controller/data-action,hellotext-icon, and SVG paths while droppingforeignObject, iframes, and executable markup.Inbound message teasers now use
textContent, so teaser strings cannot execute as HTML. Missing message bodies render as empty instead of showingundefined.Tests cover unsafe bodies, carousel contract preservation, teaser escaping, pagination, and form header/footer sanitization.
Reviewed by Cursor Bugbot for commit 04f999d. Bugbot is set up for automated code reviews on this repo. Configure here.