At most one auth library wired up
Why it matters
Two active auth libraries means two independent systems of record for who a user is. Password reset may work in NextAuth but silently fail for Clerk-authenticated users. Session revocation on logout may only fire in one library, leaving valid sessions alive in the other. OWASP A07 (Identification & Authentication Failures) and CWE-287 both flag fragmented identity systems as a direct path to authentication bypass — attackers can exploit the gap between which library enforces your authorization checks and which issued the session token they forged. Every route that trusts the wrong library is unprotected.
Severity rationale
Critical because split auth systems produce routes that enforce access control against a session they didn't issue, creating authentication bypass vulnerabilities exploitable without credentials.
Remediation
Pick one auth library and route every session lookup through it. Delete the runner-up's session-getting code, consolidate into a single src/lib/auth.ts helper, then npm uninstall the discarded package.
// src/lib/auth.ts — single canonical session helper
import { getServerSession } from 'next-auth'
import { authOptions } from './auth-options'
export function getSession() {
return getServerSession(authOptions)
}
Search for any remaining imports of the removed library with grep -r "@clerk/nextjs\|lucia" src/ and eliminate them before deploying.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Multi-Session Drift Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-287 — Improper Authentication
- cwe · CWE-384 — Session Fixation
- owasp:2021 · A07 — Identification and Authentication Failures
Taxons
History
- 2026-04-18·v1.0.0·Initial import from ai-slop-code-drift·automated
- 2026-04-20·v1.1.0·Add Phase 6.0 detect-rg snippet for deterministic auth-library import detection·by cakleinman