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-10-01 - [Sandboxing Email Previews]
**Vulnerability:** XSS risk from rendering untrusted HTML via `dangerouslySetInnerHTML`, even with DOMPurify.
**Learning:** Using a sandboxed `<iframe>` with `srcDoc` and `sandbox="allow-popups allow-popups-to-escape-sandbox"` provides a stronger, isolated browsing context that prevents script execution while preserving safe link functionality.
**Prevention:** Prioritize sandboxed iframes for rendering dynamic HTML like email previews, and manually inject necessary CSS into the `srcDoc`.
28 changes: 26 additions & 2 deletions components/accounts/ppp-savings-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,32 @@ export function PppSavingsPanel({ orgSlug, accountId }: PppSavingsPanelProps) {
)}
</div>
</div>
<div className="min-h-[24rem] w-full overflow-auto bg-white p-6 text-sm text-black">
<div dangerouslySetInnerHTML={{ __html: sanitizedEmailHtml }} />
<div className="min-h-[24rem] w-full overflow-hidden bg-white">
<iframe
title="Email Preview"
srcDoc={`
<!DOCTYPE html>
<html>
<head>
<style>
body {
font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
font-size: 0.875rem; /* text-sm */
line-height: 1.25rem;
color: #000; /* text-black */
margin: 0;
padding: 1.5rem; /* p-6 */
}
</style>
</head>
<body>
${sanitizedEmailHtml}
</body>
</html>
`}
sandbox="allow-popups allow-popups-to-escape-sandbox"
className="h-full min-h-[24rem] w-full border-none"
/>
</div>
</div>
</div>
Expand Down
Loading