GHSA-6vj9-mwq6-2f5v
Nodemailer: Process-global DNS cache reuses TLS `servername` across transports, enabling cross-tenant SMTP credential disclosure
- Risk score
- 40/100
- CVSS
- 5.9 v3.1
- Published
- 28 Sep 2026
Open in the live forecast Today's forecast
What to know
- What it is
- Nodemailer's process-global DNS cache is keyed only by host, but each cache entry also stores the caller-specific TLS servername. When two direct SMTPS transports use the same DNS host with different tls.servername values, the first transport's server name is returned to the second transport and overwrites its explici…
- Affected
- nodemailer (npm) >= 5.0.0, < 10.0.2
- Fix
- Upgrade nodemailer to 10.0.2 or later.
- Exploitation
- No known exploitation
Story map
At a glance
nodemailer: Amber, patch this week. nodemailer/lib/addressparser parses one shape of address in O(n^2) time. A single ~640 KB address value blocks the Node.js event loop for roughly 7 seconds. And it is reachable without auth: mailparser feeds inbound email headers straight into this parser, so one crafted email is enough to stall a service that parses …
The flaws
- GHSA-6vj9-mwq6-2f5v: Nodemailer: Process-global DNS cache reuses TLS `servername` across transports, enabling cross-tenant SMTP credential disclosure (CVSS 5.9)
- CVE-2026-90776: Nodemailer addressparser: O(n^2) on comment-joined addresses enables a remote DoS (reachable via mailparser) (CVSS 7.5 · EPSS 1%)
- GHSA-v53p-9fqp-m79j: Nodemailer: Quadratic backtracking in the addressparser free-text fallback allows remote denial of service (CVSS 7.5)
- CVE-2026-110871: Nodemailer: Quadratic (O(n^2)) DKIM header unfolding lets a large folded header cause remote denial of service during signing (CVSS 6.5 · EPSS 0%)
The fix
Upgrade nodemailer: 10.0.10 or later on your release line
Who is exposed: nodemailer (npm) >= 9.1.0, <= 10.0.4
Where it stands
- Public proof of concept
Connects to
- Same weakness: CWE-295 (CWE-295). 82 other warnings in 30 days
Why it is Yellow
- CVSS 5.9 medium
- On your watchlist: npm
Affected packages
| Package | Ecosystem | Vulnerable | Fixed in |
|---|---|---|---|
| nodemailer | npm | >= 5.0.0, < 10.0.2 | 10.0.2 |
References
- https://github.com/advisories/GHSA-6vj9-mwq6-2f5v
- https://github.com/nodemailer/nodemailer/security/advisories/GHSA-6vj9-mwq6-2f5v
- https://github.com/nodemailer/nodemailer/commit/a6512dbcb3c6e7f2f70d3acccc5752defe3c61fe
- https://github.com/nodemailer/nodemailer/releases/tag/v10.0.2
- https://github.com/advisories/GHSA-6vj9-mwq6-2f5v
Original description
### Summary Nodemailer's process-global DNS cache is keyed only by `host`, but each cache entry also stores the caller-specific TLS `servername`. When two direct SMTPS transports use the same DNS host with different `tls.servername` values, the first transport's server name is returned to the second transport and overwrites its explicitly configured value. As a result, Nodemailer sends the wrong SNI value and verifies the peer certificate against the wrong identity. In a multi-tenant service or SNI-routed SMTP gateway, one tenant can prime the cache so that a victim transport connects to the attacker's TLS virtual host, accepts the attacker's certificate with `rejectUnauthorized: true`, and sends the victim's SMTP credentials to it. ## Affected component - **Ecosystem:** npm - **Package:** `nodemailer` - **Repository:** https://github.com/nodemailer/nodemailer - **Tested version:** `10.0.1` - **Tested commit:** `40d52215aac65b811d7e131bc916f68605efd9d2` - **Runtime-confirmed vulnerable versions:** `5.0.0` and `10.0.1` - **Affected versions:** `>= 5.0.0, <= 10.0.1` - **Patched versions:** None known at the time of this report - **Affected mode:** Direct TLS/SMTPS connections (`secure: true`) where different transports use the same non-IP `host` and different TLS `servername` values The vulnerable cache implementation was introduced in commit `6859b5dd96c8d9f0070a3169a877181b71df4a3b` on 2018-12-28. Git history shows `v5.0.0` as the first release tag containing that commit. The behavior remains present in `v10.0.1`. ## Details ### Root cause `src/shared/index.ts` defines one module-global DNS cache, keyed only by the DNS host: ```ts export const dnsCache = new Map<string, DnsCacheEntry>(); ``` Although the cache key contains only `host`, the cached value contains both DNS addresses and the request-specific TLS identity: ```ts const value: DnsCacheValue = { addresses: allAddresses, servername: options.servername || host }; dnsCache.set(host, { value, expires: Date.now() + (options.dnsTtl || DNS_TTL) }); ``` On a cache hit, `resolveHostname()` returns the cached `servername` without considering the current call's `options.servername`: ```ts if (!cached.expires || cached.expires >= now) { return callback( null, formatDNSValue(cached.value, { cached: true }) ); } ``` `formatDNSValue()` copies that stale value into the result: ```ts return Object.assign( { servername: value.servername, host, _addresses: addresses }, extra || {} ); ``` For a direct TLS connection, `SMTPConnection.connect()` initially copies the current transport's TLS configuration into `opts`. `_resolveAndConnect()` then overwrites every truthy field with the cached resolver result, including `opts.servername`: ```ts Object.assign(opts, this.options.tls || {}); if (this.servername && !opts.servername) { opts.servername = this.servername; } return this._resolveAndConnect(opts, resolved => { this._connectToHost(opts, this.secureConnection); }); ``` ```ts for (const key of Object.keys(resolved!)) { if (key.charAt(0) !== '_' && (resolved as { [key: string]: any })[key]) { (opts as { [key: string]: any })[key] = (resolved as { [key: string]: any })[key]; } } ``` The resulting `opts` object is passed to `tls.connect()`. Node therefore sends the cached server name as SNI and verifies the certificate against that cached name, rather than against the server name explicitly configured for the current transport. The default DNS cache TTL is five minutes: ```ts const DNS_TTL = 5 * 60 * 1000; ``` ### Code path ```text Tenant A: createTransport({ host: H, secure: true, tls: { servername: attackerName } }) -> SMTPConnection.connect() -> _resolveAndConnect(opts) -> shared.resolveHostname({ host: H, servername: attackerName }) -> dnsCache.set(H, { addresses, servername: attackerName }) Victim: createTransport({ host: H, secure: true, tls: { servername: victimName } }) -> SMTPConnection.connect() -> opts.servername = victimName -> _resolveAndConnect(opts) -> shared.resolveHostname({ host: H, servername: victimName }) -> dnsCache.get(H) -> returns cached servername = attackerName -> _resolveAndConnect overwrites opts.servername -> tls.connect({ servername: attackerName }) -> attacker SNI virtual host and certificate are selected -> AUTH transmits victim SMTP credentials ``` ### Relevant source locations in the tested revision - `src/shared/index.ts:184` — five-minute default cache TTL - `src/shared/index.ts:245` — process-global cache keyed by host - `src/shared/index.ts:247-262` — cached `servername` returned by `formatDNSValue()` - `src/shared/index.ts:292-323` — host-only lookup and cache-hit return - `src/shared/index.ts:350-359` — caller-specific `servername` stored in host-only cache - `src/smtp-connection/index.ts:713-729` — direct TLS options and resolver call - `src/smtp-connection/index.ts:741-763` — cached fields overwrite current connection options ## PoC ### Prerequisites - Node.js 20 (tested with Node.js `20.20.2`) - A checkout/build of Nodemailer `10.0.1` - OpenSSL to generate the local test certificate No external SMTP server or network access is required. ### 1. Generate a certificate for only `attacker.test` Create `openssl.cnf`: ```ini [req] distinguished_name = dn x509_extensions = ext prompt = no [dn] CN = attacker.test [ext] subjectAltName = DNS:attacker.test basicConstraints = critical,CA:TRUE keyUsage = critical,digitalSignature,keyEncipherment,keyCertSign extendedKeyUsage = serverAuth ``` Generate the certificate and private key: ```bash openssl req -x509 -newkey rsa:2048 -nodes -days 1 \ -keyout attacker-key.pem -out attacker-cert.pem -config openssl.cnf ``` ### 2. Save the following as `poc-dns-cache-servername-confusion.mjs` Adjust the two import paths if the PoC is not saved b
Last activity 28 Sep 2026. Patch Forecast updates every hour.