fix(web): sanitize markdown link attributes to prevent XSS (CWE-79)#17362
fix(web): sanitize markdown link attributes to prevent XSS (CWE-79)#17362kvenux wants to merge 1 commit intoanomalyco:devfrom
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The following comment was made by an LLM, it may be inaccurate: Found a related PR: PR #17357 - fix(desktop-electron): sanitize markdown link attributes to prevent XSS (CWE-79) This PR addresses the same XSS vulnerability (CWE-79) in markdown link rendering, but for the desktop-electron package instead of the web package. Both PRs implement the same security fixes: escaping HTML attributes, URL protocol whitelisting, and blocking unsafe URLs. They're part of the same security fix across multiple packages. |
Security Audit: Severity Downgrade to Defense-in-DepthAfter thorough testing and analysis, we're downgrading this from High to Low (defense-in-depth). What we verified1. Client-side vulnerability is real (code level)
Combined with 2. Local POC confirms XSS fires in browser Created
3. Live opncd.ai share page — XSS does NOT fire Tested by sharing a session containing
Why this is defense-in-depth, not criticalThere are three defense layers blocking exploitation:
The first two layers already prevent exploitation on the production service. The client-side code should have DOMPurify (it's the right practice, and the main app already uses it), but the actual risk on opncd.ai is low. Potential risk for self-hosted deploymentsSelf-hosted or enterprise deployments that use a different backend may lack the server-side sanitization layer. In that case, the client-side vulnerability would be directly exploitable. Recommendation
Test artifacts
|
Issue for this PR
Closes #17361
Type of change
What does this PR do?
The custom
markedlink renderer incontent-markdown.tsxinterpolateshrefandtitledirectly into HTML without escaping. Combined withinnerHTMLrendering, this allows XSS via crafted markdown links.Fixes:
Added
escapeHtml()forhrefandtitleattributes to prevent attribute breakoutAdded URL protocol whitelist (
https:,http:,mailto:,tel:) to blockjavascript:URLsUnsafe URLs render as
<span>instead of<a>CWE: CWE-79
File:
packages/web/src/components/share/content-markdown.tsx:12-14Severity: High
How did you verify your code works?
content-markdown.test.tswith 9 test casesChecklist