Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

Conversation

renovate[bot]
Copy link

@renovate renovate bot commented Mar 18, 2023

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
next-auth (source) 4.12.0 -> 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


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 added the renovate label Mar 18, 2023
@vercel
Copy link

vercel bot commented Mar 18, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ama-prisma ❌ Failed (Inspect) Nov 21, 2023 0:45am

@renovate renovate bot changed the title chore(deps): update dependency next-auth to 4.20.1 [security] fix(deps): update dependency next-auth to v4.20.1 [security] Mar 24, 2023
@renovate renovate bot force-pushed the renovate/npm-next-auth-vulnerability branch from 7e854e2 to 24fb09a Compare November 21, 2023 00:44
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants