{"id":"DHI-wq6p-ygnr-yzwx-qvbg","summary":"### Summary","details":"### Summary\n\nNodemailer's address parser (`lib/addressparser/index.js`) parses a list of comma‑separated addresses in **quadratic time — O(n²)** in the number of addresses. A single crafted address string (e.g. a `To`, `Cc`, `Bcc`, `From`, or `Reply‑To` value, or any value passed to the exported `addressparser`) therefore consumes CPU proportional to the **square** of its length and blocks Node's single‑threaded event loop for the entire duration, denying service to every other request in the process.\n\nThis requires **no special application configuration and no cooperating receiver** — it is entirely inside the parser and triggers on the library's default code path. A ~1.5 MB address value freezes the process for ~25–30 seconds of 100% CPU; the cost grows with the square of the input, so a few‑MB value stalls the server for minutes. It is a distinct issue from the recursion DoS fixed as CVE‑2025‑14874 (that path is guarded by a nesting‑depth cap; this one is a flat, comma‑separated list with no such limit).\n\n### Details\n\n`addressparser` tokenizes the input, splits it into per‑address token groups, and then accumulates the parsed results in a loop (`lib/addressparser/index.js`, ~lines 500–505):\n\n```js\naddresses.forEach(addr =\u003e {\n    const handled = _handleAddress(addr, depth);\n    if (handled.length) {\n        parsedAddresses = parsedAddresses.concat(handled);   // \u003c-- line ~503\n    }\n});\n```\n\n`Array.prototype.concat` builds and returns a **new** array containing a copy of every element accumulated so far. Reassigning `parsedAddresses = parsedAddresses.concat(handled)` on each of the *n* iterations copies 1 + 2 + 3 + … + n elements in total, i.e. **O(n²)** work (and O(n²) transient allocations) for an input containing *n* addresses. Tokenization and `_handleAddress` themselves are linear; the quadratic blowup is entirely this accumulator.\n\n**Root‑cause proof.** Replacing only that line with an in‑place append and re‑running the exact same input:\n\n```\nparsedAddresses = parsedAddresses.concat(handled);      -\u003e  100000 addresses:  ~6068 ms\nparsedAddresses.push.apply(parsedAddresses, handled);   -\u003e  100000 addresses:  ~51 ms   (≈119x faster, now linear)\n```\n\n**Measured scaling** (nodemailer 9.0.6, `'a@b.com,'.repeat(n)`):\n\n| addresses n | input size | parse time | ratio for 2× input |\n|---|---|---|---|\n| 25,000  | 0.19 MB | ~0.35 s | – |\n| 50,000  | 0.38 MB | ~1.4 s  | ×4.0 |\n| 100,000 | 0.76 MB | ~6–8 s  | ×3.9 |\n| 200,000 | 1.53 MB | ~25–30 s| ×4.1 |\n\nDoubling the input quadruples the time — the signature of O(n²).\n\n**Reachability.** The parser is invoked on any structured‑address header value on the normal send path (`MimeNode.setHeader('To'/'Cc'/'Bcc'/'From'/'Reply-To', value)` → `_parseAddresses` → `addressparser`, and `getEnvelope()`), so a single `transport.sendMail({ to: \u003ccrafted string\u003e })` triggers it. It is also reached directly through the **exported** `require('nodemailer/lib/addressparser')`, which many applications call to validate or display user‑supplied recipient lists. Confirmed via the public API: `setHeader('To', 'a@b.com,'.repeat(80000))` + `getEnvelope()` blocks for ~3.9 s.\n\n**Suggested fix:** accumulate in place instead of rebuilding the array each iteration, e.g. `parsedAddresses.push.apply(parsedAddresses, handled);` (or `for (const h of handled) parsedAddresses.push(h);`). Optionally cap the number of addresses / input length before parsing.\n\n### PoC\n\nEnvironment: Node.js ≥ 18 and the published `nodemailer@9.0.6`. No transport, network, or configuration required — the cost is in parsing.\n\n`poc-dos.js`:\n```js\n'use strict';\nconst addressparser = require('nodemailer/lib/addressparser');\n\nconsole.log('addresses | input size | parse time');\nfor (const n of [25000, 50000, 100000, 200000]) {\n  const payload = 'a@b.com,'.repeat(n);        // n valid, comma-separated recipients\n  const t0 = process.hrtime.bigint();\n  addressparser(payload);                       // blocks synchronously\n  const ms = Number(process.hrtime.bigint() - t0) / 1e6;\n  console.log(String(n).padStart(9) + ' | ' + (payload.length / 1048576).toFixed(2) + ' MB   | ' + ms.toFixed(0).padStart(7) + ' ms');\n}\n```\n\nRun:\n```\nnpm init -y && npm install nodemailer@9.0.6\nnode poc-dos.js\n```\n\nActual output (nodemailer 9.0.6):\n```\naddresses | input size | parse time\n    25000 | 0.19 MB   |     381 ms\n    50000 | 0.38 MB   |    1435 ms\n   100000 | 0.76 MB   |    7949 ms\n   200000 | 1.53 MB   |   25154 ms\n```\n\nEquivalent trigger through the normal send API (freezes the event loop):\n```js\nconst nodemailer = require('nodemailer');\nnodemailer.createTransport({ jsonTransport: true })\n  .sendMail({ from: 'a@b.com', to: 'a@b.com,'.repeat(150000), subject: 'x', text: 'y' });\n// ~15+ seconds of 100% CPU inside addressparser before anything is sent\n```\n\n### Impact\n\n* **Who is impacted:** any service that runs Nodemailer (or the standalone `nodemailer/lib/addressparser`) on an address value that can be influenced by an untrusted party — a recipient field in a \"send email / invite / share\" feature, a `Reply‑To`/`From` derived from user input, a contact‑import or mailing‑list parser, or any endpoint that validates addresses with `addressparser`. No authentication, special option, or particular receiver is needed.\n\n## Patched in 9.1.0\n\nThree separate quadratic paths were fixed, not one:\n\n* `addressparser` rebuilt its accumulator with `concat()` on every address ([9116da9](https://github.com/nodemailer/nodemailer/commit/9116da9)).\n* The display-name merge loop directly below spliced each fragment out of the array, the same shape reached through `'a, b \u003cc@d.com\u003e,'.repeat(n)` (same commit).\n* `MimeNode#_convertAddresses` checked recipient uniqueness with a linear scan per address ([7cc38af](https://github.com/nodemailer/nodemailer/commit/7cc38af), refined in [34da642](https://github.com/nodemailer/nodemailer/commit/34da642)). This was the most severe of the three and the reported proof of concept did not reach it: `'a@b.com,'.repeat(n)` is one address repeated, which dedupes to a single envelope entry. A list of *distinct* recipients cost O(n^2) here, taking ~35s for 100k even after `addressparser` was fixed.\n\nFixed alongside: `[].concat.apply` in `_parseAddresses` threw `RangeError: Maximum call stack size exceeded` past roughly 124k recipients, with no crafted input needed ([83b8c48](https://github.com/nodemailer/nodemailer/commit/83b8c48)).\n\nParsing 200k addresses now takes ~80ms instead of ~25s, and every path scales linearly. A new `maxRecipients` option (default 100000) throws rather than truncating, as a backstop.","modified":"2026-11-20T17:01:14.740811451Z","published":"2026-11-14T01:06:37Z","upstream":["GHSA-2x7j-588g-ccc2"],"references":[{"type":"ADVISORY","url":"https://scout.docker.com/v/DHI-wq6p-ygnr-yzwx-qvbg"},{"type":"ADVISORY","url":"https://github.com/advisories/GHSA-2x7j-588g-ccc2"},{"type":"ADVISORY","url":"https://github.com/nodemailer/nodemailer/security/advisories/GHSA-2x7j-588g-ccc2"},{"type":"FIX","url":"https://github.com/nodemailer/nodemailer/pull/1848"},{"type":"FIX","url":"https://github.com/nodemailer/nodemailer/commit/9116da9528c6524cefaed75185602a7e85d20434"},{"type":"FIX","url":"https://github.com/nodemailer/nodemailer/commit/7cc38af418ffa6fc7e86085195ca5ca681694b3e"},{"type":"FIX","url":"https://github.com/nodemailer/nodemailer/commit/34da64282dcdc9b0581c721a27ab2fa226673150"},{"type":"WEB","url":"https://github.com/nodemailer/nodemailer/releases/tag/v9.1.0"}],"affected":[{"package":{"name":"langfuse-2","ecosystem":"Docker Hardened Images:Debian:13","purl":"pkg:deb/dhi/langfuse-2"},"versions":["2.95.12-0","2.95.12-1","2.95.12-10","2.95.12-11","2.95.12-12","2.95.12-13","2.95.12-2","2.95.12-3","2.95.12-4","2.95.12-5","2.95.12-6","2.95.12-7","2.95.12-8","2.95.12-9"],"database_specific":{"owner_kind":"HSP","source":"https://github.com/docker-hardened-images/advisories/blob/main/dhi/osv/2026/DHI-wq6p-ygnr-yzwx-qvbg.json"}},{"package":{"name":"langfuse-3","ecosystem":"Docker Hardened Images:Debian:13","purl":"pkg:deb/dhi/langfuse-3"},"versions":["3.225.0-0","3.225.0-1","3.225.1-0","3.225.1-1","3.225.10-0","3.225.11-0","3.225.12-0","3.225.12-1","3.225.12-2","3.225.14-0","3.225.15-0","3.225.15-1","3.225.15-2","3.225.2-0","3.225.3-0","3.225.4-0","3.225.5-0","3.225.5-1","3.225.7-0","3.225.7-1","3.225.8-0","3.225.8-1","3.225.9-0","3.227.0-0","3.227.0-1","3.227.1-0","3.227.1-1","3.227.1-2"],"database_specific":{"owner_kind":"HSP","source":"https://github.com/docker-hardened-images/advisories/blob/main/dhi/osv/2026/DHI-wq6p-ygnr-yzwx-qvbg.json"}},{"package":{"name":"langfuse-4","ecosystem":"Docker Hardened Images:Debian:13","purl":"pkg:deb/dhi/langfuse-4"},"versions":["4.10.0-0","4.11.0-0","4.12.0-0","4.13.0-0","4.14.0-0","4.15.0-0","4.26.0-0","4.3.1-0","4.36.1-0","4.38.0-0","4.4.0-0","4.41.0-0","4.43.0-0","4.44.0-0","4.46.0-0","4.47.0-0","4.48.0-0","4.5.0-0","4.5.0-1","4.50.0-0","4.53.0-0","4.6.0-0","4.63.0-0","4.67.0-0","4.69.0-0","4.70.0-0","4.70.1-0","4.71.0-0","4.71.0-1","4.72.0-1","4.74.0-0","4.75.0-0","4.76.0-0","4.76.0-1","4.77.0-0","4.78.0-0","4.79.0-0","4.79.0-1","4.80.0-0","4.80.0-1","4.81.0-0","4.82.0-0","4.83.0-0","4.9.0-0"],"database_specific":{"owner_kind":"HSP","source":"https://github.com/docker-hardened-images/advisories/blob/main/dhi/osv/2026/DHI-wq6p-ygnr-yzwx-qvbg.json"}},{"package":{"name":"uptime-kuma-1","ecosystem":"Docker Hardened Images:Debian:13","purl":"pkg:deb/dhi/uptime-kuma-1"},"versions":["1.23.17-0","1.23.17-1","1.23.17-11","1.23.17-2","1.23.17-3","1.23.17-4","1.23.17-5","1.23.17-6","1.23.17-7","1.23.17-8","1.23.17-9"],"database_specific":{"owner_kind":"HSP","source":"https://github.com/docker-hardened-images/advisories/blob/main/dhi/osv/2026/DHI-wq6p-ygnr-yzwx-qvbg.json"}}],"schema_version":"1.9.2","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"}]}