CVE-2023-27490

8.1 HIGH

📋 TL;DR

This vulnerability in NextAuth.js allows attackers to bypass authentication and log in as victims by intercepting and tampering with OAuth authorization URLs. It affects Next.js applications using NextAuth.js OAuth providers before version 4.20.1. Attackers need network access to read victim traffic or ability to trick victims into clicking malicious login links.

💻 Affected Systems

Products:
  • NextAuth.js
Versions: All versions before 4.20.1
Operating Systems: All
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects applications using OAuth providers. Applications using other authentication methods are not affected.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete account takeover where attackers gain unauthorized access to user accounts, potentially accessing sensitive data, performing unauthorized actions, or escalating privileges within the application.

🟠

Likely Case

Targeted account compromise where attackers gain access to specific user accounts they can intercept traffic for or trick into clicking malicious links.

🟢

If Mitigated

No impact if proper OAuth state, PKCE, and nonce validation is implemented or if upgraded to patched version.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: MEDIUM

Exploitation requires either network access to intercept traffic or social engineering to get victims to click malicious links. The vulnerability bypasses CSRF protection.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 4.20.1

Vendor Advisory: https://github.com/nextauthjs/next-auth/security/advisories/GHSA-7r7x-4c4q-c4qf

Restart Required: Yes

Instructions:

1. Update NextAuth.js dependency to version 4.20.1 or later. 2. Run npm update next-auth or yarn upgrade next-auth. 3. Restart your Next.js application. 4. Test OAuth authentication flows.

🔧 Temporary Workarounds

Advanced Initialization with Manual Validation

all

Implement manual validation of state, PKCE, and nonce parameters in OAuth callback requests

🧯 If You Can't Patch

  • Implement manual validation of state, PKCE, and nonce parameters in all OAuth callback handlers
  • Monitor authentication logs for suspicious OAuth callback patterns and implement rate limiting

🔍 How to Verify

Check if Vulnerable:

Check package.json for next-auth version. If version is below 4.20.1 and using OAuth providers, the application is vulnerable.

Check Version:

npm list next-auth or check package.json for version

Verify Fix Applied:

Verify next-auth version is 4.20.1 or higher in package.json and test OAuth authentication flows work correctly.

📡 Detection & Monitoring

Log Indicators:

  • Multiple failed OAuth callbacks from same IP
  • OAuth callbacks with missing or mismatched state/PKCE/nonce parameters
  • Successful logins from unusual locations or IPs

Network Indicators:

  • Unusual OAuth authorization request patterns
  • Intercepted OAuth traffic with modified parameters

SIEM Query:

source="auth.log" AND ("OAuth callback failed" OR "state mismatch" OR "PKCE validation failed")

🔗 References

📤 Share & Export