CVE-2025-62380
Description
mailgen is a Node.js package that generates responsive HTML e-mails for sending transactional mail. Mailgen versions through 2.0.31 contain an HTML injection vulnerability in plaintext emails generated with the generatePlaintext method when user generated content is supplied. The plaintext generation code attempts to strip HTML tags using a regular expression and then decodes HTML entities, but tags that include certain Unicode line separator characters are not matched and removed. These encoded tags are later decoded into valid HTML content, allowing unexpected HTML to remain in output intended to be plaintext. Projects are affected if they call Mailgen.generatePlaintext with untrusted input and then render or otherwise process the returned string in a context where HTML is interpreted. This can lead to execution of attacker supplied script in the victim’s browser. Version 2.0.32 fixes the issue.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Mailgen through 2.0.31 has an HTML injection vulnerability in plaintext emails, allowing XSS when untrusted input is processed.
Vulnerability
Mailgen versions up to 2.0.31 contain an HTML injection vulnerability in the generatePlaintext method [1][2]. The plaintext generation attempts to strip HTML tags using a regular expression and then decodes HTML entities. However, tags that include certain Unicode line separator characters are not matched and removed during the stripping step. These encoded tags are later decoded into valid HTML content, allowing unexpected HTML to remain in output intended to be plaintext [2][4].
Exploitation
An attacker can supply user-generated content containing specially crafted HTML tags with Unicode line separators [2]. When Mailgen.generatePlaintext is called with this untrusted input and the resulting string is rendered or processed in a context where HTML is interpreted (e.g., displayed in a web page or an HTML email client), the injected HTML becomes active. No authentication or special network position is required beyond being able to inject content into the email generation pipeline [4].
Impact
Successful exploitation can lead to execution of attacker-supplied script in the victim's browser, enabling cross-site scripting (XSS) attacks. This could allow theft of cookies, session tokens, or other sensitive information, or perform actions on behalf of the user [2][4].
Mitigation
The vulnerability is fixed in version 2.0.32 [2]. Users should update to the latest version. No workarounds are mentioned, but avoiding use of user-generated content in generatePlaintext until patched can reduce risk [3][4].
AI Insight generated on May 19, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
mailgennpm | < 2.0.32 | 2.0.32 |
Affected products
2Patches
17a791a424ff3index.js: Fix additional HTML injection security issue in plaintext e-mails (thanks @edoardottt)
1 file changed · +1 −1
index.js+1 −1 modified@@ -126,7 +126,7 @@ Mailgen.prototype.generatePlaintext = function (params) { output = he.decode(output); // Strip all HTML tags from plaintext output - output = output.replace(/<(.|\n)+?>/g, ''); + output = output.replace(/<.+?>/gs, ''); // All done! return output;
Vulnerability mechanics
Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
4News mentions
0No linked articles in our index yet.