[PR #6375] [MERGED] fix(sub): randomize fresh panel subscription paths #6238

Closed
opened 2026-11-02 04:07:19 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6375
Author: @rokokol
Created: 8/31/2026
Status: ✅ Merged
Merged: 9/3/2026
Merged by: @MHSanaei

Base: main ← Head: fix/random-subscription-paths


📝 Commits (2)

  • 0f8348e fix(sub): randomize fresh panel subscription paths
  • 7c733b1 fix(sub): regenerate paths on settings reset

📊 Changes

20 files changed (+285 additions, -158 deletions)

View changed files

📝 docs/components/tools/subscription-builder.tsx (+4 -4)
📝 docs/content/docs/en/config/subscription.mdx (+6 -6)
📝 docs/content/docs/en/reference/api/clients.mdx (+10 -8)
📝 docs/content/docs/en/reference/api/subscription-server.mdx (+25 -22)
📝 docs/content/docs/fa/config/subscription.mdx (+6 -6)
📝 docs/content/docs/fa/reference/api/clients.mdx (+11 -9)
📝 docs/content/docs/fa/reference/api/subscription-server.mdx (+22 -21)
📝 docs/content/docs/ru/config/subscription.mdx (+6 -6)
📝 docs/content/docs/ru/reference/api/clients.mdx (+11 -9)
📝 docs/content/docs/ru/reference/api/subscription-server.mdx (+22 -21)
📝 docs/content/docs/zh/config/subscription.mdx (+6 -6)
📝 docs/content/docs/zh/reference/api/clients.mdx (+5 -5)
📝 docs/content/docs/zh/reference/api/subscription-server.mdx (+14 -14)
📝 docs/public/openapi.json (+5 -5)
📝 frontend/public/openapi.json (+5 -5)
📝 frontend/src/pages/api-docs/endpoints.ts (+5 -5)
📝 internal/database/db.go (+21 -0)
📝 internal/database/db_seed_test.go (+51 -0)
📝 internal/web/service/setting.go (+11 -6)
📝 internal/web/service/setting_security_test.go (+39 -0)

📄 Description

Summary

  • Seed distinct cryptographically random 16-character paths for base64, JSON, and Clash subscriptions when a fresh panel database is created
  • Persist the generated paths so restarts keep every published subscription URL stable
  • Leave existing installations unchanged so an upgrade never invalidates URLs that have already been distributed

Why

3x-ui currently ships the well-known /sub/ and /json/ subscription paths, and the Settings page itself reports both as security warnings. Although each subscription still has its own secret subId, a fixed service path makes the public subscription endpoints immediately recognizable and leaves every new panel with a warning that requires manual remediation.

Changing these paths after clients have been provisioned changes every subscription URL. Operators then have to rotate and redistribute those URLs just to remove an insecure default they did not choose. Generating panel-specific paths at database creation makes fresh installations safe by default and avoids that later operational churn.

The Clash path is randomized as well so all public subscription formats follow the same default. This is limited to fresh databases deliberately: silently changing paths during an upgrade would cause the exact URL rotation this change is intended to prevent.

The randomized prefix is defense-in-depth, not a replacement for the per-subscription subId.

Testing

  • make test-go
  • make lint-go
  • go build ./...
  • Verified all three paths are distinct between panels and remain unchanged after reopening the same database

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6375 **Author:** [@rokokol](https://github.com/rokokol) **Created:** 8/31/2026 **Status:** ✅ Merged **Merged:** 9/3/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/random-subscription-paths` --- ### 📝 Commits (2) - [`0f8348e`](https://github.com/MHSanaei/3x-ui/commit/0f8348e92d725483eb89192bd244385e111616d8) fix(sub): randomize fresh panel subscription paths - [`7c733b1`](https://github.com/MHSanaei/3x-ui/commit/7c733b10d60ef05f40b1e5f1d5c1888323e00260) fix(sub): regenerate paths on settings reset ### 📊 Changes **20 files changed** (+285 additions, -158 deletions) <details> <summary>View changed files</summary> 📝 `docs/components/tools/subscription-builder.tsx` (+4 -4) 📝 `docs/content/docs/en/config/subscription.mdx` (+6 -6) 📝 `docs/content/docs/en/reference/api/clients.mdx` (+10 -8) 📝 `docs/content/docs/en/reference/api/subscription-server.mdx` (+25 -22) 📝 `docs/content/docs/fa/config/subscription.mdx` (+6 -6) 📝 `docs/content/docs/fa/reference/api/clients.mdx` (+11 -9) 📝 `docs/content/docs/fa/reference/api/subscription-server.mdx` (+22 -21) 📝 `docs/content/docs/ru/config/subscription.mdx` (+6 -6) 📝 `docs/content/docs/ru/reference/api/clients.mdx` (+11 -9) 📝 `docs/content/docs/ru/reference/api/subscription-server.mdx` (+22 -21) 📝 `docs/content/docs/zh/config/subscription.mdx` (+6 -6) 📝 `docs/content/docs/zh/reference/api/clients.mdx` (+5 -5) 📝 `docs/content/docs/zh/reference/api/subscription-server.mdx` (+14 -14) 📝 `docs/public/openapi.json` (+5 -5) 📝 `frontend/public/openapi.json` (+5 -5) 📝 `frontend/src/pages/api-docs/endpoints.ts` (+5 -5) 📝 `internal/database/db.go` (+21 -0) 📝 `internal/database/db_seed_test.go` (+51 -0) 📝 `internal/web/service/setting.go` (+11 -6) 📝 `internal/web/service/setting_security_test.go` (+39 -0) </details> ### 📄 Description ## Summary - Seed distinct cryptographically random 16-character paths for base64, JSON, and Clash subscriptions when a fresh panel database is created - Persist the generated paths so restarts keep every published subscription URL stable - Leave existing installations unchanged so an upgrade never invalidates URLs that have already been distributed ## Why 3x-ui currently ships the well-known `/sub/` and `/json/` subscription paths, and the Settings page itself reports both as security warnings. Although each subscription still has its own secret `subId`, a fixed service path makes the public subscription endpoints immediately recognizable and leaves every new panel with a warning that requires manual remediation. Changing these paths after clients have been provisioned changes every subscription URL. Operators then have to rotate and redistribute those URLs just to remove an insecure default they did not choose. Generating panel-specific paths at database creation makes fresh installations safe by default and avoids that later operational churn. The Clash path is randomized as well so all public subscription formats follow the same default. This is limited to fresh databases deliberately: silently changing paths during an upgrade would cause the exact URL rotation this change is intended to prevent. The randomized prefix is defense-in-depth, not a replacement for the per-subscription `subId`. ## Testing - `make test-go` - `make lint-go` - `go build ./...` - Verified all three paths are distinct between panels and remain unchanged after reopening the same database --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:07:19 +07:00
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#6238
No description provided.