{"id":"CVE-2022-31127","published":"2022-07-06T18:00:16Z","modified":"2025-04-22T17:51:28Z","title":"Improper handling of email input in next-auth","vendor":"nextauthjs","product":"next-auth","tier":"tail","description":{"text":"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.","provenance":"source","from":"CVE.org"},"cvss":{"score":7.1,"severity":"HIGH","version":"3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:L","provenance":"source","from":"CVE.org CNA"},"epss":{"score":0.01094,"percentile":0.6507,"provenance":"source"},"cwes":[{"id":"CWE-79","name":"Improper Neutralization of Input During Web Page Generation"}],"references":[{"url":"https://next-auth.js.org/getting-started/upgrade-v4","tags":["x_refsource_MISC"]},{"url":"https://github.com/nextauthjs/next-auth/security/advisories/GHSA-pgjx-7f9g-9463","tags":["x_refsource_CONFIRM"]},{"url":"https://github.com/nextauthjs/next-auth/commit/ae834f1e08a4a9915665eecb9479c74c6b039c9c","tags":["x_refsource_MISC"]},{"url":"https://github.com/nextauthjs/next-auth/releases/tag/next-auth%40v4.9.0","tags":["x_refsource_MISC"]},{"url":"https://next-auth.js.org/providers/email#customizing-emails","tags":["x_refsource_MISC"]}],"priority":{"score":18.0,"factors":[{"name":"EPSS percentile","points":13.01},{"name":"CVSS severity","points":4.97}]},"vendorSlug":"nextauthjs","affectedVersions":[{"vendor":"nextauthjs","product":"next-auth","versions":["< 3.29.8",">= 4.0.0, < 4.9.0"]}],"ssvc":{"exploitation":"poc","automatable":"no","technicalImpact":"partial","timestamp":"2025-04-22T15:45:38.302117Z","from":"CISA ADP","provenance":"source"},"affected":[{"ecosystem":"npm","package":"next-auth","vulnerableRanges":["<3.29.8",">=4.0.0, <4.9.0"],"patched":["3.29.8","4.9.0"],"from":["GHSA-pgjx-7f9g-9463"],"provenance":"source"}],"euvd":{"id":"EUVD-2022-6383","exploited":false,"provenance":"source"},"lineage":{"familyId":"fam-nextauthjs-next-auth-cve-2022-31127","children":[{"from":"CVE-2022-31127","to":"CVE-2022-35924","relation":"related","confidence":"medium","kind":"lineage","evidence":[{"kind":"same-code","provenance":"machine","files":["packages/next-auth/src/core/lib/email/signin.ts","packages/next-auth/src/core/routes/signin.ts","packages/next-auth/src/providers/email.ts"],"commits":["https://github.com/nextauthjs/next-auth/commit/ae834f1e08a4a9915665eecb9479c74c6b039c9c","https://github.com/nextauthjs/next-auth/commit/afb1fcdae3cc30445038ef588e491d139b916003"],"basis":"shared function","functions":["Email","EmailConfig","email","signin"]}]}],"packageHistory":[{"cve":"CVE-2022-24858","published":"2022-04-19","fixed":"4.3.2","kev":false},{"cve":"CVE-2022-29214","published":"2022-05-20","fixed":"4.3.3","kev":false},{"cve":"CVE-2022-31093","published":"2022-06-27","fixed":"4.5.0","kev":false,"link":{"from":"CVE-2022-31093","to":"CVE-2022-31127","relation":"successor","confidence":"low","kind":"sequence","evidence":[{"kind":"version-step","provenance":"source","package":"npm:next-auth","fromFixed":"3.29.5","toFixed":"3.29.8","daysApart":9},{"kind":"version-step","provenance":"source","package":"npm:next-auth","fromFixed":"4.5.0","toFixed":"4.9.0","daysApart":9}]}},{"cve":"CVE-2022-31127","published":"2022-07-06","fixed":"4.9.0","kev":false},{"cve":"CVE-2022-31186","published":"2022-08-01","fixed":"4.10.2","kev":false,"link":{"from":"CVE-2022-31127","to":"CVE-2022-31186","relation":"successor","confidence":"low","kind":"sequence","evidence":[{"kind":"version-step","provenance":"source","package":"npm:next-auth","fromFixed":"3.29.8","toFixed":"3.29.9","daysApart":26},{"kind":"version-step","provenance":"source","package":"npm:next-auth","fromFixed":"4.9.0","toFixed":"4.10.2","daysApart":26}]}},{"cve":"CVE-2022-35924","published":"2022-08-02","fixed":"4.10.3","kev":false},{"cve":"CVE-2023-27490","published":"2023-03-09","fixed":"4.20.1","kev":false}],"package":"npm:next-auth"}}