Skip to content

Harden URL safety checks and sanitization in safe mode (#721) - #722

Open
Crozzers wants to merge 4 commits into
trentm:masterfrom
Crozzers:xss-721
Open

Harden URL safety checks and sanitization in safe mode (#721)#722
Crozzers wants to merge 4 commits into
trentm:masterfrom
Crozzers:xss-721

Conversation

@Crozzers

@Crozzers Crozzers commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

This PR fixes #721.

First issue was that for HTML encoded colons the semicolon at the end of : is actually optional, but our safe_href regex didn't account for that. That is now fixed.

Second, our auto link checks were accepting URLs like <http:|>, even in safe mode. This is clearly not a valid URL (I don't even think | is a valid URL char). The _is_auto_link check was modified to check against _safe_href in safe mode.

Finally, escaped HTML comments weren't having their contents properly sanitized. This is now passed through _sanitize_html to prevent any smuggling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XSS's in safe mode

1 participant