LiveActive security incident?Get immediate response
CVE Record

CVE-2022-31127: Improper handling of email input in next-auth

NextAuth.js is a complete open source authentication solution for Next.js applications. An attacker can pass a compromised input to the e-mail [signin endpoint](https://next-auth.js.org/getting-started/rest-api#post-apiauthsigninprovider) that contains some malicious HTML, tricking the e-mail server to send it to the user, so they can perform a phishing attack. Eg.: `balazs@email.com, <a href="http://attacker.com">Before signing in, claim your money!</a>`. This was previously sent to `balazs@email.com`, and the content of the email containing a link to the attacker's site was rendered in the HTML. This has been remedied in the following releases, by simply not rendering that e-mail in the HTML, since it should be obvious to the receiver what e-mail they used: next-auth v3 users before version 3.29.8 are impacted. (We recommend upgrading to v4, as v3 is considered unmaintained. next-auth v4 users before version 4.9.0 are impacted. If for some reason you cannot upgrade, the workaround requires you to sanitize the `email` parameter that is passed to `sendVerificationRequest` and rendered in the HTML. If you haven't created a custom `sendVerificationRequest`, you only need to upgrade. Otherwise, make sure to either exclude `email` from the HTML body or efficiently sanitize it.

HighCVSS 7.1Not KEV-listedUpdated
Glexia's TakeAutomated analysishigh

Security readout for executives and security teams

Plain-English summary

This flaw lets an attacker place malicious HTML into the email sign-in address field so the legitimate NextAuth email sign-in message can carry phishing content. The main risk is credential theft or user deception through a trusted application email, not direct server takeover. Vendor fixes remove the unsafe email rendering.

Executive priority

Prioritize remediation where authentication emails are user-facing or brand-trusted. The business risk is phishing through a legitimate application channel, which can damage trust and support credential compromise even without server compromise.

Technical view

CVE-2022-31127 is CWE-79 in next-auth email sign-in handling. Affected versions are v3 before 3.29.8 and v4 before 4.9.0. The vulnerable flow rendered user-controlled email input in HTML verification emails. The fix stops rendering that email in the HTML body.

Likely exposure

Exposure is likely limited to Next.js applications using next-auth email sign-in on affected versions, especially deployments with custom sendVerificationRequest templates that render the email parameter into HTML.

Exploitation context

The source bundle does not show known active exploitation, and KEV is false. Exploitation requires a victim to act on phishing content delivered through the application’s legitimate email sign-in flow.

Researcher notes

The advisory describes improper handling of email input in the sign-in endpoint, mapped to CWE-79 with CVSS 7.1. The relevant remediation is version upgrade or safe handling of the email parameter in custom verification email code. Evidence for exploit-in-the-wild is not present in the supplied sources.

Mitigation direction

  • Upgrade next-auth v4 deployments to 4.9.0 or later.
  • Upgrade v3 deployments to 3.29.8, preferably migrate to maintained v4.
  • Remove the email parameter from verification email HTML bodies.
  • Sanitize the email parameter in any custom sendVerificationRequest implementation.
  • Review vendor guidance before applying compensating controls.

Validation and detection

  • Inventory all applications using next-auth email provider sign-in.
  • Check dependency manifests and lockfiles for affected next-auth versions.
  • Identify custom sendVerificationRequest implementations and email templates.
  • Confirm verification emails no longer render user-controlled email input as HTML.
  • Review public routes exposing the email sign-in provider.
Prepared
Confidence
high
Sources
6

Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.

Potential ATT&CK relevance

Conservative CVE-to-ATT&CK context

These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.

ATT&CK lookup starting points

Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.

cwe · medium confidence lookup

CWE-79: User-session and phishing behavior lookup

Client-side and session-facing weaknesses should be reviewed alongside initial-access and user-execution behaviors. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.

Open ATT&CK lookup
cve · low confidence lookup

CVE-2022-31127 mapping review

Open the CVE-to-ATT&CK bridge for reviewed, inferred, or future official mappings tied to this CVE.

Open ATT&CK lookup
Vulnerability profileCVE Program record
Severity
High
CVSS
7.1 (3.1)
Known Exploited
No
Published

Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:L

Official CVE source material

CNA and ADP enrichment extracted from CVE v5

These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.

1CVSS vectors
0Timeline events
0ADP providers
6Source links

CVSS vector scores

1 official score

We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.

ScoreVersionSeverityVectorExploitImpactSource
7.1CVSS 3.1HighCVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:L2.83.7Primary CVE score

Vulnerability scoring details

Base CVSS 3.1 score

7.1High
CVSS 3.1 vector shape for CVE-2022-31127Attack VectorAttack ComplexityPrivileges RequiredUser InteractionScopeConfidentiality ImpactIntegrity ImpactAvailability Impact

Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:L

Attack Vector
NetworkAdjacentLocalPhysical
Attack Complexity
LowHigh
Privileges Required
NoneLowHigh
User Interaction
NoneRequired
Scope
ChangedUnchanged
Confidentiality Impact
HighLowNone
Integrity Impact
HighLowNone
Availability Impact
HighLowNone
Affected products

Products and packages named in the record

VendorProductVersion / packageStatus
nextauthjsnext-auth< 3.29.8, >= 4.0.0, < 4.9.0Listed
Weakness

CWE details

CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.

CWE-79 · source CWE mapping

Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.