fix(deps): update dependency nodemailer to v8 [security]#8065
fix(deps): update dependency nodemailer to v8 [security]#8065renovate-bot wants to merge 1 commit intogoogleapis:mainfrom
Conversation
|
/gcbrun |
There was a problem hiding this comment.
Code Review
This pull request updates the nodemailer dependency in the compute samples to version ^8.0.0. Feedback suggests bumping the version to ^8.0.5 to address known security vulnerabilities (GHSA-c7w3-x93f-qmm8 and GHSA-vvjj-xcjg-gr5g). Additionally, the update may require adjustments to error handling logic due to renamed error codes, and the nodemailer-smtp-transport dependency may now be redundant.
| "@google-cloud/compute": "^6.9.0", | ||
| "@sendgrid/mail": "^8.0.0", | ||
| "nodemailer": "^7.0.0", | ||
| "nodemailer": "^8.0.0", |
There was a problem hiding this comment.
The security vulnerabilities GHSA-c7w3-x93f-qmm8 and GHSA-vvjj-xcjg-gr5g are addressed in nodemailer version 8.0.5. Specifying ^8.0.5 ensures these fixes are applied and prevents the installation of vulnerable versions (8.0.0-8.0.4). Additionally, be aware that nodemailer v8 renames the NoAuth error code to ENOAUTH, which may require updates to error handling logic in the sample code. The nodemailer-smtp-transport dependency is also likely redundant as v8 includes built-in SMTP support.
| "nodemailer": "^8.0.0", | |
| "nodemailer": "^8.0.5", |
02da8a6 to
83f3283
Compare
|
/gcbrun |
83f3283 to
05436bd
Compare
|
/gcbrun |
05436bd to
07a344e
Compare
|
/gcbrun |
07a344e to
994a8c5
Compare
|
/gcbrun |
994a8c5 to
640e63b
Compare
|
/gcbrun |
640e63b to
3e94255
Compare
|
/gcbrun |
3e94255 to
bf5cda0
Compare
|
/gcbrun |
bf5cda0 to
171b15a
Compare
|
/gcbrun |
171b15a to
b6a808c
Compare
|
/gcbrun |
b6a808c to
3396a1f
Compare
|
/gcbrun |
3396a1f to
0c1cfa4
Compare
|
/gcbrun |
0c1cfa4 to
83fe1a8
Compare
|
/gcbrun |
83fe1a8 to
d99cb91
Compare
|
/gcbrun |
d99cb91 to
a68b87b
Compare
|
/gcbrun |
a68b87b to
091c2e1
Compare
|
/gcbrun |
091c2e1 to
52caef9
Compare
|
/gcbrun |
52caef9 to
1ab67f7
Compare
|
/gcbrun |
1ab67f7 to
d7e3a94
Compare
|
/gcbrun |
d7e3a94 to
b7c0083
Compare
|
/gcbrun |
b7c0083 to
83dfe57
Compare
|
/gcbrun |
83dfe57 to
8cb61ad
Compare
|
/gcbrun |
This PR contains the following updates:
^7.0.0→^8.0.5GitHub Vulnerability Alerts
GHSA-c7w3-x93f-qmm8
Summary
When a custom
envelopeobject is passed tosendMail()with asizeproperty containing CRLF characters (\r\n), the value is concatenated directly into the SMTPMAIL FROMcommand without sanitization. This allows injection of arbitrary SMTP commands, includingRCPT TO— silently adding attacker-controlled recipients to outgoing emails.Details
In
lib/smtp-connection/index.js(lines 1161-1162), theenvelope.sizevalue is concatenated into the SMTPMAIL FROMcommand without any CRLF sanitization:This contrasts with other envelope parameters in the same function that ARE properly sanitized:
from,to): validated for[\r\n<>]at lines 1107-1127dsn.ret,dsn.envid,dsn.orcpt): encoded viaencodeXText()at lines 1167-1183The
sizeproperty reaches this code path throughMimeNode.setEnvelope()inlib/mime-node/index.js(lines 854-858), which copies all non-standard envelope properties verbatim:Since
_sendCommand()writes the command string followed by\r\nto the raw TCP socket, a CRLF in thesizevalue terminates theMAIL FROMcommand and starts a new SMTP command.Note: by default, Nodemailer constructs the envelope automatically from the message's
from/tofields and does not includesize. This vulnerability requires the application to explicitly pass a customenvelopeobject with asizeproperty tosendMail().While this limits the attack surface, applications that expose envelope configuration to users are affected.
PoC
ave the following as
poc.jsand run withnode poc.js:Expected output:
The
RCPT TO:<attacker@evil.com>line is injected by the CRLF in thesizefield, silently adding an extra recipient to the email.Impact
This is an SMTP command injection vulnerability. An attacker who can influence the
envelope.sizeproperty in asendMail()call can:RCPT TOcommands, receiving copies of all emails sent through the affected transportRSET, additionalMAIL FROMto send entirely separate emails through the server)The severity is mitigated by the fact that the
envelopeobject must be explicitly provided by the application. Nodemailer's default envelope construction from message headers does not includesize. 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.sizeis supported.Severity
CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:NGHSA-vvjj-xcjg-gr5g
Summary
Nodemailer versions up to and including 8.0.4 are vulnerable to SMTP command injection via CRLF sequences in the transport
nameconfiguration option. Thenamevalue 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, thenameoption is concatenated directly into the EHLO command:The
_sendCommandmethod writes the string directly to the socket followed by\r\n(line 1082):If the
nameoption contains\r\nsequences, each injected line is interpreted by the SMTP server as a separate command. Unlike theenvelope.fromandenvelope.tofields which are validated for\r\n(line 1107-1119), and unlikeenvelope.sizewhich was recently fixed (GHSA-c7w3-x93f-qmm8) by casting to a number, thenameparameter 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 (
namevssize), uses a different injection point (EHLO command vs MAIL FROM command), and occurs at connection initialization rather than during message sending.The
nameoption is also used in HELO (line 1384) and LHLO (line 1333) commands with the same lack of sanitization.PoC
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
nameSMTP transport option. This includes:What can an attacker do:
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
nameoption by stripping or rejecting CRLF sequences, similar to howenvelope.fromandenvelope.toare already validated on lines 1107-1119 oflib/smtp-connection/index.js. For example:Severity
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:NRelease Notes
nodemailer/nodemailer (nodemailer)
v8.0.5Compare Source
Bug Fixes
v8.0.4Compare Source
Bug Fixes
v8.0.3Compare Source
Bug Fixes
v8.0.2Compare Source
Bug Fixes
v8.0.1Compare Source
Bug Fixes
v8.0.0Compare Source
⚠ BREAKING CHANGES
Bug Fixes
v7.0.13Compare Source
Bug Fixes
v7.0.12Compare Source
Bug Fixes
v7.0.11Compare Source
Bug Fixes
v7.0.10Compare Source
Bug Fixes
v7.0.9Compare Source
Bug Fixes
v7.0.7Compare Source
Bug Fixes
v7.0.6Compare Source
Bug Fixes
v7.0.5Compare Source
Bug Fixes
v7.0.4Compare Source
Bug Fixes
v7.0.3Compare Source
Bug Fixes
v7.0.2Compare Source
Bug Fixes
v7.0.1Compare Source
Bug Fixes
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.