Summary
Possible user mocking that bypasses basic authentication
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
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.
CVE-2023-48309 has a CVSS score of 5.3 (Medium). The vector is network-reachable, no privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (4.24.5); upgrading removes the vulnerable code path.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
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
Frequently Asked Questions
- What is CVE-2023-48309? CVE-2023-48309 is a medium-severity security vulnerability in next-auth (npm), affecting versions < 4.24.5. It is fixed in 4.24.5.
- How severe is CVE-2023-48309? CVE-2023-48309 has a CVSS score of 5.3 (Medium). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which versions of next-auth are affected by CVE-2023-48309? next-auth (npm) versions < 4.24.5 is affected.
- Is there a fix for CVE-2023-48309? Yes. CVE-2023-48309 is fixed in 4.24.5. Upgrade to this version or later.
- Is CVE-2023-48309 exploitable, and should I be worried? Whether CVE-2023-48309 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether CVE-2023-48309 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix CVE-2023-48309? Upgrade
next-authto 4.24.5 or later.