Crítica

Auth.js: Configuration errors can cause existence-based auth checks to fail open (auth object populated with an error)

  • Publicada: 23.07.2026
  • Actualizado: 11.10.2026 10:22

Impact

next-auth (Auth.js) v5 applications that gate access by checking only for the existence of the auth object — the pattern shown in the official session management / protecting resources guide — are affected.

When the Auth.js configuration produces a server-side error, the auth object exposed by the auth() wrapper (in middleware, Route Handlers, etc.) is populated with an error object instead of being null:

js
{ "message": "There was a problem with the server configuration. Check the server logs for more information." }

Because this object is truthy, any authorization check of the form !!auth (or if (req.auth)) evaluates to true for every request, including unauthenticated ones. The application fails open: instead of denying access when the auth layer is broken, it grants access to everyone.

ts
// middleware.ts — affected pattern
export default auth((req) => {
  const { nextUrl, auth } = req
  const isLoggedIn = !!auth // <-- always true when the configuration is broken
  // ...
})

A representative trigger is a provider that is missing required configuration. For example, a Keycloak provider with neither issuer nor authorization endpoint set logs:

[auth][error] InvalidEndpoints: Provider "keycloak" is missing both `issuer` and `authorization` endpoint config. At least one of them is required.

…and from that point on auth is the error object above, so !!auth is permanently true. The same fail-open behavior occurs for other server-configuration errors (for example, an unset AUTH_SECRET).

There is no impact while the configuration is valid. The risk materializes when a previously-working deployment becomes misconfigured — e.g. an environment variable is changed or removed during a deploy — at which point existence-based auth checks silently stop protecting routes and all visitors are treated as authenticated. Because the failure mode is silent and grants access to everyone, the consequences can be severe.

This is an instance of CWE-636 (Not Failing Securely / "Failing Open") leading to improper authorization (CWE-285).

Patches

The fix ensures that a server-configuration error no longer surfaces as a truthy auth object: existence checks fail closed rather than open. This is released in next-auth@<!-- TODO: set patched version on publish -->.

To upgrade:

bash
npm i next-auth@beta
bash
yarn add next-auth@beta
bash
pnpm add next-auth@beta

Workarounds

If you cannot upgrade immediately, check for a concrete user/session property rather than the bare object, so a configuration-error object is not treated as an authenticated session:

ts
// middleware.ts
export default auth((req) => {
  // `auth.user` is only present on a real session; resilient to config-error objects
  const isLoggedIn = !!req.auth?.user
  // ...
})

As defense in depth, make Auth.js configuration errors fail loudly in your deployment pipeline (for example, treat [auth][error] log lines as a failed health check) so a broken configuration cannot silently reach production. As always, an existing session indicates authentication only — for authorization, perform an explicit role/permission check rather than relying on session existence. See the role-based access control guide.

References

For more information

If you have any concerns, Auth.js requests responsible disclosure, outlined here: https://authjs.dev/security

Credits

Reported by @marc-zollingkoffer-syzygy.

Software afectado

Haz clic en una tecnología para ver todas sus vulnerabilidades.

PlataformaPaqueteVersiones vulnerablesCorregida en
Paquete de npm next-auth >= 5.0.0-beta.0, < 5.0.0-beta.32 5.0.0-beta.32

Referencias

Puntuación CVSS -
Vector CVSS
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N
Debilidad (CWE)
CWE-285, CWE-636
Plataforma
npm
Paquete
next-auth
Publicada
23.07.2026
Actualizado
11.10.2026 10:22

Fuentes y licencias

OSV / GitHub Advisory Database - GHSA-8fpg-xm3f-6cx3 - CC BY 4.0

Historial de vulnerabilidades: next-auth

Todas las vulnerabilidades publicadas de este paquete (Paquete de npm), de la más reciente a la más antigua. Muestra si es un fallo aislado o un paquete que hay que vigilar.

Todas (14) en el archivo
Entradas en total
14
Primera → última
02.2021 07.2026
Sin corrección
0
Explotada en ataques
0

Distribución por gravedad

  • Crítica 3
  • Alta 4
  • Media 5
  • Baja 2

Divulgaciones por año

  1. 2021: 1
  2. 2022: 6
  3. 2023: 2
  4. 2024: 0
  5. 2025: 1
  6. 2026: 4
Gravedad:
  1. Auth.js: Configuration errors can cause existence-based auth checks to fail open (auth object populated with an error) esta entrada
    Crítica CVE-2026-73421 >= 5.0.0-beta.0, < 5.0.0-beta.32 5.0.0-beta.32
  2. Alta · 7.5 CVE-2026-73418 >= 5.0.0-beta.0, < 5.0.0-beta.32, >= 4.0.6, < 4.24.15 5.0.0-beta.32, 4.24.15
  3. Crítica CVE-2026-73420 >= 4.10.3, < 4.24.15, >= 5.0.0-beta.1, < 5.0.0-beta.32 4.24.15, 5.0.0-beta.32
  4. Crítica · 9.1 CVE-2022-35924 >= 4.0.0, < 4.10.3, < 3.29.10 4.10.3, 3.29.10
  5. Alta · 7.1 CVE-2022-31127 < 3.29.8, >= 4.0.0, < 4.9.0 3.29.8, 4.9.0
  6. Alta · 7.5 CVE-2022-31093 < 3.29.5, >= 4.0.0, < 4.5.0 3.29.5, 4.5.0

Identifica las vulnerabilidades de tu aplicación

Con la integración de DockRay y el inventario de software activado, DockRay compara las versiones notificadas de los componentes con las vulnerabilidades conocidas y avisa de las coincidencias confirmadas. La cobertura depende de la tecnología compatible y de los avisos disponibles.

Conectar tu aplicación
Newsletter DockRay

La seguridad de tus aplicaciones en tu correo

Vulnerabilidades importantes, recomendaciones concretas y consejos prácticos para tus aplicaciones. Elige tus tecnologías y sigue lo que importa para tu proyecto.

  • Un resumen diario de nuevas vulnerabilidades, también las críticas.
  • Avisos sobre actualizaciones importantes.
  • Consejos prácticos sobre seguridad y monitorización de aplicaciones.

Déjalo vacío para recibir avisos de todas las tecnologías.

Suscripción gratuita. Date de baja con un clic en cualquier correo.