fix(security): allowlist markdown link/image schemes (LC-154) #189
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/lc-154-markdown-link-scheme"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Closes the markdown link-scheme XSS from the LC-148 audit (finding S8).
Problem
pulldown_cmarkwrites a link destination into thehrefverbatim, and the renderer'sTag::Linkarm passed the event straight through. So a message body[click](javascript:alert(document.cookie))rendered<a href="javascript:...">- click-to-execute XSS in any rendered message. (Bare-URL linkify was already safe; this is the explicit[label](dest)path.)Fix
link_scheme_is_safe: allows relative references (fragment / query / path / scheme-less) and thehttp/https/mailtoschemes; everything else (javascript:,data:,vbscript:,file:, ...) is neutralized by rewriting the destination to#, keeping the visible label but making the link inert. A colon after a/is treated as a path (not a scheme), sopath/to:thing-style relative refs are preserved. Applied to bothTag::LinkandTag::Image(img src is defense-in-depth - ajavascript:src doesn't execute in modern browsers, but a disallowed scheme has no business there).Test
javascript:/data:/vbscript:/file:neutralized (case-insensitive),http/https/mailto/relative preserved, plus alink_scheme_is_safepredicate matrix.just check/just test/just test-saasgreen (theroutes_uploadsflake is pre-existing; no upload code touched).Part of the LC-159 post-audit story.
🤖 Generated with Claude Code