Miggo Logo

CVE-2025-62380: Mailgen has HTML Injection and XSS Filter Bypass in Plaintext Emails

N/A

CVSS Score

Basic Information

EPSS Score
-
Published
10/15/2025
Updated
10/15/2025
KEV Status
No
Technology
TechnologyJavaScript

Technical Details

CVSS Vector
-
Package NameEcosystemVulnerable VersionsFirst Patched Version
mailgennpm<= 2.0.312.0.32

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The analysis of the vulnerability is based on the provided description, Proof of Concept (PoC), and the associated commit patch. The vulnerability report explicitly points to the Mailgen.prototype.generatePlaintext function as the source of the HTML injection issue. The PoC demonstrates how user-provided input containing a unicode-obfuscated HTML tag (<img ... \u2028>) bypasses the sanitization logic. The commit patch confirms this by modifying the regular expression responsible for stripping HTML tags within the generatePlaintext function. The change from /<(.|\n)+?>/g to /<.+?>/gs directly addresses the bypass, as the s flag allows the dot (.) to match newline characters, including the unicode line separator \u2028 used in the exploit. Therefore, the generatePlaintext function is the single, clearly identifiable vulnerable function that would appear in a runtime profile during exploitation.

Vulnerable functions

Mailgen.generatePlaintext
index.js
The vulnerability lies in the `generatePlaintext` function. The regex used to strip HTML tags, `/<(.|\n)+?>/g`, was insufficient and could be bypassed using unicode characters such as the line separator `\u2028`. An attacker could provide a malicious payload with such characters within an HTML tag. The regex would fail to match and remove the tag. The subsequent `he.decode(output)` call would process the string, and if the output is rendered as HTML by a mail client, it would lead to Cross-Site Scripting (XSS). The patch replaces the vulnerable regex with `/<.+?>/gs`, which uses the `s` (dotall) flag to ensure that `.` matches any character, including newlines and unicode line separators, thus correctly stripping the malicious HTML.

WAF Protection Rules

WAF Rule

### Summ*ry *n *TML inj**tion vuln*r**ility in pl*int*xt *m*ils **n*r*t** *y M*il**n **s ***n *is*ov*r**. Proj**t* *r* *****t** i* t** `M*il**n.**n*r*t*Pl*int*xt(*m*il)` m*t*o* is us** *n* p*ss** in us*r-**n*r*t** *ont*nt. T** issu* w*s *is*ov*r** *

Reasoning

T** *n*lysis o* t** vuln*r**ility is **s** on t** provi*** **s*ription, Proo* o* *on**pt (Po*), *n* t** *sso*i*t** *ommit p*t**. T** vuln*r**ility r*port *xpli*itly points to t** `M*il**n.prototyp*.**n*r*t*Pl*int*xt` *un*tion *s t** sour** o* t** *TM