Skip to main content

Mailgen CVE-2025-62366

LOW
Cross-site Scripting (XSS) (CWE-79)
2025-10-14 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 entity-encoded HTML in user content
  2. Delivery
    Bypass regex tag-stripping filter
  3. Exploit
    he.decode() reconstructs active HTML tag
  4. Execution
    Downstream app renders plaintext as HTML
  5. Impact
    Attacker 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. &lt...&gt) to bypass the regex tag-stripper before he.decode() reactivates them. LIMITING FACTORS: if the output is used as true plaintext (its intended purpose), there is no impact; a victim must view the rendered output for JavaScript to execute; and only versions through 2.0.30 are affected (2.0.31+ is patched). No known workarounds exist short of upgrading.

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 &ltimg src=xyz onerror=alert(1)&gt, which the tag-stripping regex misses and the he.decode() step turns back into a live <img> tag with an onerror handler, executing attacker JavaScript when the output is displayed. A working proof-of-concept payload is published in the GHSA advisory.

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

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

Alert me

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

npm mailgen fix: 2.0.31

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 &ltimg src=xyz onerror=alert(1)&gt 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

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 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.

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:P/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.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

EPSS Score
0.4%
Top 65% exploitable
Prevalence
Medium
moderately popular npm transactional-email library, not a core infrastructure component
Data Quality
4 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.4%
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