Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't use dangerouslySetinnnerHTML #4437

Closed
hacke2 opened this issue Mar 5, 2025 · 0 comments
Closed

don't use dangerouslySetinnnerHTML #4437

hacke2 opened this issue Mar 5, 2025 · 0 comments

Comments

@hacke2
Copy link
Member

hacke2 commented Mar 5, 2025

In the CommentsBody component, dangerouslySetInnerHTML is being used which could potentially lead to XSS vulnerabilities. The problematic code is:

<div
  dangerouslySetInnerHTML={{
    __html: toMarkdownHtml(typeof body === 'string' ? body : body.value, {
      gfm: true,
      breaks: false,
      pedantic: false,
      smartLists: true,
      smartypants: false,
      renderer,
    }),
  }}
></div>

Consider using a safer alternative for rendering markdown content, such as:

  1. Using a secure markdown rendering library that handles sanitization
  2. Implementing proper sanitization before rendering
  3. Using React components to render the markdown structure instead of raw HTML

File: packages/comments/src/browser/comments-body.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant