Repository navigation
Harden chat HTML sanitiser: poster/background/cite, inline style, remote media src - #3866
Merged
Merged
Conversation
…ote media src Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…rm targets Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
mstomar125
force-pushed
the
issue-3864-sanitiser-hardening
branch
from
October 22, 2026 04:39
0158874 to
875752a
Compare
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.
Refs #3864
Defence in depth for the chat HTML sanitiser (the CSP already blocks these at load time in the shipped app).
Changes
poster,backgroundandciteare now covered.citeis held to the link allow-list;posterandbackgroundfetch on their own, so they follow the media rule below.styleis removed (DOMPurifyFORBID_ATTR) rather than filtered. Chat markdown never emits inline style, so there is nothing to keep, and a filter forurl(),image-set()andposition:fixedwould be a second parser to get wrong.src,poster,background) now accept only a relative reference.img(andposter/background) may also carrydata:image/(png|jpeg|gif|webp). Remotehttps://onimg,audio,video,sourceandtrackis dropped.hrefbehaviour is unchanged.href/xlink:hrefon anything other thanaandarea(svgimage,feImage,use) is fetched by the browser, so it follows the same relative /data:imagerule assrc. Anchors keep the link allow-list.<style>elements are forbidden (FORBID_TAGS), including inside svg; app styles live in the Svelte component, not in message HTML.action/formactionare dropped.daemon_setup.rs: the "bundle changed while it was being installed" re-check after the rename is nowensure_bundle_unchanged, with a unit test (changed size, vanished bundle, unchanged passes).User-visible change
Remote markdown images (
) and remote<img>in AI replies no longer render. This is the intended privacy trade: no tracking pixel or IP leak from a message.Tests
Browser vitest (real Chromium + DOMPurify) for each point; each was mutation-checked (cite, poster/background, style, remote-src, data-image-on-non-img) and fails without its change. The Rust test fails when the check is stubbed out.
Not done
ping,longdescanddataattributes are unchanged (srcsetwas already dropped).🤖 Generated with Claude Code