Skip to content

fix: sanitize blog post HTML to prevent stored XSS - #16

Closed
FuturMix wants to merge 1 commit into
profullstack:masterfrom
FuturMix:fix/blog-xss-sanitize-html
Closed

fix: sanitize blog post HTML to prevent stored XSS#16
FuturMix wants to merge 1 commit into
profullstack:masterfrom
FuturMix:fix/blog-xss-sanitize-html

Conversation

@FuturMix

Copy link
Copy Markdown
Contributor

Fixes #15

Bug

Blog post content in apps/web/app/blog/[slug]/page.tsx is rendered via dangerouslySetInnerHTML without any HTML sanitization. If malicious HTML is injected into a post's content field, it executes in every visitor's browser (stored XSS).

Fix

  • Added sanitize-html dependency
  • Sanitize post.content before 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) in apps/web/ to install the sanitize-html dependency.

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.
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedsanitize-html@​2.17.510010010095100

View full report

@socket-security

Copy link
Copy Markdown

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.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: npm entities is 91.0% likely obfuscated

Confidence: 0.91

Location: Package overview

From: ?npm/sanitize-html@2.17.5npm/entities@4.5.0

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/entities@4.5.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
Obfuscated code: npm htmlparser2 is 90.0% likely obfuscated

Confidence: 0.90

Location: Package overview

From: ?npm/sanitize-html@2.17.5npm/htmlparser2@10.1.0

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/htmlparser2@10.1.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@FuturMix

Copy link
Copy Markdown
Contributor Author

Hi @ralyodio — we have 2 fix PRs for c0upons (#16 stored XSS fix, #18 auth for coupon/store creation). Would appreciate a review. Thanks!

@ralyodio ralyodio closed this Jun 15, 2026
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.

Bug: Stored XSS via unsanitized dangerouslySetInnerHTML in blog post rendering

2 participants