---
id: "GHSA-8c8m-p3m8-cjg8"
kind: "vulnerability"
aliases: ["GHSA-8c8m-p3m8-cjg8"]
title: "Nodemailer: A nested comment ends early in addressparser, releasing the rest of the comment as a recipient"
severity: "medium"
cvss: 6.5
epss: null
exploited: false
status: "open"
category: "package"
products: [{"name": "nodemailer", "fixed": ["10.1.4"], "affected": ">= 3.0.0, < 10.1.4", "ecosystem": "npm"}]
ecosystems: ["npm"]
tags: ["cwe-20", "cwe-436", "mail-sending-apps", "mailparser", "node.js", "nodemailer", "package"]
not_affected_if: ["no-user-controlled-addresses", "nodemailer-10.1.4-or-later", "nodemailer-below-3.0.0"]
published_at: "2026-10-23T21:53:04+00:00"
first_seen_at: "2026-10-23T21:56:55+00:00"
updated_at: "2026-10-23T21:57:08+00:00"
sources: [{"source": "ghsa", "url": "https://github.com/advisories/GHSA-8c8m-p3m8-cjg8", "first_seen_at": "2026-10-23T21:56:55+00:00"}]
---

# Nodemailer: A nested comment ends early in addressparser, releasing the rest of the comment as a recipient

Nodemailer's address parser ends an RFC 5322 comment at the first closing parenthesis, so a nested comment makes it read the rest of the address as a different recipient. An attacker who controls an address passed to Nodemailer can redirect mail to an attacker chosen domain even when the application's own validator approved the address.

_Summary, check and fix written by a model from the sources; labelled as such._

## Affected

- npm:nodemailer affected >= 3.0.0, < 10.1.4 fixed 10.1.4

## How to check

Check the installed version: npm ls nodemailer (affected if 3.0.0 through 10.1.3).
Audit any code that passes user-supplied addresses to sendMail or to mailparser's From/To handling.

## Fix

Upgrade nodemailer to 10.1.4 or later.
If upgrading is not possible now, reject address strings containing nested parentheses before passing them to Nodemailer.

## Timeline

- 2026-10-23T21:56:55+00:00 ghsa https://github.com/advisories/GHSA-8c8m-p3m8-cjg8

## From the sources

### Vulnerability summary

RFC 5322 comments nest. addressparser ended a comment at the first `)`, including the one that closes a nested comment, and parsed the rest of the outer comment as header text. `Victim (x(y) <evil@evil.com>) <v@victim.com>` names `v@victim.com` with `x(y) <evil@evil.com>` as a comment, and Nodemailer read it as the address `evil@evil.com`. This is the same shape as the escaped parenthesis fixed in 10.1.2, reached through nesting instead of a quoted-pair. Affected: 3.0.0 through 10.1.3.

### Attacker capabilities

The attacker controls the text of an address that an application passes to Nodemailer, or the From or To header of an inbound message parsed with mailparser. No access to the application, its configuration or its credentials is needed. The value is a syntactically valid RFC 5322 address that conformant parsers accept without defects.

### Realistic exploitation scenario

An application validates a submitted address with a conformant parser and allows only its own domain. The attacker submits `Victim (x(y) <evil@evil.com>) <v@victim.com>`, which validates as `v@victim.com`. Nodemailer delivers to `evil@evil.com`. In the inbound direction, a DMARC or display layer built on a conformant parser and a mail client built on mailparser disagree on the author of the same message, which is the setting for sender spoofing. The boundary crossed is the application's recipient allow list, or the author check of the receiving side.

### Proof of concept

```js
const addressparser = require('nodemailer/lib/addressparser');
console.log(addressparser("Victim (x(y) <evil@evil.com>) <v@victim.com>"));
// [ { address: 'evil@evil.com', name: 'Victim) v@victim.com' } ]
```

Python's `email._header_value_parser.get_address_list` reads the same value as `v@victim.com` with the display name `Victim`, with no defects reported.

The envelope a message gets is built from the same parse, so `sendMail({ to: "Victim (x(y) <evil@evil.com>) <v@victim.com>" })` issues the RCPT TO shown above.

### Security impact

Mail intended for an approved recipient is delivered to an attacker chosen domain, disclosing its content, and parsers built on this module report a different author than conformant ones. The misreading only occurs on values a conformant validator approves, so correct validation is bypassed. Affected are applications that pass user influenced addresses to Nodemailer and consumers of the standalone parser such as mailparser.

The fix counts comment depth and ends a comment only at the `)` that closes the outermost one.

Found in an internal review of addressparser on 2026-10-18. Verified on 3.0.0, 6.9.16 and 10.1.3.

---

_Free to read at a human pace. An API with keys and an MCP server are in preparation; early access: hello@infrastack.ai_
