Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

fix(deps): update dependency next-auth to v4.24.5 [security] #286

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Mar 13, 2023

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
next-auth (source) 4.10.3 -> 4.24.5 age adoption passing confidence

GitHub Vulnerability Alerts

CVE-2023-27490

Impact

next-auth applications using OAuth provider versions before v4.20.1 are affected.

A bad actor who can spy on the victim's network or able to social engineer the victim to click a manipulated login link could intercept and tamper with the authorization URL to log in as the victim, bypassing the CSRF protection.

As an example, an attack can happen in the following scenario.

TL;DR: The attacker steals the victim's authenticated callback by intercepting and tampering with the authorization URL created by next-auth.

  1. The victim attempts to log in to the next-auth site. For example https://next-auth-example.vercel.app/
  2. next-auth sets the checks cookies according to how the OAuth provider is configured. In this case, state and pkce are set by default for the Google Provider.

Screen Shot 2023-03-03 at 09 54 26

  1. The attacker intercepts the returned authorization URL, strips away the OAuth check (nonce, state, pkce), and returns the URL without the check to the victim's browser. For example:
    From
    https://accounts.google.com/o/oauth2/v2/auth/oauthchooseaccount?client_id=client_id&scope=openid%20email%20profile&response_type=code&redirect_uri=https%3A%2F%2Fnext-auth-example.vercel.app%2Fapi%2Fauth%2Fcallback%2Fgoogle&state=state&code_challenge=code_challenge&code_challenge_method=S256&service=lso&o2v=2&flowName=GeneralOAuthFlow
    to
    https://accounts.google.com/o/oauth2/v2/auth/oauthchooseaccount?client_id=client_id&scope=openid%20email%20profile&response_type=code&redirect_uri=https%3A%2F%2Fnext-auth-example.vercel.app%2Fapi%2Fauth%2Fcallback%2Fgoogle&service=lso&o2v=2&flowName=GeneralOAuthFlow.
    Notice the parameters state, code_challenge and code_verifier are removed from the victim's address bar.

  2. The victim attempts to log in using their OAuth account.

  3. The Authorization Server logs the victim in and calls back to the next-auth api/auth/callback/:providerIdendpoint.
    5.1. The attacker intercepts and logs this callback URL for later use.
    5.2. next-auth checks the callback call from OAuth Authorization Server (doesn't have checks) and compares the checks with the cookies set (has checks) at step 2. This check will fail, resulting in the victim isn't logged in. However, at this step, the Authorization Server has already accepted the victim's request to log in and generated/sent a code in the URL.

  4. The attacker now has an authorization URL with the code that the AS will exchange for valid access_token/id_token and can log in as the victim automatically. They can open a new browser window and paste in the URL logged at step 5.1 and log in as the victim.

Patches

We patched the vulnerability in next-auth v4.20.1
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 Advanced Initialization, developers can manually check the callback request for state, pkce, and nonce against the provider configuration, and abort the sign-in process if there is a mismatch. Check out the source code for help.

References

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


Release Notes

nextauthjs/next-auth (next-auth)

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

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/[email protected]@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

v4.20.0

Compare Source

v4.19.2

Compare Source

What's Changed

Full Changelog: https://github.com/nextauthjs/next-auth/compare/[email protected]@4.19.2

v4.19.1

Compare Source

What's Changed

New Contributors

Full Changelog: https://github.com/nextauthjs/next-auth/compare/[email protected]@4.19.1

v4.19.0

Compare Source

What's Changed

Full Changelog: https://github.com/nextauthjs/next-auth/compare/[email protected]@4.19.0

v4.18.10

Compare Source

v4.18.9

Compare Source

v4.18.8

Compare Source

What's Changed

Full Changelog: https://github.com/nextauthjs/next-auth/compare/[email protected]@4.18.8

v4.18.7

Compare Source

Bugfixes

v4.18.6

Compare Source

Bugfixes

v4.18.5

Compare Source

Bugfixes

v4.18.4

Compare Source

Bugfixes

v4.18.3

Compare Source

Bugfixes

  • core: throw error if no action can be determined (157269e)
  • core: add protocol if missing (221bc8e)

Other

v4.18.2

Compare Source

Bugfixes

v4.18.1

Compare Source

Bugfixes

  • core: don't mutate authOptions in unstable_getServerSession (#​5973) (b19b2bc)

Other

v4.18.0

Compare Source

Features

  • core: make pkce and state maxAge configurable on the cookies (#​4719) (f277989)

Bugfixes

Other

v4.17.0

Compare Source

Features

Bugfixes

Other

  • fix signin btns svg URLs to 'main' (#​5826)

v4.16.4

Compare Source

Bugfixes

v4.16.3

Compare Source

Bugfixes

v4.16.2

Compare Source

Bugfixes

  • next: build RSC+unstable_getServerSession (180c625)

v4.16.1

Compare Source

v4.16.0

Features

  • next: allow unstable_getServerSession in Server Components (#​5741) (e90925b)

v4.15.1

Compare Source

Bugfixes

Other

  • update example to Next.js 13

v4.15.0

Compare Source

Features

Other

v4.14.0

Compare Source

Features

Bugfixes

Other

  • dev: improve DX (f38ee19)
  • fix TS lint

v4.13.0

Compare Source

Features

Bugfixes

Other

  • docs: update middleware documentation link (#​5492) (0a4b99d)
  • release: bump package version(s) [skip ci] (d6efda0)

v4.12.3

Compare Source

Bugfixes

Other

v4.12.2

Compare Source

Bugfixes

v4.12.1

Compare Source

Bugfixes

v4.12.0

Compare Source

Features

  • core: make session token with DB session strategy customizable (#​5328) (965c626)

Others

v4.11.0

Compare Source

Features

Bugfixes

  • middleware: use includes() for NextAuth pages (#​5104) (44f2a47)
  • providers: use client_secret_post token auth for LinkedIn (#​5236) (ba20974)
  • providers: convert Strava Provider to TS (#​5241) (f1d3bc2)
  • providers: Add appid param to Azure AD wellKnown URL (#​5138) (a03657e)
  • Change getToken parameter type to required (#​5245)
  • return null in unstable_getServerSession if there's an error (#​5218)
  • Use consistent error type between doc, logger and error class (#​5046)

Other


Configuration

📅 Schedule: Branch creation - "" in timezone Europe/Paris, 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 has been generated by Mend Renovate. View repository job log here.

@renovate renovate bot added the dependencies Pull requests that update a dependency file label Mar 13, 2023
@sonarcloud
Copy link

sonarcloud bot commented Mar 13, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@renovate renovate bot changed the title fix(deps): update dependency next-auth to v4.20.1 [security] fix(deps): update dependency next-auth to v4.24.5 [security] Nov 21, 2023
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from c899338 to da07448 Compare November 21, 2023 01:18
Copy link

sonarcloud bot commented Nov 21, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link

Updated dependencies detected. Learn more about Socket for GitHub ↗︎

Packages Version New capabilities Transitives Size Publisher
next-auth 4.10.3...4.24.5 eval, network, filesystem +33/-7 1.15 GB balazsorban

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants