mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[GH-ISSUE #5931] [Bug]: Web UI login fails with 403 #4113
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#4113
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
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
@zwzzrl commented on GitHub (Jul 13, 2026):
After rolling back to version 2.9.4, I was able to log in successfully.
@github-actions[bot] commented on GitHub (Jul 13, 2026):
I traced the request path a
POST /logingoes 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:91and: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'slogger.Warningf/logger.Infofcalls); a request stopped earlier logs nothing.Two things in the code can return exactly
403 Forbiddenfor panel requests:internal/web/middleware/security.go:41-56, applied toPOST /login. It 403s when the request'sX-CSRF-Tokenheader 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 onGET /csrf-tokenisn't making it back onPOST /loginat all.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 whoseHostheader isn't an exact, case-sensitive match — nothing trims a stray scheme, trailing slash, or whitespace (internal/web/service/setting.go:413-415returns 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:
https://prefix, no trailing/, same case)?GET /csrf-token, orPOST /login? Does that response include acf-rayheader (confirms it reached the tunnel), and does the body look like a plain empty 403 or a Cloudflare-branded block/challenge page?journalctl -u x-ui -n 200, or the path set inXUI_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.
@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""
@zwzzrl commented on GitHub (Jul 13, 2026):
I tried using incognito mode and restarting the server, but I still couldn't log in.