fix(security): escape untrusted values in transactional email HTML
Customer input (first name, address, product names), order data, admin fields (company data, carrier, tracking number) and URLs were inserted into email HTML unescaped. A first name such as <a href="…">…</a> ended up as a working link in a genuine shop email, usable for phishing. All variable values in email HTML now go through escapeHtml (lib/escape-html.ts, shared with the withdrawal receipt). Button links only accept http(s), so a javascript: tracking URL is dropped. The plain text part stays unescaped. Tests cover order confirmation, shipment, status mails, layout company data and back-in-stock mails. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
dcfad4e011
commit
cef2248a45
6 files changed
+126
-35
No files matched your search
@@ -5,7 +5,8 @@ import { rateLimit, getClientIp } from "@/lib/rate-limit";
|
||||
import { isTrustedOrigin } from "@/lib/csrf";
|
||||
import { sendMail } from "@/lib/mail";
|
||||
import { withdrawalReceiptEmail } from "@/lib/email-templates";
|
||||
import { escapeHtml, formatReceivedAt, withdrawalDeclarationLines } from "@/lib/withdrawal";
|
||||
import { formatReceivedAt, withdrawalDeclarationLines } from "@/lib/withdrawal";
|
||||
import { escapeHtml } from "@/lib/escape-html";
|
||||
import { getLocale } from "@/i18n/locale";
|
||||
|
||||
const WITHDRAWALS_PER_WINDOW = 10;
|
||||
|
||||
Reference in new issue
Block a user