[PR #7050] [CLOSED] fix(xray): refuse fallbacks on VLESS decryption and drop empty fallbacks (#7001) #6620

Closed
opened 2026-11-07 14:34:12 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/7050
Author: @DoctorGuidance
Created: 11/2/2026
Status: ❌ Closed

Base: main ← Head: fix/vless-decryption-fallbacks


📝 Commits (1)

  • b7fe8f7 fix(xray): refuse fallbacks on VLESS decryption and drop empty fallbacks (#7001)

📊 Changes

9 files changed (+199 additions, -2 deletions)

View changed files

📝 frontend/src/lib/xray/inbound-form-adapter.ts (+8 -0)
📝 frontend/src/pages/api-docs/endpoints.ts (+1 -1)
📝 frontend/src/pages/inbounds/form/InboundFormModal.tsx (+10 -0)
📝 frontend/src/test/inbound-form-adapter.test.ts (+29 -0)
📝 internal/web/service/fallback.go (+12 -0)
📝 internal/web/service/inbound.go (+22 -0)
📝 internal/web/service/inbound_protocol.go (+64 -1)
📝 internal/web/service/inbound_protocol_test.go (+38 -0)
📝 internal/web/service/xray.go (+15 -0)

📄 Description

Summary of Changes

Closes #7001

Root Cause Analysis

In Xray-core (infra/conf/vless.go):

if s.Decryption != "" && s.Fallbacks != nil {
    return nil, newError("VLESS settings: \"fallbacks\" can not be used together with \"decryption\"")
}

When an inbound is created or updated via API (POST /panel/api/inbounds/add or /update), raw JSON imports, or restored backups with VLESS decryption enabled and "fallbacks": [], Go unmarshals "fallbacks": [] into a non-nil slice (len == 0). Because Xray-core checks Fallbacks != nil, an empty array counts as fallbacks being present.
Consequently, Xray-core fails to start with exit status 23 (VLESS settings: "fallbacks" can not be used together with "decryption"), causing an infinite restart loop that knocks down every inbound on the server.

Furthermore:

  1. inboundCanHostFallbacks in internal/web/service/inbound_protocol.go did not check decryption, so fallbacks managed by the panel on a vlessenc TCP+TLS/REALITY inbound would result in the exact same crash.
  2. The UI modal (InboundFormModal.tsx) did not exclude VLESS inbounds with decryption from isFallbackHost.
  3. The API documentation sample payload in endpoints.ts carried "fallbacks": [] by default.

Changes Implemented

  1. Backend Validation & Normalization (internal/web/service/inbound_protocol.go):
    • Added normalizeVlessSettings: drops cosmetic empty fallbacks: [] / null (matching the UI's dropLegacyOptionalEmpties) and returns an explicit validation error (VLESS settings: "fallbacks" can not be used together with "decryption") if non-empty fallbacks are supplied alongside a real decryption value.
    • Updated inboundCanHostFallbacks: gates fallback injection so VLESS inbounds with decryption never host fallbacks.
    • Added vlessDecryptionEnabled helper to verify whether a server-side decryption key is active.
  2. Inbound Handlers (internal/web/service/inbound.go):
    • Integrated normalizeVlessSettings into AddInbound and UpdateInbound.
    • In buildInboundForNodePush, defensively pruned empty fallbacks and invalid decryption fallbacks.
  3. Core Config Generation Defense-in-Depth (internal/web/service/xray.go):
    • When generating config.json for Xray, empty fallbacks: [] are stripped.
    • Any fallbacks lingering on a VLESS inbound with decryption (e.g. from direct DB edits or legacy backups) are dropped with a warning log before Xray can crash.
  4. Fallback Service (internal/web/service/fallback.go):
    • In SetByMaster, validated that the master inbound can host fallbacks before attaching fallback rows.
  5. Frontend Form & Adapters (frontend/):
    • In dropLegacyOptionalEmpties, stripped fallbacks if decryption is set.
    • In InboundFormModal.tsx, excluded VLESS with decryption from isFallbackHost.
    • In endpoints.ts, removed "fallbacks": [] from the minimal VLESS API documentation payload.
  6. Tests:
    • Added unit tests in internal/web/service/inbound_protocol_test.go verifying fallback capability gating and normalizeVlessSettings.
    • Added unit tests in frontend/src/test/inbound-form-adapter.test.ts for dropLegacyOptionalEmpties.

🔄 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/7050 **Author:** [@DoctorGuidance](https://github.com/DoctorGuidance) **Created:** 11/2/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/vless-decryption-fallbacks` --- ### 📝 Commits (1) - [`b7fe8f7`](https://github.com/MHSanaei/3x-ui/commit/b7fe8f7bb540ff7951b8c3519b548a6cb63fc8c8) fix(xray): refuse fallbacks on VLESS decryption and drop empty fallbacks (#7001) ### 📊 Changes **9 files changed** (+199 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/lib/xray/inbound-form-adapter.ts` (+8 -0) 📝 `frontend/src/pages/api-docs/endpoints.ts` (+1 -1) 📝 `frontend/src/pages/inbounds/form/InboundFormModal.tsx` (+10 -0) 📝 `frontend/src/test/inbound-form-adapter.test.ts` (+29 -0) 📝 `internal/web/service/fallback.go` (+12 -0) 📝 `internal/web/service/inbound.go` (+22 -0) 📝 `internal/web/service/inbound_protocol.go` (+64 -1) 📝 `internal/web/service/inbound_protocol_test.go` (+38 -0) 📝 `internal/web/service/xray.go` (+15 -0) </details> ### 📄 Description ### Summary of Changes Closes #7001 #### Root Cause Analysis In Xray-core (`infra/conf/vless.go`): ```go if s.Decryption != "" && s.Fallbacks != nil { return nil, newError("VLESS settings: \"fallbacks\" can not be used together with \"decryption\"") } ``` When an inbound is created or updated via API (`POST /panel/api/inbounds/add` or `/update`), raw JSON imports, or restored backups with VLESS decryption enabled and `"fallbacks": []`, Go unmarshals `"fallbacks": []` into a non-nil slice (`len == 0`). Because Xray-core checks `Fallbacks != nil`, an empty array counts as fallbacks being present. Consequently, Xray-core fails to start with exit status 23 (`VLESS settings: "fallbacks" can not be used together with "decryption"`), causing an infinite restart loop that knocks down every inbound on the server. Furthermore: 1. `inboundCanHostFallbacks` in `internal/web/service/inbound_protocol.go` did not check `decryption`, so fallbacks managed by the panel on a vlessenc TCP+TLS/REALITY inbound would result in the exact same crash. 2. The UI modal (`InboundFormModal.tsx`) did not exclude VLESS inbounds with decryption from `isFallbackHost`. 3. The API documentation sample payload in `endpoints.ts` carried `"fallbacks": []` by default. #### Changes Implemented 1. **Backend Validation & Normalization (`internal/web/service/inbound_protocol.go`)**: - Added `normalizeVlessSettings`: drops cosmetic empty `fallbacks: []` / `null` (matching the UI's `dropLegacyOptionalEmpties`) and returns an explicit validation error (`VLESS settings: "fallbacks" can not be used together with "decryption"`) if non-empty fallbacks are supplied alongside a real `decryption` value. - Updated `inboundCanHostFallbacks`: gates fallback injection so VLESS inbounds with `decryption` never host fallbacks. - Added `vlessDecryptionEnabled` helper to verify whether a server-side decryption key is active. 2. **Inbound Handlers (`internal/web/service/inbound.go`)**: - Integrated `normalizeVlessSettings` into `AddInbound` and `UpdateInbound`. - In `buildInboundForNodePush`, defensively pruned empty fallbacks and invalid decryption fallbacks. 3. **Core Config Generation Defense-in-Depth (`internal/web/service/xray.go`)**: - When generating `config.json` for Xray, empty `fallbacks: []` are stripped. - Any fallbacks lingering on a VLESS inbound with decryption (e.g. from direct DB edits or legacy backups) are dropped with a warning log before Xray can crash. 4. **Fallback Service (`internal/web/service/fallback.go`)**: - In `SetByMaster`, validated that the master inbound can host fallbacks before attaching fallback rows. 5. **Frontend Form & Adapters (`frontend/`)**: - In `dropLegacyOptionalEmpties`, stripped `fallbacks` if `decryption` is set. - In `InboundFormModal.tsx`, excluded VLESS with decryption from `isFallbackHost`. - In `endpoints.ts`, removed `"fallbacks": []` from the minimal VLESS API documentation payload. 6. **Tests**: - Added unit tests in `internal/web/service/inbound_protocol_test.go` verifying fallback capability gating and `normalizeVlessSettings`. - Added unit tests in `frontend/src/test/inbound-form-adapter.test.ts` for `dropLegacyOptionalEmpties`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 14:34:12 +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#6620
No description provided.