HTML phishing injection via comment reply text in email notifications (text/template instead of html/template)
Description
Email notification templates use Go's text/template engine instead of html/template, so CommentText and ParentCommentText are rendered verbatim into HTML email body without escaping. bluemonday's UGC policy permits <a href='http://...'> anchor tags and <img src='http://...'> tags. Combined, an authenticated attacker can inject phishing links and tracking pixels into email notifications sent to other users from the legitimate remark42 mail server.
Details
backend/app/notify/email.go line 8 imports 'text/template' instead of 'html/template'. At email.go:276, e.msgTmpl.Execute(&msg, tmplData) renders with text/template, inserting all variables verbatim without HTML entity escaping.
In backend/app/templates/static/email_reply.html.tmpl lines 45 and 54, {{.ParentCommentText}} and {{.CommentText}} are inserted directly into HTML <div> elements.
These values come from comment.Text sanitized by bluemonday UGC policy (backend/app/store/comment.go:122-134), which explicitly permits: <a href='http://...'>, <a href='https://...'>, <img src='http://...'>, <b>, <i>, <p>, <blockquote>, and other formatting elements.
Additionally, backend/app/api/formatter.go:48 uses HTMLFlags(0) (blackfriday HTMLFlagsNone, meaning SkipHTML is not set), so raw HTML in markdown input passes through to bluemonday, making injection trivial.
PoC
# Prerequisites: email notifications enabled; victim has subscribed to notifications
# 1. Victim posts a comment on any page
# 2. Attacker replies with a comment containing a phishing link:
curl -s -X POST 'https://remark42.example.com/api/v1/comment?site=site1' \
-H 'Authorization: Bearer ATTACKER_JWT' \
-H 'Content-Type: application/json' \
-d '{"text":"Your account needs verification: <a href=\"https://phishing.example.com/remark42-login\">Click here to verify</a> <img src=\"https://attacker.example.com/track.png\" width=\"1\" height=\"1\">","locator":{"site":"site1","url":"https://example.com/post"},"pid":"VICTIM_COMMENT_ID"}'
# 3. Victim receives a legitimate-looking remark42 email notification containing:
# - A clickable phishing link styled as a call-to-action
# - A 1x1 tracking pixel that fires when the email is openedImpact
Any authenticated user (including users with anonymous/social auth) can inject phishing links and tracking pixels into email notifications sent to other users. The injected content appears inside a legitimate remark42 email from the configured mail server, lending it credibility and bypassing email client phishing warnings. The <img> tracking pixel reveals the victim's IP address, email client, and OS to the attacker when the email is opened.
Fix
Change backend/app/notify/email.go to import 'html/template' instead of 'text/template'. Declare CommentText and ParentCommentText as template.HTML in the msgTmplData struct to indicate they are pre-sanitized HTML — html/template will then pass them through safely while still auto-escaping any other fields. As additional defense, apply a stricter bluemonday policy for email content that strips <a> and <img> tags, or text-only renders comment snippets in notification emails.
If possible, please apply for a CVE number when publishing.I would greatly appreciate it.