Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mosu-app/src/entities/posts/ui/MarkDown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const MarkDownRenderer = ({ content, ...props }: MarkDownRendererProps) =
return (
<article
{...props}
className={cn(props.className, "prose [&>h1]:my-1")}
className={cn(props.className, "prose max-w-none [&>h1]:my-1")}
dangerouslySetInnerHTML={{ __html: content }}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Sanitize HTML before injecting (XSS risk)

dangerouslySetInnerHTML requires trusted content. Sanitize on render or ensure upstream sanitization.

Option A (render-time sanitization):

-            dangerouslySetInnerHTML={{ __html: content }}
+            dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(content) }}

Add once at the top of this file:

import DOMPurify from "isomorphic-dompurify";

Option B (preferred): sanitize in the Markdown→HTML pipeline (see comment in faq.tsx Lines 21-22).

🧰 Tools
🪛 Biome (2.1.2)

[error] 12-12: Avoid passing content using the dangerouslySetInnerHTML prop.

Setting content using code can expose users to cross-site scripting (XSS) attacks

(lint/security/noDangerouslySetInnerHtml)

🤖 Prompt for AI Agents
mosu-app/src/entities/posts/ui/MarkDown.tsx around line 12, the component
injects raw HTML via dangerouslySetInnerHTML which is an XSS risk; either (A)
import isomorphic-dompurify at the top of this file and sanitize content before
passing it to dangerouslySetInnerHTML (use DOMPurify.sanitize with an HTML
profile/options), or (B, preferred) ensure the Markdown→HTML pipeline sanitizes
the output upstream and pass only already-sanitized HTML here; implement one of
these fixes and remove any remaining direct injections of unsanitized content.

/>
);
Expand Down
4 changes: 2 additions & 2 deletions mosu-app/src/pages/notice/faq.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export default function NoticeFAQPage({ faqs }: InferGetStaticPropsType<typeof g
<AccordionTrigger className="flex h-20 items-center text-xl">
Q. {faq.question}
</AccordionTrigger>
<AccordionContent className="mt-4 text-lg">
<MarkDownRenderer content={faq.answer} />
<AccordionContent className="mt-4 text-lg w-full">
<MarkDownRenderer content={faq.answer} className="w-full" />
</AccordionContent>
</AccordionItem>
);
Expand Down