Skip to content

502 Bad Gateway on login due to unhandled expired refresh token causing HTTP 400 error #8256

@ksarabi-sp

Description

@ksarabi-sp

Steps to Reproduce

When logging into Prowler UI using username/password, if the refresh token expires or becomes invalid, the UI backend throws an unhandled error on HTTP 400 during token refresh. This results in a 502 Bad Gateway error visible in the browser.
Steps to reproduce:

Login normally to Prowler UI.

Wait for the refresh token to expire (or manually expire it).

Try to perform an action or reload the UI.

The browser shows a 502 Bad Gateway error.

Observed behavior:

Backend logs show repeated errors like:

lua
Copy
Edit
Error refreshing access token: HTTP error! status: 400
Nginx returns 502 to the browser on /sign-in POST or token refresh requests.

The user must clear cookies or open an incognito window to workaround.

Expected behavior

The ui should gracefully handle expired/invalid refresh tokens without throwing.

The session should be invalidated and user redirected to login screen automatically.

No 502 errors should appear.

Actual Result with Screenshots or Logs

Error refreshing access token: Error: HTTP error! status: 400
at d (/app/.next/server/chunks/6769.js:1:11922)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async i_ (/app/.next/server/chunks/1194.js:369:45691)
at async iT (/app/.next/server/chunks/1194.js:369:51994)
at async iC (/app/.next/server/chunks/1194.js:369:56536)
at async /app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:38411
at async e_.execute (/app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:27880)
at async e_.handle (/app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:39943)
at async doRender (/app/node_modules/next/dist/server/base-server.js:1366:42)
at async cacheEntry.responseCache.get.routeKind (/app/node_modules/next/dist/server/base-server.js:1588:28)

How did you install Prowler?

Docker (docker pull toniblyx/prowler)

Environment Resource

  1. EKS

OS used

  1. Amzon Linux 2

Prowler version

latest

Pip version

25.1.1

Context

In the NextAuth session callback, check for this error and expire the session to force logout:

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions