[PR #7003] [MERGED] fix(inbounds): reject incompatible VLESS fallbacks and prevent Xray crashes #6571

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/7003
Author: @HamedSanaei
Created: 10/28/2026
Status: ✅ Merged
Merged: 11/3/2026
Merged by: @MHSanaei

Base: main ← Head: fix/vlessenc-fallbacks-xray-crash-7001


📝 Commits (2)

  • eaa4359 fix(inbounds): prevent VLESS fallback conflicts from crashing Xray
  • 75954bc Merge remote-tracking branch 'origin/main' into pr/7003

📊 Changes

31 files changed (+853 additions, -79 deletions)

View changed files

📝 .github/workflows/ci.yml (+3 -3)
📝 docs/content/docs/en/reference/api/inbounds.mdx (+30 -16)
📝 docs/public/openapi.json (+6 -8)
📝 frontend/public/openapi.json (+6 -8)
📝 frontend/src/pages/api-docs/endpoints.ts (+5 -5)
📝 frontend/src/pages/inbounds/form/FallbacksCard.tsx (+6 -1)
📝 frontend/src/pages/inbounds/form/InboundFormModal.tsx (+56 -9)
📝 frontend/src/pages/inbounds/form/useInboundFallbacks.ts (+10 -0)
📝 frontend/src/test/inbound-form-modal.test.tsx (+132 -10)
📝 frontend/src/test/setup.components.ts (+4 -1)
➕ internal/web/controller/inbound_vless_fallback_test.go (+119 -0)
📝 internal/web/service/fallback.go (+10 -2)
📝 internal/web/service/inbound.go (+17 -2)
📝 internal/web/service/inbound_protocol.go (+3 -0)
➕ internal/web/service/inbound_vless_fallback.go (+78 -0)
➕ internal/web/service/inbound_vless_fallback_test.go (+317 -0)
📝 internal/web/service/xray.go (+9 -0)
📝 internal/web/translation/ar-EG.json (+3 -1)
📝 internal/web/translation/en-US.json (+3 -1)
📝 internal/web/translation/es-ES.json (+3 -1)

...and 11 more files

📄 Description

Problem

API and JSON import accept VLESS fallbacks with active server decryption. Xray rejects even fallbacks: [], so restarting with the saved configuration can take every inbound down. Panel-managed fallback injection can recreate the conflict.

Root cause

Xray checks server-side decryption and whether the fallback slice is nil. UI-only removal of empty arrays did not protect API/import requests, and managed fallback eligibility ignored decryption. The existing encryption field is for link generation and is deliberately not used for this restriction.

Solution

  • Share VLESS fallback normalization/validation between Add and Update. Remove cosmetic empty arrays, accept null/absent keys, reject malformed entries and nonempty conflicts, and preserve unrelated settings through raw JSON values.
  • Check managed fallback eligibility before replacement and serialize it with inbound writes. Reject enabling decryption while effective managed rules exist, retain existing rules on rejection, and allow explicit removal from an incompatible master.
  • Normalize legacy empty arrays in full config generation and local/node payloads. Refuse legacy nonempty conflicts before stopping a healthy core; report the refused candidate through the existing held-back-config status field. This uses the existing recovery path rather than adding general process-manager preflight validation.
  • Match the form to server decryption, keep existing/draft rules available for removal, block incompatible additions/saves, and keep the draft open on fallback load/save failure. An explicit removal is saved before the incompatible inbound edit; the two HTTP operations remain separate. Retain a newly-created inbound ID when a fallback save needs a retry.
  • Update all 14 locales, the shared API example and descriptions, generated panel/docs OpenAPI, and the generated API reference. Add SQLite, PostgreSQL, authenticated HTTP/import/node-sync, frontend, concurrency and actual-core regression coverage. CI requires the PostgreSQL regression to execute successfully.

Testing

Validation ran in an isolated Linux checkout of the proposed files with Go 1.27.3, Node 26.12.1, npm 11.20.0 and Chromium. No production installation or live client traffic was used.

Command Result
make verify PASS: generation freshness, Go/frontend lint, formatter, typecheck, all Go packages, 2,023 frontend/Chromium Storybook tests in 215 files, panel/Go builds, Storybook build and docs OpenAPI equality
go test ./internal/web/service/... ./internal/web/controller/... ./internal/xray/... -count=1 PASS
make race PASS across all Go packages, shuffled and uncached
XRAY_E2E_BINARY=/artifacts/xray-7001-current go test -race ./internal/web/service ./internal/web/controller -run '^TestVless' -count=1 PASS with the exact pinned core, including the healthy-process/gRPC check
PostgreSQL 16: go test -race ./internal/web/service -run 'PostgresCommitFailure|^TestSyncInboundClientsOnPostgres$|^TestSetClientLimitHwidIsSerializedWithSyncInbound$|^TestVlessManagedFallbackConflictPostgres$' -count=1 -v PASS: all 5 required tests actually ran; CI requires 5 passes
make node-e2e PASS: real master/node sync under admin and node-sync tokens, plus the three-panel traffic heartbeat chain (352.9 s)
go test ./internal/util/link -run '^$' -fuzz '^FuzzParseLink$' -fuzztime=30s -parallel=2 PASS: 299,242 executions
go test ./internal/web/runtime -run '^$' -fuzz '^FuzzDecodeCertPin$' -fuzztime=30s -parallel=2 PASS: 202,253 executions
make vulncheck PASS: 0 reachable vulnerabilities; 3 advisories in required modules are not called by this code
cd frontend && npm run gen; copy OpenAPI to docs; cd docs && npm run gen:api PASS; generated outputs committed
actionlint -shellcheck= .github/workflows/ci.yml; git diff --cached --check PASS

An overlapping race/frontend run hit four existing 5-second component-test timeouts. The unchanged tests passed when the full make verify was rerun by itself; timeouts were not raised. Default actionlint separately reports existing SC2046 warnings in unchanged workflow scripts (lines 40 and 241); structural workflow validation above passes.

Ordinary Go runs skip environment-gated integrations; the live PostgreSQL, actual-core and master/node checks listed above were run separately. The tested Linux files were compared against the staged Git content with git diff --exit-code and matched exactly.

The initial regression run failed for Add/Update, managed rules and every legacy runtime path with the reported fallback conflict. The frontend reproduction failed because adding fallbacks remained enabled. Both became green after the changes. The healthy-core test also first failed because the refusal reason was absent, then passed after exposing it.

Actual Xray validation: the tests call the embedded Xray-core VLESS/Trojan config builders, not just JSON-key assertions. A real core built from the exact go.mod dependency (v1.260327.1-0.20261021115930-1b1647cd9ddf) remains running and answers its gRPC API after both forced and ordinary restart attempts reject a conflicting candidate.

Xray status follow-up

The broader crash-loop status issue is deferred, not claimed fixed. A separate automated reproduction seeded a cached running status with no current Xray process: CurrentStatus() still returned running with an empty error while IsXrayRunning() was false. CurrentStatus() reuses the periodic snapshot, and process replacement also clears the cached result. That demonstrates a stale-status mechanism; it does not establish the complete cause of the reporter's sustained polling results. A separate lifecycle/status change should test exited children and watchdog retries together. This PR prevents the reported VLESS candidate from causing that crash loop and exposes the reason when a healthy core keeps its previous config.

Raw nonempty legacy fallback conflicts require administrator correction; routing is never silently discarded.

Fixes #7001


🔄 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/7003 **Author:** [@HamedSanaei](https://github.com/HamedSanaei) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 11/3/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/vlessenc-fallbacks-xray-crash-7001` --- ### 📝 Commits (2) - [`eaa4359`](https://github.com/MHSanaei/3x-ui/commit/eaa435997e7badfeeeaca8e02130f7ab12058170) fix(inbounds): prevent VLESS fallback conflicts from crashing Xray - [`75954bc`](https://github.com/MHSanaei/3x-ui/commit/75954bc836404d0cc9ce80e34946c2aff9c5d3b0) Merge remote-tracking branch 'origin/main' into pr/7003 ### 📊 Changes **31 files changed** (+853 additions, -79 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/ci.yml` (+3 -3) 📝 `docs/content/docs/en/reference/api/inbounds.mdx` (+30 -16) 📝 `docs/public/openapi.json` (+6 -8) 📝 `frontend/public/openapi.json` (+6 -8) 📝 `frontend/src/pages/api-docs/endpoints.ts` (+5 -5) 📝 `frontend/src/pages/inbounds/form/FallbacksCard.tsx` (+6 -1) 📝 `frontend/src/pages/inbounds/form/InboundFormModal.tsx` (+56 -9) 📝 `frontend/src/pages/inbounds/form/useInboundFallbacks.ts` (+10 -0) 📝 `frontend/src/test/inbound-form-modal.test.tsx` (+132 -10) 📝 `frontend/src/test/setup.components.ts` (+4 -1) ➕ `internal/web/controller/inbound_vless_fallback_test.go` (+119 -0) 📝 `internal/web/service/fallback.go` (+10 -2) 📝 `internal/web/service/inbound.go` (+17 -2) 📝 `internal/web/service/inbound_protocol.go` (+3 -0) ➕ `internal/web/service/inbound_vless_fallback.go` (+78 -0) ➕ `internal/web/service/inbound_vless_fallback_test.go` (+317 -0) 📝 `internal/web/service/xray.go` (+9 -0) 📝 `internal/web/translation/ar-EG.json` (+3 -1) 📝 `internal/web/translation/en-US.json` (+3 -1) 📝 `internal/web/translation/es-ES.json` (+3 -1) _...and 11 more files_ </details> ### 📄 Description ## Problem API and JSON import accept VLESS fallbacks with active server decryption. Xray rejects even `fallbacks: []`, so restarting with the saved configuration can take every inbound down. Panel-managed fallback injection can recreate the conflict. ## Root cause Xray checks server-side `decryption` and whether the fallback slice is nil. UI-only removal of empty arrays did not protect API/import requests, and managed fallback eligibility ignored decryption. The existing `encryption` field is for link generation and is deliberately not used for this restriction. ## Solution - Share VLESS fallback normalization/validation between Add and Update. Remove cosmetic empty arrays, accept null/absent keys, reject malformed entries and nonempty conflicts, and preserve unrelated settings through raw JSON values. - Check managed fallback eligibility before replacement and serialize it with inbound writes. Reject enabling decryption while effective managed rules exist, retain existing rules on rejection, and allow explicit removal from an incompatible master. - Normalize legacy empty arrays in full config generation and local/node payloads. Refuse legacy nonempty conflicts before stopping a healthy core; report the refused candidate through the existing held-back-config status field. This uses the existing recovery path rather than adding general process-manager preflight validation. - Match the form to server decryption, keep existing/draft rules available for removal, block incompatible additions/saves, and keep the draft open on fallback load/save failure. An explicit removal is saved before the incompatible inbound edit; the two HTTP operations remain separate. Retain a newly-created inbound ID when a fallback save needs a retry. - Update all 14 locales, the shared API example and descriptions, generated panel/docs OpenAPI, and the generated API reference. Add SQLite, PostgreSQL, authenticated HTTP/import/node-sync, frontend, concurrency and actual-core regression coverage. CI requires the PostgreSQL regression to execute successfully. ## Testing Validation ran in an isolated Linux checkout of the proposed files with Go 1.27.3, Node 26.12.1, npm 11.20.0 and Chromium. No production installation or live client traffic was used. | Command | Result | | --- | --- | | `make verify` | PASS: generation freshness, Go/frontend lint, formatter, typecheck, all Go packages, 2,023 frontend/Chromium Storybook tests in 215 files, panel/Go builds, Storybook build and docs OpenAPI equality | | `go test ./internal/web/service/... ./internal/web/controller/... ./internal/xray/... -count=1` | PASS | | `make race` | PASS across all Go packages, shuffled and uncached | | `XRAY_E2E_BINARY=/artifacts/xray-7001-current go test -race ./internal/web/service ./internal/web/controller -run '^TestVless' -count=1` | PASS with the exact pinned core, including the healthy-process/gRPC check | | PostgreSQL 16: `go test -race ./internal/web/service -run 'PostgresCommitFailure\|^TestSyncInboundClientsOnPostgres$\|^TestSetClientLimitHwidIsSerializedWithSyncInbound$\|^TestVlessManagedFallbackConflictPostgres$' -count=1 -v` | PASS: all 5 required tests actually ran; CI requires 5 passes | | `make node-e2e` | PASS: real master/node sync under admin and node-sync tokens, plus the three-panel traffic heartbeat chain (352.9 s) | | `go test ./internal/util/link -run '^$' -fuzz '^FuzzParseLink$' -fuzztime=30s -parallel=2` | PASS: 299,242 executions | | `go test ./internal/web/runtime -run '^$' -fuzz '^FuzzDecodeCertPin$' -fuzztime=30s -parallel=2` | PASS: 202,253 executions | | `make vulncheck` | PASS: 0 reachable vulnerabilities; 3 advisories in required modules are not called by this code | | `cd frontend && npm run gen`; copy OpenAPI to docs; `cd docs && npm run gen:api` | PASS; generated outputs committed | | `actionlint -shellcheck= .github/workflows/ci.yml`; `git diff --cached --check` | PASS | An overlapping race/frontend run hit four existing 5-second component-test timeouts. The unchanged tests passed when the full `make verify` was rerun by itself; timeouts were not raised. Default actionlint separately reports existing SC2046 warnings in unchanged workflow scripts (lines 40 and 241); structural workflow validation above passes. Ordinary Go runs skip environment-gated integrations; the live PostgreSQL, actual-core and master/node checks listed above were run separately. The tested Linux files were compared against the staged Git content with `git diff --exit-code` and matched exactly. The initial regression run failed for Add/Update, managed rules and every legacy runtime path with the reported fallback conflict. The frontend reproduction failed because adding fallbacks remained enabled. Both became green after the changes. The healthy-core test also first failed because the refusal reason was absent, then passed after exposing it. Actual Xray validation: the tests call the embedded Xray-core VLESS/Trojan config builders, not just JSON-key assertions. A real core built from the exact `go.mod` dependency (`v1.260327.1-0.20261021115930-1b1647cd9ddf`) remains running and answers its gRPC API after both forced and ordinary restart attempts reject a conflicting candidate. ## Xray status follow-up The broader crash-loop status issue is deferred, not claimed fixed. A separate automated reproduction seeded a cached running status with no current Xray process: `CurrentStatus()` still returned `running` with an empty error while `IsXrayRunning()` was false. `CurrentStatus()` reuses the periodic snapshot, and process replacement also clears the cached result. That demonstrates a stale-status mechanism; it does not establish the complete cause of the reporter's sustained polling results. A separate lifecycle/status change should test exited children and watchdog retries together. This PR prevents the reported VLESS candidate from causing that crash loop and exposes the reason when a healthy core keeps its previous config. Raw nonempty legacy fallback conflicts require administrator correction; routing is never silently discarded. ## Related issue Fixes #7001 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi changed title from [PR #7003] fix(inbounds): reject incompatible VLESS fallbacks and prevent Xray crashes to [PR #7003] [MERGED] fix(inbounds): reject incompatible VLESS fallbacks and prevent Xray crashes 2026-11-07 14:34:02 +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#6571
No description provided.