Mailgen CVE-2025-62380
LOWAttack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessSubmit untrusted content with Unicode-separator HTML tag
-
DeliveryApp calls Mailgen.generatePlaintext
-
ExploitRegex filter bypassed, entity decode restores tag
-
ExecutionPlaintext rendered in HTML context
-
ImpactScript executes in victim browser
Vulnerability Assessment
| Weakness |
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Output encoding, context-aware escaping
MITRE ATT&CK
2 techniques across 2 tactics: Initial Access, Execution The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up. |
| Exploitation Conditions | Exploitation requires that (1) the application calls Mailgen.generatePlaintext with attacker-controllable/untrusted input, AND (2) the returned string - which the API advertises as plaintext - is subsequently rendered or processed in a context where HTML is interpreted (e.g. an HTML email preview or web view). The injected tag must contain a Unicode line separator (U+2028) or similar character that evades the pre-patch tag-stripping regex. The limiting factor is condition (2): if the output is used strictly as plaintext (the intended use), there is no impact - this is why the CVSS 4.0 vector carries AT:P and the overall score is only 2.9. Affects Mailgen <= 2.0.31 (Node.js); fixed in 2.0.32. |
| Impact | This is a genuinely low-priority issue despite being an XSS-class flaw. The CVSS 4.0 base score of 2.9 is itself low, driven by VC:N/VI:N/VA:N on the vulnerable system and only SC:L/SI:L on a subsequent system (the victim's browser) - i.e. no direct impact on the Mailgen host, only limited impact downstream when the output is mishandled. The 4.0 vector carries AT:P (an attack requirement), which correctly reflects that exploitation depends on a condition outside the attacker's control: the consuming application must render the string returned by generatePlaintext in an HTML-interpreted context, which is a developer misuse of an API that explicitly produces 'plaintext'. EPSS is 0.45% (37th percentile) - modest and consistent with a niche library bug rather than a mass-exploited target. Exploitation status: publicly available exploit code exists (a working payload |
| Exploit ScenarioDerived | An attacker submits user-generated content (e.g. a display name, comment, or form field) containing an HTML tag with an embedded Unicode line separator such as |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – Oct 01, 2026
Improper HTML stripping in the Mailgen Node.js package (versions through 2.0.31) allows attacker-controlled markup to survive Mailgen.generatePlaintext and be emitted in a string the API advertises as plaintext. Remote, unauthenticated attackers who can influence the values passed into generatePlaintext can embed a tag containing a Unicode line separator such as U+2028, which the pre-patch tag-stripping regex fails to match, and if that returned string is later rendered in an HTML context - an email preview or web view - the injected markup executes script in the victim's browser, with the victim having to view/render the content (UI:R). Impact is narrowly conditional (applications that consume the output strictly as plaintext are unaffected, which is why the vendor CVSS 4.0 score is only 2.9), no active exploitation is indicated (not listed in CISA KEV; EPSS 0.45%, 37th percentile), and the upstream advisory documents a proof-of-concept payload; version 2.0.32 fixes the flaw.
RemediationAI
Vendor-released patch: 2.0.32. Upgrade the mailgen dependency to 2.0.32 or later (npm install mailgen@^2.0.32) and redeploy; this release contains the corrected tag-stripping pattern /<.+?>/gs from upstream commit 7a791a424ff3a3f7783f8750919f1e98639924a8, and the advisory with full details is at https://github.com/eladnava/mailgen/security/advisories/GHSA-q4w9-x3rv-4c8j. If an immediate upgrade is not possible, the most effective compensating control is to stop treating generatePlaintext output as trusted: HTML-escape the returned string at the sink where it is displayed (for example he.encode or a context-appropriate HTML encoder) before inserting it into any HTML document, preview, or web view - the trade-off is that legitimate angle brackets in mail content will render as escaped entities, which is usually acceptable for a plaintext preview. Additional mitigation is to sanitize or reject user-controlled values before they reach Mailgen, stripping C0/C1 controls, U+2028, and U+2029 and any HTML tags, since the same characters that bypass the regex have no legitimate place in plain-text transactional content; alternatively, avoid the plaintext generator for untrusted input and derive the plaintext body from a separately escaped source. Deploying a strict Content-Security-Policy (no inline scripts, no onerror handlers) on any page that renders this output reduces exploitability of the resulting script injection, and forcing the plaintext body to download or display as text/plain rather than text/html removes the HTML interpretation context entirely. No published workarounds beyond patching are documented by the vendor.
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 1 package in npm
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
Mailgen renders transactional e-mail templates with EJS and, for the plaintext variant, is supposed to strip all markup from the rendered output. The vulnerable code path in index.js performs, in order, an EJS render of the cached plaintext theme, optional <br> handling, HTML entity decoding via the he library, and finally a tag-stripping regular expression: output.replace(/<(.|\n)+?>/g, ''). That pattern is fundamentally flawed because the '.' metacharacter does not match line-terminator characters (U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR) and the alternation only adds \n, so any tag containing a Unicode line separator escapes removal; the decoded separator (for example from an entity-encoded payload) is what defeats the filter. The proof-of-concept payload <img src=x onerror=alert(1) > demonstrates that a script-bearing tag survives into the returned 'plaintext'. The upstream fix in commit 7a791a4 changes the pattern to /<.+?>/gs, using the dotAll ('s') flag so '.' matches every character including U+2028/U+2029, closing the filter bypass. This is CWE-79 (Improper Neutralization of Input During Web Page Generation / cross-site scripting), specifically an output-encoding/sanitization failure in a Node.js package distributed as npm/mailgen; no CPE strings were supplied in the source data, and the primary affected artifact is the npm package rather than a server product.
Know when Node.js gets its next vulnerability
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N/E:P
AC:H because exploitation depends on the app mishandling plaintext as HTML; UI:R as the victim must view the rendered email; S:C and C:L/I:L reflect limited script execution in the victim's browser, a separate system.
Primary rating from Vendor (github).
CVSS VectorVendor: github
DescriptionCVE.org
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.
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
Cross-Site Scripting occurs when an application accepts untrusted data and sends it to a web browser without proper validation or encoding.
Remote code execution in n8n's workflow expression evaluation system allows an authenticated user with workflow creation
A vulnerability in the NuPoint Unified Messaging (NPM) component of Mitel MiCollab through 9.8 SP1 FP2 (9.8.1.201) could
FortiOS and FortiProxy contain an authentication bypass via the Node.js websocket module allowing unauthenticated remote
Denial of service against HTTP/2 server implementations allows remote unauthenticated attackers to exhaust server resour
Eval injection vulnerability in the internals.batch function in lib/batch.js in the bassmaster plugin before 1.5.2 for t
Flowise version 3.0.5 contains a remote code execution vulnerability in the CustomMCP node. The mcpServerConfig paramete
Node.js 8.5.0 before 8.6.0 allows remote attackers to access unintended files, because a change to ".." handling was inc
An issue was discovered in the node-serialize package 0.0.4 for Node.js. Rated critical severity (CVSS 9.8), this vulner
OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h does not properly restrict processing of ChangeCiph
Directory traversal vulnerability in the st module before 0.2.5 for Node.js allows remote attackers to read arbitrary fi
Multiple SQL injection vulnerabilities in the Manage Accounts page in the AccountManagement.asmx service in the Solarwin
The JS-YAML module before 2.0.5 for Node.js parses input without properly considering the unsafe !!js/function tag, whic
NVD
CVE.org
EPSS
GitHub
VulDB
Exploit-DB