The minimalistic document archiving platform.
fix(emails): sanitize user name in email content (#995)
Corentin Thomasset327eda000135
diff --git a/.changeset/true-queens-exist.md b/.changeset/true-queens-exist.mdnew file mode 100644index 00000000..aef4c0d0--- /dev/null+++ b/.changeset/true-queens-exist.md@@ -0,0 +1,5 @@+---+"@papra/app": patch+---++Properly sanitize user name before including it in the email content to prevent potential XSS or html injection attacks.diff --git a/apps/papra-server/src/modules/app/auth/auth.emails.services.ts b/apps/papra-server/src/modules/app/auth/auth.emails.services.tsindex 033063b2..9ca70f90 100644--- a/apps/papra-server/src/modules/app/auth/auth.emails.services.ts+++ b/apps/papra-server/src/modules/app/auth/auth.emails.services.ts@@ -1,6 +1,7 @@import type { User } from 'better-auth';import type { EmailsServices } from '../../emails/emails.services';import { injectArguments } from '@corentinth/chisels';+import { sanitize } from '../../shared/html/html';import { createLogger } from '../../shared/logger/logger';const logger = createLogger({ namespace: 'auth.emails.services' });@@ -24,7 +25,7 @@ export async function sendVerificationEmail({ user, url, emailsServices }: { useto: user.email,subject: 'Verify your email',html: `-<p>Hello ${user.name},</p>+<p>Hello ${sanitize(user.name)},</p><p>Verify your email by clicking <a href="${url}">here</a></p><p>Or by pasting the following link into your browser: ${url}</p><p style="color: #888;">Best regards,</p>@@ -40,7 +41,7 @@ export async function sendPasswordResetEmail({ user, url, emailsServices }: { usto: user.email,subject: 'Reset your password',html: `-<p>Hello ${user.name},</p>+<p>Hello ${sanitize(user.name)},</p><p>Reset your password by clicking <a href="${url}">here</a></p><p>Or by pasting the following link into your browser: ${url}</p><p style="color: #888;">Best regards,</p>