CVE-2022-31093: Improper Handling of `callbackUrl` parameter in next-auth

next-auth Updated 02 Oct 2025

Summary

21/06/2022
Yes i
High
7.5

CVE-2022-31093: Improper Handling of callbackUrl parameter in next-auth. Affects next-auth across 2 version ranges.

< 3.29.5 >= 4.0.0, < 4.5.0

Fixed in 3.29.5 or 4.5.0, depending on the release line you run. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

The next-auth package is an authentication library for Next.js applications. It provides a simple and flexible way to implement authentication and authorization features. The package is widely used in the Next.js ecosystem and is known for its ease of use and robustness. However, a vulnerability has been discovered in versions before 3.29.5 (for v3 users) and before 4.5.0 (for v4 users) that allows an attacker to exploit the callbackUrl parameter, leading to API route handler timeouts and login failures.

Vulnerability Detail

The vulnerability arises from improper handling of the callbackUrl parameter in NextAuth.js. When an attacker sends a request with an invalid callbackUrl query parameter, the URL instantiation fails due to a malformed URL being passed into the constructor. This triggers an unhandled error, causing the API route handler to timeout and login to fail. The impact of this vulnerability can disrupt the authentication flow and potentially lead to unauthorized access or denial of service. The vulnerability has been assigned a CVSS score of 7.5, indicating a high severity level.

How To Fix

Latest published version: 4.24.15 as of 23 Oct 2026

npm install next-auth@4.24.15

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 3.29.5 3.29.5
    npm install next-auth@3.29.5
  • >= 4.0.0, < 4.5.0 4.5.0
    npm install next-auth@4.5.0

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

If upgrading the next-auth package is not possible, a workaround can be implemented using advanced initialization. The code snippet below demonstrates the workaround:

import NextAuth from "next-auth"

function isValidHttpUrl(url) {
  try {
    return /^https?:///.test(url);
  } catch {
    return false;
  }
}

export default async function handler(req, res) {
  if (req.query.callbackUrl && !isValidHttpUrl(req.query.callbackUrl)) {
    return res.status(500).send('');
  }
  
  return await NextAuth(req, res, /* your config */)
}

This workaround checks if the callbackUrl query parameter is present and if it is a valid HTTP or HTTPS URL. If the callbackUrl is invalid, it returns a 500 status code, effectively preventing the vulnerability from being exploited.

Conclusion

The next-auth package is vulnerable to an improper handling of the callbackUrl parameter, which can lead to API route handler timeouts and login failures. To mitigate this vulnerability, it is recommended to update to the latest patched version of the package. If upgrading is not possible, a workaround using advanced initialization is available. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for next-auth →

Share this vulnerability

FAQ

The vulnerability can cause API route handler timeouts and login failures, disrupting the authentication flow and potentially leading to unauthorized access or denial of service.

Versions before 3.29.5 for v3 users and before 4.5.0 for v4 users are affected.

To fix this vulnerability, update the next-auth package to the latest patched version. For v3 users, upgrade to version 3.29.5 or later. For v4 users, upgrade to version 4.5.0 or later.

Yes, a workaround is available using advanced initialization. Please refer to the provided code snippet in the 'Workaround' section for implementation details.

The CVSS score of this vulnerability is 7.5, indicating a high severity level.

Related vulnerabilities

Recent vulnerabilities recorded for next-auth.

How To Fix

Latest published version: 4.24.15 as of 23 Oct 2026

npm install next-auth@4.24.15

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 3.29.5 3.29.5
    npm install next-auth@3.29.5
  • >= 4.0.0, < 4.5.0 4.5.0
    npm install next-auth@4.5.0

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback