Skip to main content

Mailgen CVE-2025-62380

LOW
Cross-site Scripting (XSS) (CWE-79)
2025-10-15 security-advisories@github.com
2.9
CVSS 4.0 · Vendor: github
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Submit untrusted content with Unicode-separator HTML tag
  2. Delivery
    App calls Mailgen.generatePlaintext
  3. Exploit
    Regex filter bypassed, entity decode restores tag
  4. Execution
    Plaintext rendered in HTML context
  5. Impact
    Script 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 <img src=x onerror=alert(1)\u2028> is published in the GHSA advisory), but this is NOT active exploitation - there is no CISA KEV listing. POC availability and active exploitation are distinct signals; do not conflate them. The E:P (Proof-of-Concept exploit maturity) in the vendor vector aligns with the published PoC. Net: real but low-severity, contingent on insecure downstream handling; prioritize via normal dependency-update hygiene, not emergency patching.

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 <img src=x onerror=alert(1)\u2028>. A transactional-email backend passes that content to Mailgen.generatePlaintext; the regex tag-stripper fails to match the tag because of the U+2028 character, and he.decode later restores it to valid HTML. If the application then renders that supposedly-plaintext string in an HTML context (e.g. a web mail preview), the script executes in the victim's browser. A working PoC payload is published in the GHSA advisory.

Monitor Track and reassess. Why: LOW severity (CVSS 0.1-3.9).
Patch available 0.5% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – 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

npm mailgen fix: 2.0.32

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

Vendor (github) PRIMARY 2.9 LOW
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
vuln.today AI 4.7 MEDIUM

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.

3.1 AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N
4.0 AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N

Primary rating from Vendor (github).

CVSS VectorVendor: github

Attack Vector
Network
Attack Complexity
Low
Attack Requirements
Present
Privileges Required
None
User Interaction
None
Vulnerable system: Confidentiality
None
Vulnerable system: Integrity
None
Vulnerable system: Availability
None
Subsequent system: Confidentiality
Low
Subsequent system: Integrity
Low
Subsequent system: Availability
None

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

EPSS Score
0.5%
Top 63% exploitable
Prevalence
Medium
popular npm transactional-email library, but exposure depends on downstream HTML misuse
Data Quality
5 sources
Confidence: Medium

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.

SignalValue
Severity LOW
CISA KEV No
Public POC No
EPSS 0.5%
Patch available Yes
Active threat No
Deciding rule
LOW severity (CVSS 0.1-3.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation· derived
None
System Exposure· derived
Open
Automatable· derived
Yes
Human Impact· derived
Low

Priority Score

14
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +14
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Cross-Site Scripting occurs when an application accepts untrusted data and sends it to a web browser without proper validation or encoding.

CVE-2025-68613 HIGH POC
8.8 Dec 19

Remote code execution in n8n's workflow expression evaluation system allows an authenticated user with workflow creation

CVE-2024-41713 CRITICAL POC
9.1 Oct 21

A vulnerability in the NuPoint Unified Messaging (NPM) component of Mitel MiCollab through 9.8 SP1 FP2 (9.8.1.201) could

CVE-2024-55591 CRITICAL POC
9.8 Jan 14

FortiOS and FortiProxy contain an authentication bypass via the Node.js websocket module allowing unauthenticated remote

CVE-2023-44487 HIGH POC
7.5 Oct 10

Denial of service against HTTP/2 server implementations allows remote unauthenticated attackers to exhaust server resour

CVE-2014-7205 CRITICAL POC
10.0 Oct 08

Eval injection vulnerability in the internals.batch function in lib/batch.js in the bassmaster plugin before 1.5.2 for t

CVE-2025-59528 CRITICAL POC
10.0 Sep 22

Flowise version 3.0.5 contains a remote code execution vulnerability in the CustomMCP node. The mcpServerConfig paramete

CVE-2017-14849 HIGH POC
7.5 Sep 28

Node.js 8.5.0 before 8.6.0 allows remote attackers to access unintended files, because a change to ".." handling was inc

CVE-2017-5941 CRITICAL POC
9.8 Feb 09

An issue was discovered in the node-serialize package 0.0.4 for Node.js. Rated critical severity (CVSS 9.8), this vulner

CVE-2014-0224 HIGH POC
7.4 Jun 05

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

CVE-2014-3744 HIGH POC
7.5 Oct 23

Directory traversal vulnerability in the st module before 0.2.5 for Node.js allows remote attackers to read arbitrary fi

CVE-2014-9566 HIGH POC
7.5 Mar 10

Multiple SQL injection vulnerabilities in the Manage Accounts page in the AccountManagement.asmx service in the Solarwin

CVE-2013-4660 MEDIUM POC
6.8 Jun 28

The JS-YAML module before 2.0.5 for Node.js parses input without properly considering the unsafe !!js/function tag, whic

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy