GHSA-f9wg-5f46-cjmw

Suggest an improvement
Source
https://github.com/advisories/GHSA-f9wg-5f46-cjmw
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2022/04/GHSA-f9wg-5f46-cjmw/GHSA-f9wg-5f46-cjmw.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-f9wg-5f46-cjmw
Aliases
Published
2022-04-22T20:49:09Z
Modified
2023-11-08T04:08:38Z
Severity
  • 6.1 (Medium) CVSS_V3 - CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:N/A:N CVSS Calculator
Summary
NextAuth.js default redirect callback vulnerable to open redirects
Details

next-auth v3 users before version 3.29.2 are impacted. (We recommend upgrading to v4 in most cases. See our migration guide).next-auth v4 users before version 4.3.2 are impacted. Upgrading to 3.29.2 or 4.3.2 will patch this vulnerability. If you are not able to upgrade for any reason, you can add a configuration to your callbacks option:

// async redirect(url, baseUrl) { // v3
async redirect({ url, baseUrl }) { // v4
    // Allows relative callback URLs
    if (url.startsWith("/")) return new URL(url, baseUrl).toString()
    // Allows callback URLs on the same origin
    else if (new URL(url).origin === baseUrl) return url
    return baseUrl
}

If you already have a redirect callback, make sure that you match the incoming url origin against the baseUrl.

Database specific
{
    "cwe_ids":  [
        "CWE-290",
        "CWE-601"
    ],
    "github_reviewed":  true,
    "github_reviewed_at":  "2022-04-22T20:49:09Z",
    "nvd_published_at":  "2022-04-19T23:15:00Z",
    "severity":  "MODERATE"
}
References

Affected packages

npm / next-auth

Package

Affected ranges

Type
SEMVER
Events
Introduced
0 Unknown introduced version / All previous versions are affected
Fixed
3.29.2

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2022/04/GHSA-f9wg-5f46-cjmw/GHSA-f9wg-5f46-cjmw.json"

npm / next-auth

Package

Affected ranges

Type
SEMVER
Events
Introduced
4.0.0
Fixed
4.3.2

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2022/04/GHSA-f9wg-5f46-cjmw/GHSA-f9wg-5f46-cjmw.json"