[GH-ISSUE #5931] [Bug]: Web UI login fails with 403 #4113

Closed
opened 2026-10-31 20:37:16 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @zwzzrl on GitHub (Jul 13, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5931

Describe the bug

Can't log in

How to reproduce the problem

1.try to login

Expected behavior

Logged in successfully

Actual behavior

fails with 403

Relevant logs


Screenshots

Image Image

3x-ui version

3.5.0

Xray-core version

No response

How did you install 3x-ui?

install.sh script

Operating system

debian 12

Which parts of the panel are affected?

Backend (API endpoints, login, settings)

Browser (only if it is a UI bug)

Chromium145

Is the panel behind a reverse proxy or CDN?

Yes — Cloudflare Tunnel

Before submitting

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
Originally created by @zwzzrl on GitHub (Jul 13, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5931 ### Describe the bug Can't log in ### How to reproduce the problem 1.try to login ### Expected behavior Logged in successfully ### Actual behavior fails with 403 ### Relevant logs ```shell ``` ### Screenshots <img width="1173" height="567" alt="Image" src="https://github.com/user-attachments/assets/b6dcd264-3a1a-4788-9450-b828673368e0" /> <img width="443" height="671" alt="Image" src="https://github.com/user-attachments/assets/85c45fbe-2202-49b9-b2b9-0367f130c881" /> ### 3x-ui version 3.5.0 ### Xray-core version _No response_ ### How did you install 3x-ui? install.sh script ### Operating system debian 12 ### Which parts of the panel are affected? Backend (API endpoints, login, settings) ### Browser (only if it is a UI bug) Chromium145 ### Is the panel behind a reverse proxy or CDN? Yes — Cloudflare Tunnel ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:37:16 +07:00
Author
Owner

@zwzzrl commented on GitHub (Jul 13, 2026):

After rolling back to version 2.9.4, I was able to log in successfully.

<!-- gh-comment-id:4955924961 --> @zwzzrl commented on GitHub (Jul 13, 2026): After rolling back to version 2.9.4, I was able to log in successfully.
Author
Owner

@github-actions[bot] commented on GitHub (Jul 13, 2026):

I traced the request path a POST /login goes through in v3.5.0. A wrong username/password never produces a 403 — both the credential check and the brute-force login limiter respond with HTTP 200 and a JSON error body (internal/web/controller/index.go:91 and :111). So the 403 is coming from middleware rejecting the request outright (or from Cloudflare itself), before credentials are ever checked. That also explains the empty logs: any request that reaches the login handler always logs a line, success or failure (index.go's logger.Warningf/logger.Infof calls); a request stopped earlier logs nothing.

Two things in the code can return exactly 403 Forbidden for panel requests:

  1. CSRF check — internal/web/middleware/security.go:41-56, applied to POST /login. It 403s when the request's X-CSRF-Token header doesn't match the token stored in that browser's session (internal/web/session/csrf.go:32-47). The frontend already fetches this token up front and even auto-retries once with a freshly-fetched token if the first attempt 403s (frontend/src/api/http-init.ts:153-157). If you're still seeing the error after that, either the retry also failed, or the session cookie set on GET /csrf-token isn't making it back on POST /login at all.
  2. "Listen Domain" mismatch — internal/web/middleware/domainValidator.go:17-31. If Settings → Panel Settings → "Listen Domain" (webDomain) is set, this middleware runs on every route in the panel (internal/web/web.go:182-184) and rejects any request whose Host header isn't an exact, case-sensitive match — nothing trims a stray scheme, trailing slash, or whitespace (internal/web/service/setting.go:413-415 returns the raw stored value; the Settings field is a plain text input with no validation, frontend/src/pages/settings/GeneralTab.tsx:167-169). A mismatch here 403s the whole panel, not just login. This exact gap was also flagged to @MHSanaei while triaging #5868 (a different symptom — blank page — on the same code path).

I can't tell which of these applies — or whether Cloudflare's own edge (WAF / Bot Fight Mode) is returning the 403 before the request reaches the tunnel — without more detail:

  1. Is Listen Domain set under Settings → Panel Settings? If so, does it exactly match, character for character, the hostname in the browser's address bar (no https:// prefix, no trailing /, same case)?
  2. From browser DevTools → Network tab, reproduced live: which request returns 403 — the initial page load, GET /csrf-token, or POST /login? Does that response include a cf-ray header (confirms it reached the tunnel), and does the body look like a plain empty 403 or a Cloudflare-branded block/challenge page?
  3. Any Cloudflare Cache Rules / Page Rules (e.g. "Cache Everything") applied to this hostname?
  4. The panel log around the failed attempt (journalctl -u x-ui -n 200, or the path set in XUI_LOG_FOLDER) — confirms whether the request reached the Go process at all.

@MHSanaei for visibility, since the Listen Domain exact-match behavior in (2) looks like a real hardening gap independent of what turns out to be the cause here.

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:4955934464 --> @github-actions[bot] commented on GitHub (Jul 13, 2026): I traced the request path a `POST /login` goes through in v3.5.0. A wrong username/password never produces a 403 — both the credential check and the brute-force login limiter respond with HTTP 200 and a JSON error body (`internal/web/controller/index.go:91` and `:111`). So the 403 is coming from middleware rejecting the request outright (or from Cloudflare itself), before credentials are ever checked. That also explains the empty logs: any request that reaches the login handler always logs a line, success or failure (`index.go`'s `logger.Warningf`/`logger.Infof` calls); a request stopped earlier logs nothing. Two things in the code can return exactly `403 Forbidden` for panel requests: 1. **CSRF check** — `internal/web/middleware/security.go:41-56`, applied to `POST /login`. It 403s when the request's `X-CSRF-Token` header doesn't match the token stored in that browser's session (`internal/web/session/csrf.go:32-47`). The frontend already fetches this token up front and even auto-retries once with a freshly-fetched token if the first attempt 403s (`frontend/src/api/http-init.ts:153-157`). If you're still seeing the error after that, either the retry also failed, or the session cookie set on `GET /csrf-token` isn't making it back on `POST /login` at all. 2. **"Listen Domain" mismatch** — `internal/web/middleware/domainValidator.go:17-31`. If Settings → Panel Settings → "Listen Domain" (`webDomain`) is set, this middleware runs on *every* route in the panel (`internal/web/web.go:182-184`) and rejects any request whose `Host` header isn't an exact, case-sensitive match — nothing trims a stray scheme, trailing slash, or whitespace (`internal/web/service/setting.go:413-415` returns the raw stored value; the Settings field is a plain text input with no validation, `frontend/src/pages/settings/GeneralTab.tsx:167-169`). A mismatch here 403s the whole panel, not just login. This exact gap was also flagged to @MHSanaei while triaging #5868 (a different symptom — blank page — on the same code path). I can't tell which of these applies — or whether Cloudflare's own edge (WAF / Bot Fight Mode) is returning the 403 before the request reaches the tunnel — without more detail: 1. Is **Listen Domain** set under Settings → Panel Settings? If so, does it exactly match, character for character, the hostname in the browser's address bar (no `https://` prefix, no trailing `/`, same case)? 2. From browser DevTools → Network tab, reproduced live: which request returns 403 — the initial page load, `GET /csrf-token`, or `POST /login`? Does that response include a `cf-ray` header (confirms it reached the tunnel), and does the body look like a plain empty 403 or a Cloudflare-branded block/challenge page? 3. Any Cloudflare Cache Rules / Page Rules (e.g. "Cache Everything") applied to this hostname? 4. The panel log around the failed attempt (`journalctl -u x-ui -n 200`, or the path set in `XUI_LOG_FOLDER`) — confirms whether the request reached the Go process at all. @MHSanaei for visibility, since the Listen Domain exact-match behavior in (2) looks like a real hardening gap independent of what turns out to be the cause here. *This reply was generated automatically; a maintainer may follow up.*
Author
Owner

@zwzzrl commented on GitHub (Jul 13, 2026):

Jul 13 04:33:47 hostname x-ui[3306]: 2026/07/13 04:33:47 ERROR [sessions] ERROR! err="securecookie: error - caused by: securecookie: error - caused by: gob: name not registered for interface: "github.com/mhsanaei/3x-ui/v2/database/model.User""
Jul 13 04:33:48 hostname x-ui[3306]: 2026/07/13 04:33:48 ERROR [sessions] ERROR! err="securecookie: error - caused by: securecookie: error - caused by: gob: name not registered for interface: "github.com/mhsanaei/3x-ui/v2/database/model.User""

<!-- gh-comment-id:4956022810 --> @zwzzrl commented on GitHub (Jul 13, 2026): Jul 13 04:33:47 **hostname** x-ui[3306]: 2026/07/13 04:33:47 ERROR [sessions] ERROR! err="securecookie: error - caused by: securecookie: error - caused by: gob: name not registered for interface: \"github.com/mhsanaei/3x-ui/v2/database/model.User\"" Jul 13 04:33:48 **hostname** x-ui[3306]: 2026/07/13 04:33:48 ERROR [sessions] ERROR! err="securecookie: error - caused by: securecookie: error - caused by: gob: name not registered for interface: \"github.com/mhsanaei/3x-ui/v2/database/model.User\""
Author
Owner

@zwzzrl commented on GitHub (Jul 13, 2026):

I tried using incognito mode and restarting the server, but I still couldn't log in.

<!-- gh-comment-id:4956048921 --> @zwzzrl commented on GitHub (Jul 13, 2026): I tried using incognito mode and restarting the server, but I still couldn't log in.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#4113
No description provided.