Improper Authorization Affecting next-auth package, versions <4.24.5


Severity

0.0
medium
0
10

    Threat Intelligence

    EPSS
    0.06% (27th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk ID SNYK-JS-NEXTAUTH-6069933
  • published 21 Nov 2023
  • disclosed 20 Nov 2023
  • credit Magnus N. Malmquist, dastaj

How to fix?

Upgrade next-auth to version 4.24.5 or higher.

Overview

next-auth is an Authentication for Next.js

Affected versions of this package are vulnerable to Improper Authorization by obtaining an issued JWT from an interrupted OAuth sign-in flow. An attacker can manually override the next-auth.session-token cookie value with this non-related JWT, allowing the attacker to create an empty/mock user and peek at logged-in user states.

Notes:

  1. Only applications prior to version 4.24.5 that rely on the default Middleware authorization are affected.

  2. This vulnerability does not give access to other users' data, neither to resources that require proper authorization via scopes or other means.

  3. Regardless of the vulnerability, the existence of a NextAuth.js session state can provide simple authentication, but not authorization in your applications.

Workaround

Developers can manually perform basic authentication:


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

export default withAuth(/your middleware function/, { callbacks: { authorized: ({ token }) => !!token?.email } })

References

CVSS Scores

version 3.1
Expand this section

Snyk

5.3 medium
  • Attack Vector (AV)
    Network
  • Attack Complexity (AC)
    Low
  • Privileges Required (PR)
    None
  • User Interaction (UI)
    None
  • Scope (S)
    Unchanged
  • Confidentiality (C)
    Low
  • Integrity (I)
    None
  • Availability (A)
    None
Expand this section

NVD

5.3 medium