Skip to content

Sanitize user-controlled values in email templates to prevent XSS#234

Merged
SATYAM-PRATIBHAN merged 2 commits into
SATYAM-PRATIBHAN:mainfrom
soumojit-D48:fix/xss-email-templates
May 27, 2026
Merged

Sanitize user-controlled values in email templates to prevent XSS#234
SATYAM-PRATIBHAN merged 2 commits into
SATYAM-PRATIBHAN:mainfrom
soumojit-D48:fix/xss-email-templates

Conversation

@soumojit-D48
Copy link
Copy Markdown
Contributor

Description

Adds HTML escaping to all email templates to prevent XSS attacks. User-controlled values (username, message, email, etc.) were interpolated directly into HTML without sanitization, allowing an attacker to inject arbitrary scripts that execute in the recipient's email client.
Created a shared escapeHtml() utility in lib/escape-html.ts and applied it across all 5 email templates for both HTML and subject
lines. Plain text versions remain unaffected.

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)

Related Issues

Fixes #233

Affected Files

  • components/email-template/otpEmailTemplate.tsusername, otp
  • components/email-template/welcomeEmailTemplate.tsusername
  • components/email-template/forgotPasswordEmailTemplate.tsusername
  • components/email-template/contactEmailTemplate.tsfirstname, lastname, email, message
  • components/email-template/grievanceEmailTemplate.tsusername, userEmail, reason, rating

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • My changes generate no new warnings
  • I have tested my changes locally

Requested Labels

GSSoC 2026 , gssoc:approved , level:beginner , quality:clean , type:refactor

@netlify
Copy link
Copy Markdown

netlify Bot commented May 27, 2026

‼️ Deploy request for arcmind-ai rejected.

Name Link
🔨 Latest commit ea37bde

@soumojit-D48
Copy link
Copy Markdown
Contributor Author

@SATYAM-PRATIBHAN, Hi kindly check this PR and let me know, Thank U!!

@SATYAM-PRATIBHAN
Copy link
Copy Markdown
Owner

nice catch @soumojit-D48

@SATYAM-PRATIBHAN SATYAM-PRATIBHAN added gssoc:approved This issue or pull request already exists level:beginner Advance UI type:security quality:clean labels May 27, 2026
@SATYAM-PRATIBHAN SATYAM-PRATIBHAN merged commit 7762c59 into SATYAM-PRATIBHAN:main May 27, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved This issue or pull request already exists level:beginner Advance UI quality:clean type:security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTML injection / XSS vulnerability in email templates — user-controlled values not escaped

2 participants