Repository navigation
Conversation
safe_mode replaces unsafe link hrefs with '#', but image src values were passed through unchecked, so  produced an img tag with a javascript: src. Apply the same _safe_href check in LinkProcessor.process_image. Base64 image data URLs stay allowed, but only with a plain base64 payload, so a code span can't break out of the src attribute. Fixes trentm#764 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aliassar
force-pushed
the
fix-safe-mode-image-src-764
branch
from
November 4, 2026 19:31
8dea2da to
6fcf20b
Compare
Contributor
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.
In safe mode, links whose URL fails
_safe_hrefgethref="#", but image sources were never checked, so)rendered<img src="javascript:alert(1)">.process_imagenow runs the same check and falls back to#, like links do. Base64data:image/...URLs still work sincedata_urls_in_safe_moderelies on them, but only when the payload is plain base64: before, a code span in one could break out ofsrc(//)). Anything links already reject now givessrc="#"too, including otherdata:URLs, URLs with spaces or', and an empty![alt](), so I updated thesrcvalues in four existing XSS fixtures and addedimage_safe_urls.Fixes #764