Details
Recommended Fix
The minimum fix is to remove the urlTransform override in ui/src/components/MarkdownBody.tsx:162 and rely on react-markdown's defaultUrlTransform:
// ui/src/components/MarkdownBody.tsx
import Markdown, { defaultUrlTransform, type Components } from "react-markdown";
// ...
// Preserve mention-chip (paperclip-mention://) hrefs so parseMentionChipHref still runs,
// but fall back to the library's scheme allow-list for everything else.
function safeUrlTransform(url: string): string {
if (url.startsWith("paperclip-mention://")) return url;
return defaultUrlTransform(url);
}
<Markdown
remarkPlugins={[remarkGfm]}
components={components}
urlTransform={safeUrlTransform}
>
{children}
</Markdown>
defaultUrlTransform strips javascript:, vbscript:, file:, and non-image data: URIs, which closes this finding for every call site of MarkdownBody.
Defense-in-depth recommendations:
- Add a strict Content-Security-Policy header to the main app response (e.g.
script-src 'self' 'nonce-...') so that even a future regression cannot execute inline JS viajavascript:navigation. - Server-side validate document and comment bodies for obviously unsafe markdown patterns (e.g. reject
](javascript:sequences) as belt-and-braces. Do not rely on client-side sanitization alone, since other clients (mobile, exports) may render the same content. - Audit every existing component for other
urlTransform/skipHtml/rehype-rawoverrides that might reintroduce the same bypass.