Sanitize user-controlled values in email templates to prevent XSS#234
Merged
SATYAM-PRATIBHAN merged 2 commits intoMay 27, 2026
Merged
Conversation
|
| Name | Link |
|---|---|
| 🔨 Latest commit | ea37bde |
Contributor
Author
|
@SATYAM-PRATIBHAN, Hi kindly check this PR and let me know, Thank U!! |
Owner
|
nice catch @soumojit-D48 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 inlib/escape-html.tsand applied it across all 5 email templates for both HTML and subjectlines. Plain text versions remain unaffected.
Type of Change
Related Issues
Fixes #233
Affected Files
components/email-template/otpEmailTemplate.ts—username,otpcomponents/email-template/welcomeEmailTemplate.ts—usernamecomponents/email-template/forgotPasswordEmailTemplate.ts—usernamecomponents/email-template/contactEmailTemplate.ts—firstname,lastname,email,messagecomponents/email-template/grievanceEmailTemplate.ts—username,userEmail,reason,ratingChecklist
Requested Labels
GSSoC 2026 , gssoc:approved , level:beginner , quality:clean , type:refactor