fix: sanitize blog post HTML to prevent stored XSS - #16
Conversation
Fixes profullstack#15 Blog post content was rendered via dangerouslySetInnerHTML without sanitization, allowing stored XSS if malicious HTML is injected into a post's content field. Added sanitize-html to strip dangerous tags (script, iframe, etc.) and attributes (onerror, onclick, etc.) while preserving safe formatting tags used in blog content.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
Fixes #15
Bug
Blog post content in
apps/web/app/blog/[slug]/page.tsxis rendered viadangerouslySetInnerHTMLwithout any HTML sanitization. If malicious HTML is injected into a post'scontentfield, it executes in every visitor's browser (stored XSS).Fix
sanitize-htmldependencypost.contentbefore rendering, stripping dangerous tags (script,iframe, event handlers) while preserving safe formatting tags (h1-h3,img,p,ul,ol,a,code,pre,blockquote, etc.)After merging
Run
npm install(or your package manager) inapps/web/to install thesanitize-htmldependency.