Skip to content

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

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

Merged
merged 1 commit into from
Mar 26, 2023

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Mar 26, 2023

Mend Renovate

This PR contains the following updates:

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


Release Notes

nextauthjs/next-auth

v4.20.1

Compare Source

Full Changelog: https://github.com/nextauthjs/next-auth/compare/next-auth@4.20.0...next-auth@4.20.1

v4.20.0

Compare Source

What's Changed

New Contributors

Full Changelog: https://github.com/nextauthjs/next-auth/compare/next-auth@4.19.2...next-auth@4.20.0

v4.19.2

Compare Source

What's Changed

Full Changelog: https://github.com/nextauthjs/next-auth/compare/next-auth@4.19.1...next-auth@4.19.2

v4.19.1

Compare Source

What's Changed

New Contributors

Full Changelog: https://github.com/nextauthjs/next-auth/compare/next-auth@4.19.0...next-auth@4.19.1

v4.19.0

Compare Source

What's Changed

Full Changelog: https://github.com/nextauthjs/next-auth/compare/next-auth@4.18.10...next-auth@4.19.0

v4.18.10

Compare Source

Full Changelog: https://github.com/nextauthjs/next-auth/compare/next-auth@4.18.9...next-auth@4.18.10

v4.18.9

Compare Source

Bugfixes

  • next-auth: remove engines (f54424c)
  • providers: default image to null for Azure AD (09bcc1d)
  • Allow adding own logo to provider (#​6465)

v4.18.8

Compare Source

What's Changed

Full Changelog: https://github.com/nextauthjs/next-auth/compare/next-auth@v4.18.7...next-auth@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)

Configuration

📅 Schedule: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).

🚦 Automerge: Enabled.

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 requested a review from a team March 26, 2023 17:06
@netlify
Copy link

netlify bot commented Mar 26, 2023

Deploy Preview for netlify-plugin-nextjs-export-demo ready!

Name Link
🔨 Latest commit 66249a5
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-export-demo/deploys/64207bac9c10a60009c0f84a
😎 Deploy Preview https://deploy-preview-2010--netlify-plugin-nextjs-export-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 26, 2023

Deploy Preview for netlify-plugin-nextjs-nx-monorepo-demo ready!

Name Link
🔨 Latest commit 66249a5
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-nx-monorepo-demo/deploys/64207bac8aae580008405d2e
😎 Deploy Preview https://deploy-preview-2010--netlify-plugin-nextjs-nx-monorepo-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 26, 2023

Deploy Preview for next-plugin-edge-middleware ready!

Name Link
🔨 Latest commit 66249a5
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-edge-middleware/deploys/64207bac7230c50008db6752
😎 Deploy Preview https://deploy-preview-2010--next-plugin-edge-middleware.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions github-actions bot added the type: bug code to address defects in shipped code label Mar 26, 2023
@netlify
Copy link

netlify bot commented Mar 26, 2023

Deploy Preview for next-i18next-demo ready!

Name Link
🔨 Latest commit 66249a5
🔍 Latest deploy log https://app.netlify.com/sites/next-i18next-demo/deploys/64207bac7456e50007aac390
😎 Deploy Preview https://deploy-preview-2010--next-i18next-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 26, 2023

Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!

Name Link
🔨 Latest commit 66249a5
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-next-auth-demo/deploys/64207bacfdd2d00007e6fd24
😎 Deploy Preview https://deploy-preview-2010--netlify-plugin-nextjs-next-auth-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 26, 2023

Deploy Preview for nextjs-plugin-custom-routes-demo ready!

Name Link
🔨 Latest commit 66249a5
🔍 Latest deploy log https://app.netlify.com/sites/nextjs-plugin-custom-routes-demo/deploys/64207bacb5d7b80009d18c74
😎 Deploy Preview https://deploy-preview-2010--nextjs-plugin-custom-routes-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 26, 2023

Deploy Preview for netlify-plugin-nextjs-demo ready!

Name Link
🔨 Latest commit 66249a5
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-demo/deploys/64207bac6988c40008df8c01
😎 Deploy Preview https://deploy-preview-2010--netlify-plugin-nextjs-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 26, 2023

Deploy Preview for next-plugin-canary ready!

Name Link
🔨 Latest commit 66249a5
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-canary/deploys/64207bac599e9a0008de4436
😎 Deploy Preview https://deploy-preview-2010--next-plugin-canary.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 26, 2023

Deploy Preview for netlify-plugin-nextjs-static-root-demo ready!

Name Link
🔨 Latest commit 66249a5
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-static-root-demo/deploys/64207bacd2fd7d000884f637
😎 Deploy Preview https://deploy-preview-2010--netlify-plugin-nextjs-static-root-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@kodiakhq kodiakhq bot merged commit 6d8bc95 into main Mar 26, 2023
@kodiakhq kodiakhq bot deleted the renovate/npm-next-auth-vulnerability branch March 26, 2023 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants