mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #4965] [Bug]: Blank sign-in page after update to 3.2.8 due to blocked inline script by CSP #3484
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#3484
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 @ubelian on GitHub (Jun 5, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4965
Describe the bug
After updating 3x-ui to version from 3.2.6 to 3.2.8, the panel sign-in page opens as a blank white page.
The initial HTML loads successfully, the page title changes to "Sign in", and static JS/CSS assets return HTTP 200. However, React does not mount into
#app.Browser console shows that an inline script is blocked by Content-Security-Policy:
Screenshots
No response
3x-ui version
3.2.8
Xray-core version
26.5.9
How did you install 3x-ui?
install.sh script
Operating system
Debian 13
Which parts of the panel are affected?
No response
Browser (only if it is a UI bug)
Firefox 151 on Linux
Is the panel behind a reverse proxy or CDN?
None
Before submitting
@github-actions[bot] commented on GitHub (Jun 5, 2026):
Thanks for the detailed report. Here's what the code does and how to narrow this down.
How the CSP nonce works
The CSP security headers (including the
script-src 'nonce-…'directive) were introduced in v3.0.2 via a security hardening commit. The mechanism works as follows, all within a single HTTP request:web/middleware/security.gogenerates a fresh random nonce withcrypto/rand, stores it in the Gin context (c.Set("csp_nonce", nonce)), and writes it to theContent-Security-Policyresponse header.web/controller/dist.goreads that same nonce from context (c.GetString("csp_nonce")) and injects<script nonce="NONCE">window.X_UI_BASE_PATH="…";</script>into the HTML just before</head>.Because both values come from the same request-scoped context, they must always match — unless something in the environment is modifying the response after it leaves the Go process.
One inconsistency in your report
Looking at the source of
dist.go(line 81):window.X_UI_CUR_VERandwindow.X_UI_DB_TYPEare only injected forindex.html(the panel SPA), not forlogin.html. If the blocked script you observed contained all three variables, the page that was actually blank is the post-login panel (index.html), not the sign-in page — even if the title said "Sign in" (which could be left over from a previous navigation or a React auth redirect that never completed because the script was blocked).Why does a blocked script cause a blank page?
vite.config.tsusesexperimental.renderBuiltUrlto resolve dynamic chunk imports at runtime:If
window.X_UI_BASE_PATHis not set (because the inline script was blocked) and you use a non-defaultwebBasePath, all lazy-loaded vendor chunks (vendor-react,vendor-antd, etc.) resolve to/assets/…instead of/your-base/assets/…, fail to load, and React never mounts — leaving the page blank.Debugging steps
1. Hard-refresh first.
Press Ctrl + Shift + R (Firefox) to bypass the browser cache and force a full reload. If this fixes it, the root cause is a stale cached HTML page that was served without a
nonce=attribute on the inline script.2. Check whether the nonce is actually in the served HTML.
Open the page, right-click → View Page Source (not DevTools Elements, which shows the parsed DOM). Search for
<script nonce=. You should see something like:Then check the
Content-Security-Policyresponse header for the same request (DevTools → Network tab → the HTML document → Response Headers). The value after'nonce-in the CSP must exactly match thenonce=attribute in the script tag.3. If the nonce is missing or mismatched, please share:
Content-Security-Policyheader value from the Network tab.<script …>line from View Page Source.The fallback meta tags (
<meta name="base-path">and<meta name="csrf-token">) are always injected bydist.goeven when the inline script is blocked, so those values survive. The missing piece for a customwebBasePathis specificallywindow.X_UI_BASE_PATH, which the chunk-loading runtime depends on.@ubelian commented on GitHub (Jun 5, 2026):
I checked it directly against the local 3x-ui HTTPS listener, without Nginx, HAProxy, CDN or any reverse proxy:
Result:
HTML contains:
<script nonce="8YQnzxXxbTvtghVeFncCkg">window.X_UI_BASE_PATH="/<webBasePath>/";</script>Response header contains:
Content-Security-Policy: default-src 'self'; script-src 'self' 'nonce-fwYb/pI38OS/VN7jmKL8tg'; ...So the nonce in the inline script and the nonce in the CSP header are different even when requesting https://127.0.0.1:18143/... directly from the 3x-ui process.
There is no reverse proxy/CDN involved in this test.