fix(security): sanitize chat history HTML to prevent DOM XSS#366
fix(security): sanitize chat history HTML to prevent DOM XSS#366yashwant938 wants to merge 2 commits into
Conversation
tjtanjin
left a comment
There was a problem hiding this comment.
Hey @yashwant938, thanks for the PR! This hardening makes sense (storage is untrusted), but it may be a behavioral break for apps that relied on “rich” HTML surviving a persist→rehydrate round-trip (e.g. srcset, inline styles, uncommon URL schemes).
On that note, it might be worth considering having an explicit extension point for backward compatibility, e.g. chatHistorySanitizer?: (html: string) => string (defaulting to the new sanitizer). This keeps the secure default while giving advanced users a more controlled way to loosen/adjust allowlists without forking. Any thoughts on this?
|
Hey @tjtanjin Thanks for pointing that out. I agree it could break some use cases. I added an option Let me know if you’d prefer this option to live under |
Description
Please include a brief summary of the change and include the relevant issue(s).
Closes #(issue)
What change does this PR introduce?
Please select the relevant option(s).
What is the proposed approach?
Please give a short overview/explanation on the approach taken to resolve the issue(s).
Checklist: