CVE-2023-48309 next-auth vulnerable to possible user mocking that bypasses basic authentication

Medium 5.3 Published Updated

Attackers can bypass authentication by injecting a JWT from an interrupted OAuth flow, allowing them to simulate a logged-in state and view protected UI elements.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2023-48309?

CVE-2023-48309 is a medium-severity authentication bypass vulnerability in nextauthjs next-auth, published on 20 Nov 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official description

NextAuth.js provides authentication for Next.js. `next-auth` applications prior to version 4.24.5 that rely on the default Middleware authorization are affected by a vulnerability. 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). `next-auth` `v4.24.5` contains a patch for the vulnerability. As a workaround, using a custom authorization callback for Middleware, developers can manually do a basic authentication.

Weakness: CWE-863, CWE-285

Which versions are affected by CVE-2023-48309?

2 open source packages ship an affected version, including next-auth. It affects 1 product.

PackageAffectedFixed in
next-auth npmAll versions4.24.5
next-auth npmAll versions4.24.5

Products include Nextauth.js Next-Auth.

How do I fix CVE-2023-48309?

Upgrade next-auth to 4.24.5 or later.

Upgrade, and rotate credentials and sessions that may have been exposed. More about Authentication bypass.

Is CVE-2023-48309 being exploited?

There is no known exploitation of CVE-2023-48309 in the wild and no public exploit code.

Sources

Also known as GHSA-v64w-49xw-qq89.

Is CVE-2023-48309 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free