Skip to content
Open
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
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 2024-05-24 - [dangerouslySetInnerHTML XSS Vulnerability]
**Vulnerability:** Found a Cross-Site Scripting (XSS) vulnerability in `RoomAIChat` where chat messages were being rendered using `dangerouslySetInnerHTML` to support `<br/>` tags for newlines.
**Learning:** Using `.replace(/\n/g, '<br/>')` paired with `dangerouslySetInnerHTML` is a highly dangerous pattern in React that inadvertently allows malicious HTML/JS execution if user input flows through it (e.g. chat messages).
**Prevention:** Always use standard React text rendering `{msg.content}` paired with CSS `white-space: pre-wrap` (or Tailwind's `whitespace-pre-wrap`) to safely render text with line breaks without exposing the app to XSS risks.
162 changes: 0 additions & 162 deletions src/app/about/page.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/room/ai-chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export function RoomAIChat({
: "bg-purple-500/10 border border-purple-500/20 text-purple-100",
)}
>
<div dangerouslySetInnerHTML={{ __html: msg.content.replace(/\n/g, '<br/>') }} />
<div className="whitespace-pre-wrap">{msg.content}</div>

{/* Render Options Buttons */}
{msg.options && msg.options.length > 0 && (
Expand Down