[GH-ISSUE #5959] [Bug]: Web panel update resets custom short URL path back to default random string #4131

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

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

Describe the bug

When the panel is first installed, it generates a long, random URL path for security reasons. If a user manually changes this path to a custom, shorter, or more convenient one, updating the panel via the Web UI completely resets this setting back to a default/generated random string.

While I understand this might be intended as a security enforcement mechanism, it is inconvenient for users who consciously choose their own URL path and are aware of the risks. The custom path should not be overwritten during updates

How to reproduce the problem

  1. Change the automatically generated long URL path to a custom, convenient one in the panel settings
  2. Update the panel to a newer version using the update button in the Web UI
  3. After the update, the custom URL path is lost and replaced by a default/randomized path again

Expected behavior

The panel should preserve the user-defined custom URL path during updates, even if it doesn't match the original randomly generated security string

Actual behavior

The custom URL path is forcibly reset, disrupting access and requiring manual reconfiguration

Relevant logs


Screenshots

No response

3x-ui version

3.5.0

Xray-core version

No response

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 24.04

Which parts of the panel are affected?

Frontend (UI / panel pages)

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

Yes — other

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 @Ashteeer on GitHub (Jul 14, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5959 ### Describe the bug When the panel is first installed, it generates a long, random URL path for security reasons. If a user manually changes this path to a custom, shorter, or more convenient one, updating the panel via the Web UI completely resets this setting back to a default/generated random string. While I understand this might be intended as a security enforcement mechanism, it is inconvenient for users who consciously choose their own URL path and are aware of the risks. The custom path should not be overwritten during updates ### How to reproduce the problem 1. Change the automatically generated long URL path to a custom, convenient one in the panel settings 2. Update the panel to a newer version using the update button in the Web UI 3. After the update, the custom URL path is lost and replaced by a default/randomized path again ### Expected behavior The panel should preserve the user-defined custom URL path during updates, even if it doesn't match the original randomly generated security string ### Actual behavior The custom URL path is forcibly reset, disrupting access and requiring manual reconfiguration ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.5.0 ### Xray-core version _No response_ ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 24.04 ### Which parts of the panel are affected? Frontend (UI / panel pages) ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? Yes — other ### 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:23 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

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

Title: update.sh's config_after_update() regenerates any custom webBasePath of 3 characters or fewer on every update

Severity: High

Category: Correctness

Why this matters:
Confirmed in source, including the exact release you're running. The Web UI's Update button calls POST /server/updatePanel (internal/web/controller/server.go:71), which runs PanelService.StartUpdate() (internal/web/service/panel/panel.go:183). That function always downloads the latest update.sh straight from the main branch (panelUpdaterURL, panel.go:43) and executes it — regardless of which version is installed. update_x-ui() then unconditionally calls config_after_update() (update.sh:1202), which reads the stored webBasePath, strips its leading /, and regenerates it whenever the remainder is under 4 characters:

# update.sh, config_after_update()
local existing_webBasePath=$(${xui_folder}/x-ui setting -show true | grep -Eo 'webBasePath: .+' | awk '{print $2}' | sed 's#^/##')
...
if [[ ${#existing_webBasePath} -lt 4 ]]; then          # line 862
    local config_webBasePath=$(gen_random_string 18)
    ${xui_folder}/x-ui setting -webBasePath "${config_webBasePath}"
    ...
fi

The check is meant to catch the true factory default (a bare /, which strips to an empty string) but a raw length threshold also matches any deliberately short custom path, e.g. /a/, /ab/, /abc/. The panel's own validation allows these: webBasePath (frontend/src/schemas/setting.ts:5) only requires a leading slash, with no minimum length. I confirmed line 862 is identical, unchanged, in both current main and the v3.5.0 tag you reported — and since every update re-downloads update.sh from main, this runs on every update of every installed version.

This exact condition was previously diagnosed in #5179. The fix merged for that report only added a systemctl restart after regeneration so the new path takes effect immediately (fixing a login "desync" symptom); it did not correct the faulty -lt 4 condition itself, which is why this is resurfacing.

Recovering the new path is also harder than it looks. When systemd-run is available, the update runs under a throwaway transient unit (x-ui-web-update-<timestamp>, panel.go:253), but the panel's "View Logs" feature (GetLogs, internal/web/service/server.go:1120) only reads journalctl -u x-ui, so the newly generated path is never shown there. In the non-systemd-run fallback, the update process's stdout/stderr aren't captured at all. So an admin with a short custom path can be locked out of the web UI immediately after clicking Update, recoverable only via direct server/SSH access.

Recommendation:
Replace the length heuristic with a check for the actual "unset" sentinel rather than a character count, e.g. (the leading slash is already stripped at this point, so an unset path is an empty string):

# before
if [[ ${#existing_webBasePath} -lt 4 ]]; then
# after
if [[ -z "$existing_webBasePath" ]]; then

install.sh's config_after_install() (line 1065) has the identical pattern and would need the same correction, since re-running install.sh over an existing database hits the same logic.

If you'd rather work around this in the meantime: after any update, check x-ui setting -show true (or the Settings page) for the current webBasePath, and restore it with x-ui setting -webBasePath "<yourpath>" followed by systemctl restart x-ui if it was reset.

Confidence: high — both the call path from the Web UI's Update button and the exact faulty condition are confirmed directly in the current source and in the v3.5.0 release tag.

@MHSanaei for a decision on the fix approach.

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

<!-- gh-comment-id:4974261238 --> @github-actions[bot] commented on GitHub (Jul 14, 2026): Title: `update.sh`'s `config_after_update()` regenerates any custom `webBasePath` of 3 characters or fewer on every update Severity: High Category: Correctness Why this matters: Confirmed in source, including the exact release you're running. The Web UI's Update button calls `POST /server/updatePanel` (`internal/web/controller/server.go:71`), which runs `PanelService.StartUpdate()` (`internal/web/service/panel/panel.go:183`). That function always downloads the *latest* `update.sh` straight from the `main` branch (`panelUpdaterURL`, `panel.go:43`) and executes it — regardless of which version is installed. `update_x-ui()` then unconditionally calls `config_after_update()` (`update.sh:1202`), which reads the stored `webBasePath`, strips its leading `/`, and regenerates it whenever the remainder is under 4 characters: ```bash # update.sh, config_after_update() local existing_webBasePath=$(${xui_folder}/x-ui setting -show true | grep -Eo 'webBasePath: .+' | awk '{print $2}' | sed 's#^/##') ... if [[ ${#existing_webBasePath} -lt 4 ]]; then # line 862 local config_webBasePath=$(gen_random_string 18) ${xui_folder}/x-ui setting -webBasePath "${config_webBasePath}" ... fi ``` The check is meant to catch the true factory default (a bare `/`, which strips to an empty string) but a raw length threshold also matches any deliberately short custom path, e.g. `/a/`, `/ab/`, `/abc/`. The panel's own validation allows these: `webBasePath` (`frontend/src/schemas/setting.ts:5`) only requires a leading slash, with no minimum length. I confirmed line 862 is identical, unchanged, in both current `main` and the `v3.5.0` tag you reported — and since every update re-downloads `update.sh` from `main`, this runs on every update of every installed version. This exact condition was previously diagnosed in #5179. The fix merged for that report only added a `systemctl restart` after regeneration so the new path takes effect immediately (fixing a login "desync" symptom); it did not correct the faulty `-lt 4` condition itself, which is why this is resurfacing. Recovering the new path is also harder than it looks. When `systemd-run` is available, the update runs under a throwaway transient unit (`x-ui-web-update-<timestamp>`, `panel.go:253`), but the panel's "View Logs" feature (`GetLogs`, `internal/web/service/server.go:1120`) only reads `journalctl -u x-ui`, so the newly generated path is never shown there. In the non-`systemd-run` fallback, the update process's stdout/stderr aren't captured at all. So an admin with a short custom path can be locked out of the web UI immediately after clicking Update, recoverable only via direct server/SSH access. Recommendation: Replace the length heuristic with a check for the actual "unset" sentinel rather than a character count, e.g. (the leading slash is already stripped at this point, so an unset path is an empty string): ```bash # before if [[ ${#existing_webBasePath} -lt 4 ]]; then # after if [[ -z "$existing_webBasePath" ]]; then ``` `install.sh`'s `config_after_install()` (line 1065) has the identical pattern and would need the same correction, since re-running `install.sh` over an existing database hits the same logic. If you'd rather work around this in the meantime: after any update, check `x-ui setting -show true` (or the Settings page) for the current `webBasePath`, and restore it with `x-ui setting -webBasePath "<yourpath>"` followed by `systemctl restart x-ui` if it was reset. Confidence: high — both the call path from the Web UI's Update button and the exact faulty condition are confirmed directly in the current source and in the `v3.5.0` release tag. @MHSanaei for a decision on the fix approach. *This reply was generated automatically; a maintainer may follow up.*
Author
Owner

@MHSanaei commented on GitHub (Jul 14, 2026):

It should be more than 3 characters

<!-- gh-comment-id:4974401912 --> @MHSanaei commented on GitHub (Jul 14, 2026): It should be more than 3 characters
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#4131
No description provided.