nodemailer
Affected
- introduced
0, fixed9.0.1(semver)
Fixed versions
9.0.1
Fix
- Fixed version
9.0.1npm install [email protected]
Advisory
Also known as: CVE-2026-82659
Nodemailer: Message-level raw option bypasses disableFileAccess/disableUrlAccess, enabling arbitrary file read and full-response SSRF in the delivered message
Message-level raw option bypasses disableFileAccess / disableUrlAccess, enabling arbitrary file read and full-response SSRF in the sent message
nodemailer v9.0.0 (HEAD 4e58450eb490e5097a74b2b2cce35a8d9e21856e)Summary
Nodemailer exposes disableFileAccess and disableUrlAccess so an application that passes
untrusted message data to the library can forbid that data from reading local files or
fetching URLs. Every attachment, alternative, html/text/watchHtml/amp and icalEvent
content node honors these flags. The message-level `raw` option does not.
MailComposer.compile() builds the root MIME node for a raw message without threading the
two flags, so a raw: { path: '/etc/passwd' } or raw: { href: 'http://169.254.169.254/…' }
message is read / fetched anyway, and the file or HTTP-response bytes become the **actual
message that is sent** by every transport (SMTP, SES, sendmail, stream, JSON). An actor whose
input the application intended to sandbox therefore obtains arbitrary local-file disclosure and
a full-response SSRF primitive, delivered to a recipient the same actor can choose.
This is the same vulnerability class as the already-published jsonTransport advisory
GHSA-wqvq-jvpq-h66f, but a distinct code path (raw root node, not normalize()), and
strictly higher impact: the jsonTransport bug only affected the locally-returned JSON, whereas
this affects the delivered RFC822 message for all transports.
Affected component
lib/mail-composer/index.js:34-35 — root cause: if (this.mail.raw) {
this.message = new MimeNode('message/rfc822', { newline: this.mail.newline }).setRaw(this.mail.raw);
}
The MimeNode is constructed with only { newline }. Compare the sibling node builders
_createMixed/_createAlternative/_createRelated/_createContentNode
(lib/mail-composer/index.js:389-527), which all pass
disableUrlAccess: this.mail.disableUrlAccess, disableFileAccess: this.mail.disableFileAccess.
lib/mime-node/index.js:51-52 — the constructor derives this.disableFileAccess/ this.disableUrlAccess solely from its own options; children do not inherit a parent's flags (createChild/appendChild, lines 175-194, pass options through verbatim).lib/mime-node/index.js:812 — setRaw() content is resolved through this._getStream(this._raw).lib/mime-node/index.js:984-1010 — _getStream reads the file (fs.createReadStream, 995) or fetches the URL (nmfetch, 1009) only guarded by `this.disableFileAccess`/`this.disableUrlAccess`, which on the raw root node are false.lib/mailer/index.js:188 (mail.message = new MailComposer(mail.data).compile()), so every transport is affected.Reachability gate (hop-by-hop)
transporter.sendMail({ raw: <userControlled> , to: <userControlled> }) with disableFileAccess: true and/or disableUrlAccess: true configured on the transporter (forced onto mail.data in lib/mailer/mail-message.js:36-40) or per message. This is the exact scenario the flags exist for — the same precondition under which GHSA-wqvq-jvpq-h66f was accepted._createContentNode carries disableFileAccess, so _getStream throws EFILEACCESS. Bypass: the raw branch (compile():34-35) never sets the flag on its node, so this.disableFileAccess === false and the guard at mime-node:985 / :999 is skipped. There is no other validation between mail.raw and the read; raw content shapes ({path}, {href}, stream, string, buffer) are accepted as-is by setRaw/_getStream.fs.createReadStream(content.path) (file disclosure) or nmfetch(content.href, …) (SSRF). The resulting bytes are emitted as the message body by createReadStream(), which every transport pipes to its destination (smtp-transport:233, smtp-pool/pool-resource:208, ses-transport:96, sendmail-transport:184, stream-transport:67).No guard blocks the chain; the only guard (the access flags) is structurally absent on this node.
Root cause
Inconsistent enforcement: the access policy is applied per-MimeNode via constructor options and
must be re-passed at every node creation. The raw-message shortcut in compile() omits it,
while all five other node builders include it. The flags are therefore enforced for every content
type *except* the one that lets the caller supply a complete message body by path/URL.
Exploit path
Application that sandboxes untrusted mail input (disableFileAccess/disableUrlAccess set):
raw: { path: '/proc/self/environ' } (or any server file: /app/.env, key material, etc.) and to: [email protected].compile() builds the raw root node without the flags; the transport reads the file and sends its contents as the message → arbitrary server-file exfiltration to an attacker-chosen mailbox.raw: { href: 'http://127.0.0.1:8080/admin' } or a cloud metadata URL → Nodemailer fetches it server-side and delivers the full response body in the email → full-response SSRF (no blind-channel limitation).Impact
raw.Preconditions
The application (a) passes disableFileAccess and/or disableUrlAccess (the documented sandboxing
flags) and (b) lets untrusted input influence the raw field (and, for maximal disclosure, to).
No other configuration is required; all bundled transports are affected. This mirrors the accepted
precondition of GHSA-wqvq-jvpq-h66f.
Severity
raw object; deterministic.Note: if a deployment fixes the recipient (to not attacker-controlled) the disclosure channel
narrows and the rating degrades toward the sibling's Medium; the High rating reflects the
reasonable worst case where raw and to are both untrusted.
High Basis: The source's own band: HIGH
0, fixed 9.0.1 (semver)9.0.1
9.0.1npm install [email protected]Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0