Mailgen CVE-2025-62366
LOWAttack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessSubmit entity-encoded HTML in user content
-
DeliveryBypass regex tag-stripping filter
-
Exploithe.decode() reconstructs active HTML tag
-
ExecutionDownstream app renders plaintext as HTML
-
ImpactAttacker JavaScript executes in victim context
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 TWO specific conditions together: (1) the application calls Mailgen.generatePlaintext() with user-generated/attacker-influenced content, AND (2) the resulting 'plaintext' string is subsequently rendered or interpreted as HTML (in a browser, web client, or HTML email view) rather than displayed as literal text - this misuse of plaintext-as-HTML is the core enabling condition. The payload must use HTML-entity-encoded tags (e.g. |
| Impact | This is a genuinely low-priority issue despite being a code-execution-capable XSS (CWE-79), and the multiple signals are consistent rather than conflicting. The CVSS 4.0 vector (AV:N/AC:L/AT:P/PR:N/UI:N) scores only 2.9, driven down by AT:P (a specific attack requirement) and by impact being confined to the subsequent system (VC:N/VI:N/VA:N but SC:L/SI:L) - i.e. no impact on mailgen itself, only on a downstream rendering context. EPSS is low at 0.43% (35th percentile), the CVE is NOT on CISA KEV, and exploitation status is 'publicly available exploit code exists' (a working payload is published in the GHSA advisory) - note that POC availability is distinct from active exploitation, and there is no evidence of in-the-wild use. The key caveat: the real-world impact depends entirely on a condition the vector only partially captures - the generated 'plaintext' string must be misused by the consuming application as HTML. The CVSS vector shows UI:N, but realistic XSS execution requires a victim to view the rendered output, so the practical exploitability is lower than a naive reading of AV:N/PR:N/UI:N suggests. Overall: a legitimate defect worth patching, not an urgent emergency. |
| Exploit ScenarioDerived | A developer uses Mailgen.generatePlaintext() with user-supplied content (e.g. a username or message) and then, by mistake, renders that 'plaintext' output as HTML in a web view or client. An attacker submits HTML-entity-encoded markup such as |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – Oct 08, 2026
HTML injection in Mailgen through 2.0.30 can become XSS when the generatePlaintext() output is rendered as HTML; the flaw lets HTML-entity-encoded tags pass through the tag-stripping regex before he.decode() reactivates them. Exploitation is remote and unauthenticated per the CVSS vector (PR:N) but requires user interaction and the specific misuse of the intended plaintext string as HTML, and only applications passing user-generated content to generatePlaintext are affected. Publicly available exploit code exists, the issue is not confirmed actively exploited (no CISA KEV), EPSS is 0.43% (35th percentile), and the vendor-released fix is Mailgen 2.0.31.
RemediationAI
Upgrade Mailgen to version 2.0.31 or later; this is the vendor-released patch and the only identified fix. The upstream fix is in commit 7279a983481d05c51aa451e86146f98aaa42fee9, and the advisory is at https://github.com/eladnava/mailgen/security/advisories/GHSA-xw6r-chmh-vpmj. No known workarounds exist, so applications that cannot immediately upgrade should avoid passing untrusted content to generatePlaintext(), or if the output must be handled, treat the returned string as literal text and HTML-escape it before any browser or HTML-view rendering; that compensating control may break intended formatting but prevents decoded entity-encoded tags from becoming active HTML. Because exploitation requires the downstream application to render plaintext as HTML, removing that misuse is an effective mitigation with the trade-off that callers must ensure all sinks HTML-encode untrusted output.
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 is a Node.js package for transactional email generation; generatePlaintext() renders an EJS plaintext theme, replaces <br> tags, strips apparent HTML with a regex, then decodes HTML entities with he.decode(). Because the stripping happens before decoding, entity-encoded tags such as <img src=xyz onerror=alert(1)> survive and are decoded into active HTML. This is CWE-79 (improper neutralization of input during web page generation / XSS) rather than a failure in the email-generation core itself: the generated string is supposed to be plaintext, so impact appears only when a downstream consumer renders that output as HTML. The affected package is npm/mailgen through 2.0.30, and 2.0.31 fixes it. The independent assessment assigns CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N, reflecting high attack complexity and required interaction, while the provided CVSS:4.0 score is 2.9 and EPSS is 0.43%.
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 and UI:R because execution depends on the consuming app mis-rendering plaintext as HTML and a victim viewing it; S:C and C:L/I:L reflect limited XSS impact on a downstream component, not mailgen itself.
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.30 contain an HTML injection vulnerability in plaintext emails produced by the generatePlaintext method when user‑generated content is supplied. The function attempts to remove HTML tags, but if tags are provided as encoded HTML entities they are not removed and are later decoded, resulting in active HTML (for example an img tag with an event handler) in the supposed plaintext output. In contexts where the generated plaintext string is subsequently rendered as HTML, this can allow execution of attacker‑controlled JavaScript. Versions 2.0.31 and later contain a fix. No known workarounds exist.
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
Exploit-DB