Miggo Logo

GHSA-5jpx-9hw9-2fx4: NextAuthjs Email misdelivery Vulnerability

N/A

CVSS Score

Basic Information

CVE ID
-
EPSS Score
-
Published
10/29/2025
Updated
10/29/2025
KEV Status
No
Technology
TechnologyJavaScript

Technical Details

CVSS Vector
-
Package NameEcosystemVulnerable VersionsFirst Patched Version
next-authnpm< 4.24.124.24.12
next-authnpm>= 5.0.0-beta.0, < 5.0.0-beta.305.0.0-beta.30

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability exists in how the next-auth library handles email addresses for authentication, specifically due to a parsing flaw in its dependency, nodemailer (versions prior to 7.0.7). An attacker could craft a malicious email address string such as "e@attacker.com"@victim.com. The vulnerable code in next-auth would fail to properly sanitize this input before passing it to nodemailer. The vulnerable version of nodemailer would then incorrectly parse this string, leading to the authentication email being sent to the attacker's address (e@attacker.com) instead of the legitimate user's domain (victim.com).

The analysis of the patches reveals two key locations where this vulnerability is addressed. The first is within the signin function in packages/next-auth/src/core/routes/signin.ts. The second is within the defaultNormalizer function, which is called by the sendToken function in packages/core/src/lib/actions/signin/send-token.ts. In both cases, the patches introduce stricter validation for email addresses, specifically checking for and rejecting formats that include quotes or multiple '@' symbols, which are characteristic of this exploit. The patches also update the nodemailer dependency to a non-vulnerable version as the primary mitigation. Therefore, the signin and sendToken (along with its internal defaultNormalizer) functions are the vulnerable functions that would appear in a runtime profile during an exploit attempt.

Vulnerable functions

signin
packages/next-auth/src/core/routes/signin.ts
The `signin` function in `packages/next-auth/src/core/routes/signin.ts` is vulnerable because it uses a flawed email normalization logic that can be exploited. The original code, `let [local, domain] = identifier.toLowerCase().trim().split("@")`, improperly parses crafted email addresses like `"e@attacker.com"@victim.com`. This allows an attacker to have authentication emails misdelivered to an email address they control. The patch adds validation to reject such formats.
sendToken
packages/core/src/lib/actions/signin/send-token.ts
The `sendToken` function utilizes an internal `defaultNormalizer` function to process email addresses before sending a verification token. The original implementation of `defaultNormalizer` was vulnerable to the same email parsing flaw as the `signin` function, using `email.toLowerCase().trim().split("@")` to parse the address. This could be exploited to redirect verification emails. The `sendToken` function is the entry point for this vulnerable logic.
defaultNormalizer
packages/core/src/lib/actions/signin/send-token.ts
This function, used within `sendToken`, contains the vulnerable email parsing logic. It takes an email string and splits it at the "@" symbol without properly validating the format. This allows an attacker to craft an input like `"e@attacker.com"@victim.com`, causing the underlying `nodemailer` library to misinterpret the recipient's address and send the email to the attacker. The patch introduces checks to prevent this.

WAF Protection Rules

WAF Rule

### Summ*ry N*xt*ut*.js's *m*il si*n-in **n ** *or*** to **liv*r *ut**nti**tion *m*ils to *n *tt**k*r-*ontroll** m*il*ox *u* to * *u* in `no**m*il*r`'s ***r*ss p*rs*r us** *y t** proj**t (*ix** in `no**m*il*r` **v*.*.***). * *r**t** input su** *s:

Reasoning

T** vuln*r**ility *xists in *ow t** `n*xt-*ut*` li*r*ry **n*l*s *m*il ***r*ss*s *or *ut**nti**tion, sp**i*i**lly *u* to * p*rsin* *l*w in its **p*n**n*y, `no**m*il*r` (v*rsions prior to *.*.*). *n *tt**k*r *oul* *r**t * m*li*ious *m*il ***r*ss strin*