fix(deps): update dependency nodemailer to v8.0.9 [security]#1871
Open
renovate[bot] wants to merge 1 commit into
Open
fix(deps): update dependency nodemailer to v8.0.9 [security]#1871renovate[bot] wants to merge 1 commit into
renovate[bot] wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
8.0.7→8.0.9Nodemailer: Improper TLS Certificate Validation in OAuth2 Token Fetch Enables Credential Interception
GHSA-r7g4-qg5f-qqm2
More information
Details
Summary
Nodemailer disables TLS certificate verification in its internal HTTPS fetch client through the use of rejectUnauthorized: false inside lib/fetch/index.js.
As a result, OAuth2 token requests trust invalid or self-signed HTTPS certificates and transmit sensitive OAuth credentials over connections that should fail TLS validation.
An attacker in a machine-in-the-middle position can intercept OAuth2 credential exchanges and capture:
The issue was verified through runtime testing using a self-signed HTTPS OAuth endpoint.
Details
Root Cause
The issue originates from the internal HTTPS fetch implementation used by Nodemailer for OAuth2 token retrieval and related outbound HTTPS requests.
Inside:
lib/fetch/index.jsthe request options contain:
rejectUnauthorized: falseThis disables TLS peer certificate verification globally for the internal HTTPS client unless explicitly overridden through optional TLS configuration.
As a result:
This violates expected HTTPS security guarantees.
Vulnerable Flow
The vulnerable execution chain is:
OAuth2 Transport
↓
XOAuth2 token generation
↓
Internal HTTPS fetch client
↓
HTTPS request with rejectUnauthorized:false
↓
Attacker-controlled/self-signed endpoint trusted
↓
OAuth credentials transmitted
PoC
Environment
Mail API (app/server.js)
Malicious HTTPS OAuth Server (poc/evil-oauth.js)
Nodemailer OAuth2 Test (test.js)
Steps to Reproduce
PIC

Impact
The issue effectively downgrades HTTPS security protections for sensitive OAuth credential exchanges.
Severity
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Nodemailer jsonTransport bypasses disableFileAccess and disableUrlAccess during message normalization
GHSA-wqvq-jvpq-h66f
More information
Details
Summary
Nodemailer's
disableFileAccessanddisableUrlAccessoptions are intended to prevent message content and attachments from reading local files or fetching URLs. The normal MIME streaming path enforces those options inMimeNode._getStream(). However,jsonTransportserializes messages by callingmail.normalize(), which resolveshtml,text, alternatives, calendar events, and attachments throughshared.resolveContent()before MIME generation.shared.resolveContent()reads local files and fetches HTTP(S) URLs directly, without receiving or checkingdisableFileAccessordisableUrlAccess.As a result, applications that use
jsonTransportas a safe serializer or queue payload generator while relying ondisableFileAccess/disableUrlAccesscan still be made to read local files into the generated JSON output or make outbound HTTP requests when an attacker controls message content fields such as attachmentpathortext.href.The same missing-enforcement root cause is also reachable before normal streaming when
attachDataUrlscauses_convertDataImages()to callmail.resolveContent(mail.data, 'html', ...); this should be fixed with the same access-control check.Details
Source-to-sink evidence:
lib/nodemailer.js:42-45selectsJSONTransportwhencreateTransport({ jsonTransport: true, ... })is used.lib/mailer/mail-message.js:34-39copies transport-leveldisableFileAccessanddisableUrlAccessoptions intomail.data.lib/json-transport/index.js:52-76serializes mail by callingmail.normalize((err, data) => ...).lib/mailer/mail-message.js:46-135implementsresolveAll()and callsshared.resolveContent(...args, ...)forhtml,text,watchHtml,amp,icalEvent, alternatives, and attachments.lib/shared/index.js:506-562implementsresolveContent().lib/shared/index.js:540-541fetches HTTP(S) content withnmfetch(content.path || content.href).lib/shared/index.js:549-550reads local files withfs.createReadStream(content.path).shared.resolveContent()does not checkdisableFileAccessordisableUrlAccessand does not receive those flags.Control path showing intended enforcement:
lib/mail-composer/index.js:358-359,lib/mail-composer/index.js:367-368, and sibling child-node creation paths passdisableUrlAccessanddisableFileAccessintoMimeNode.lib/mime-node/index.js:51-52stores those flags.lib/mime-node/index.js:984-995rejects file paths withEFILEACCESSwhendisableFileAccessis set.lib/mime-node/index.js:998-1009rejects URLs withEURLACCESSwhendisableUrlAccessis set.test/mail-composer/mail-composer-test.js:1028-1044includes a normal MIME-streaming test that expects file access to be blocked whendisableFileAccess: true.Additional same-root-cause variant:
lib/mailer/index.js:406-434implements_convertDataImages()forattachDataUrls.lib/mailer/index.js:407-410callsmail.resolveContent(mail.data, 'html', ...)whenattachDataUrlsis enabled andmail.data.htmlis present.mail.resolveContent()delegates toshared.resolveContent()atlib/mailer/mail-message.js:42-44, an object-formhtml: { path: ... }orhtml: { href: ... }can be resolved before the later MIME streaming enforcement sees the content.attachDataUrlsto be enabled, so the main reportable default/common path isjsonTransport; both should be fixed by enforcing access flags inside the pre-resolution helper or passing policy into it.Default/common exposure evidence:
jsonTransportis a shipped runtime transport selected by publiccreateTransportoptions.test/json-transport/json-transport-test.js:9-83demonstrates thatjsonTransportintentionally resolves file-backedhtmland attachments into JSON output.disableFileAccessanddisableUrlAccessare documented by code and tests as security controls and are copied from transport options into message data for all transports.False-positive screening and negative controls:
disableFileAccess: trueanddisableUrlAccess: truetransport options for bothjsonTransportand normalstreamTransportcontrols.jsonTransportread the temporary local fixture file and embedded the content in JSON despitedisableFileAccess: true.streamTransportwith the same attachment anddisableFileAccess: truerejected withEFILEACCESS.jsonTransportfetched a local HTTP listener despitedisableUrlAccess: true.streamTransportwith the same URL anddisableUrlAccess: truerejected withEURLACCESS.127.0.0.1and did not contact external infrastructure.Affected version evidence and uncertainty:
nodemailer8.0.8 at commit15138a84c543c20aa399218534cdbbfa2ea1ce55.jsonTransporthas existed since commitd78b63b(2017-02-09, "Added test for json transport"), anddisableFileAccessappears in historical setup commit6218b8d(2017-01-31), but older versions were not dynamically tested during this audit.Severity rationale:
pathorhreftriggers the bypass whenjsonTransportis used.Final self-review:
127.0.0.1HTTP listener.streamTransportrejects the same inputs withEFILEACCESSandEURLACCESS.PoC
From a clean checkout of
nodemailerat commit15138a84c543c20aa399218534cdbbfa2ea1ce55, run:Observed output in this environment:
Expected vulnerable output:
JSON_FILE_BYPASS=true, the printed temporary marker inJSON_FILE_CONTENT, aLOCAL_HTTP_REQUEST=GET /privateline, andJSON_URL_BYPASS=true. Expected negative/control output:STREAM_FILE_CONTROL=EFILEACCESSandSTREAM_URL_CONTROL=EURLACCESS, showing the same policy flags work in the normal streaming transport.Cleanup: the PoC removes its temporary fixture file before exiting and closes the local HTTP server.
Impact
If an application uses
jsonTransportto safely serialize or queue partially user-controlled Nodemailer message objects while relying ondisableFileAccess/disableUrlAccess, an attacker can bypass those protections. The file-read variant can copy local file contents into the generated JSON message output. The URL-fetch variant can force outbound HTTP requests from the application host to local or internal services despite URL access being disabled. The impact depends on what message fields the embedding application exposes and where it stores or returns the generated JSON, but the local PoC confirms both protected sink operations are reached.Suggested remediation
Enforce
disableFileAccessanddisableUrlAccessinsideshared.resolveContent()or pass an explicit policy object into every pre-resolution call and reject protectedpath/hrefvalues before opening files or fetching URLs. Apply the same fix tojsonTransportnormalization and theattachDataUrlspre-plugin path. Add regression tests showingjsonTransportreturnsEFILEACCESS/EURLACCESSfor file and URL content when those flags are set, and thatattachDataUrlscannot resolve object-formhtml.path/html.hrefwhen the corresponding access flag is disabled.Severity
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Nodemailer: CRLF injection in Nodemailer List-* header comments allows arbitrary message header injection
GHSA-268h-hp4c-crq3
More information
Details
Summary
Nodemailer constructs
List-*headers from the caller-providedlistmessage option using internally prepared header values. Thelist.*.commentfield is inserted into those prepared values without removing CR (\r) or LF (\n) characters. Because prepared headers bypass the normal header-value sanitizer and are passed tomimeFuncs.foldLines(), a CRLF sequence in a list comment is emitted as an actual header boundary in the generated RFC822 message.An application that lets a lower-privileged or unauthenticated user influence
list.help.comment,list.unsubscribe.comment,list.subscribe.comment,list.post.comment,list.owner.comment,list.archive.comment, orlist.id.commentcan therefore be made to generate messages containing attacker-chosen additional headers.Details
Source-to-sink evidence:
lib/mailer/mail-message.js:241-249calls_getListHeaders(this.data.list)and adds each returned value withthis.message.addHeader(listHeader.key, value).lib/mailer/mail-message.js:253-296builds each list header value as{ prepared: true, foldLines: true, value: ... }.List-ID,lib/mailer/mail-message.js:272-279copiesvalue.commentinto the generated header value. IfmimeFuncs.isPlainText(comment)returns true, it wraps the comment in quotes rather than encoding or CRLF-normalizing it.List-*headers,lib/mailer/mail-message.js:283-288copiesvalue.commentinto(<comment>). IfmimeFuncs.isPlainText(comment)returns true, the value is not encoded or CRLF-normalized.lib/mime-node/index.js:323-351accepts the prepared header object.lib/mime-node/index.js:533-540trustsoptions.prepared; whenfoldLinesis set, it pushesmimeFuncs.foldLines(key + ': ' + value)directly into the header block.lib/mailer/mail-message.js:299-308removes whitespace and angle brackets fromlist.*.url, so the confirmed injection source is thecommentfield, not the URL field.Default/common exposure evidence:
lib/nodemailer.js:21-60exposes the publiccreateTransport(...).sendMail(...)flow used by the package.examples/full.js:106-123documentslist.unsubscribe.commentandlist.id.commentas normal message options.False-positive screening and negative controls:
subjectheader input containing CRLF was normalized to a singleSubject:header and did not createX-Injectedin the local control case.prepared: truecustom headers are an explicit low-level escape hatch, but this issue is different because Nodemailer itself creates prepared headers from the documentedlist.*.commentoption.Variant analysis:
Local testing confirmed the same root cause for comments in
List-Help,List-Unsubscribe,List-Subscribe,List-Post,List-Owner,List-Archive, andList-ID. These should be fixed together by rejecting or normalizing CR/LF in list comments before prepared header generation, or by avoiding the prepared-header bypass for caller-controlled list values.Affected version evidence and uncertainty:
nodemailer8.0.8 at commit15138a84c543c20aa399218534cdbbfa2ea1ce55._getListHeaderspresent in historical commits including22fcff8(v4.3.0) and related list-header work in9b4f90a(v3.1.8), but older versions were not dynamically tested during this audit.Severity rationale:
Final self-review:
streamTransportPoC and a negativeSubjectcontrol case.PoC
From a clean checkout of
nodemailerat commit15138a84c543c20aa399218534cdbbfa2ea1ce55, run:Observed output in this environment:
Expected vulnerable output:
POSITIVE_HAS_INJECTED=trueand all listed variants ending in=true. Expected negative/control output:CONTROL_HAS_INJECTED=false, showing the ordinarySubjectheader path does not create a separate injected header.Cleanup: none required; the PoC uses only in-memory message generation.
Impact
A lower-privileged attacker who can influence
list.*.commentfields in an application using Nodemailer can inject arbitrary additional headers into generated email messages. This can alter message semantics and downstream mail-client or mail-filter behavior, including adding attacker-controlled metadata headers. The PoC confirms header-boundary injection in the generated RFC822 output; it does not demonstrate SMTP command injection, recipient injection, or code execution.Suggested remediation
Normalize or reject CR and LF in
list.*.commentbefore constructing preparedList-*headers. Prefer sharing the same CRLF-neutralization behavior used for ordinary header values, or avoid usingprepared: truefor caller-controlled list comment content. Add regression tests for CRLF in every documentedlistcomment-bearing field and verify that generated messages do not contain attacker-controlled standalone headers.Severity
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Release Notes
nodemailer/nodemailer (nodemailer)
v8.0.9Compare Source
Bug Fixes
v8.0.8Compare Source
Bug Fixes
Configuration
📅 Schedule: (in timezone Europe/Vienna)
🚦 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.