mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5543] [Bug]: Deleting a client attached to multiple inbounds does not fully remove VLESS Reality user from running Xray until Xray restart #3868
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#3868
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 @ChenTingToDo on GitHub (Jun 24, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5543
Describe the bug
Deleting a client attached to multiple inbounds through the official 3x-ui REST API removes the client from the database and subscription output, but the deleted user can still connect through the VLESS Reality inbound until Xray is restarted.
This was reproduced with one client attached to two enabled inbounds:
After the delete API succeeds:
After calling the official Xray restart endpoint, the old VLESS Reality config immediately stops working.
How to reproduce the problem
Install 3x-ui v3.4.0.
Use Xray Core 26.6.22.
Create two enabled inbounds:
Create one enabled client and attach the same client email/identity to both inbounds.
Import the subscription into a VPN client.
Confirm both nodes can connect.
Delete the client through the official API:
Confirm through the API/panel that the client is gone.
Do not update the subscription in the VPN client.
Reconnect using the old locally saved nodes.
Expected behavior
After the delete API succeeds, the deleted client should no longer be accepted by any running Xray inbound.
Both old local configs should fail:
Actual behavior
The deleted client disappears from the database/API/subscription, but the old VLESS Reality local config can still connect.
The old Hysteria2 config fails, but VLESS Reality continues to work until Xray is restarted.
Calling:
or running an equivalent Xray restart makes the old VLESS Reality config fail immediately.
I also tested applying Xray settings after delete:
This did not fully solve the issue in this setup. Hysteria2 stopped working, but VLESS Reality still connected until Xray was restarted.
Relevant logs
No sensitive logs are included.
Observed behavior is based on API responses and client-side connection tests:
Screenshots
No screenshots are attached because they would contain private domains, ports, client identifiers, and subscription URLs.
3x-ui version
v3.4.0
Xray-core version
26.6.22
How did you install 3x-ui?
install.sh script
Operating system
Ubuntu VPS
Which parts of the panel are affected?
Browser (only if it is a UI bug)
Not a UI bug.
Is the panel behind a reverse proxy or CDN?
Not specified.
Possible source location
I reviewed the v3.4.0 source and the issue may be related to the multi-inbound shared email logic in:
In
DelInboundClientByEmail, runtime removal appears to be guarded by!emailShared:For a client attached to multiple inbounds,
emailSharedcan be true while deleting from one inbound. That makes sense for preserving shared traffic/accounting rows, but it may be incorrect for skipping runtimeRemoveUser, because Xray users are attached to a specific inbound tag.In other words:
So runtime deletion probably should not be skipped just because the same email still exists in another inbound.
Workaround
After deleting the client, calling:
forces Xray to reload from the database-generated config and makes the deleted VLESS Reality user invalid.
This works, but it briefly interrupts existing connections. Ideally the delete API or runtime apply path should remove the user from every affected running inbound without requiring a full Xray restart.
Before submitting
@github-actions[bot] commented on GitHub (Jun 24, 2026):
The bug is confirmed in the source code and the root cause is a race between sequential per-inbound processing and the
emailSharedguard inDelInboundClientByEmail(internal/web/service/client_inbound_apply.go, line 719).Root cause
When a client is attached to two local inbounds,
Delete()(internal/web/service/client_crud.go:420) iterates over both inbound IDs in sequence, callingDelInboundClientByEmailfor each. Inside that function, at line 771:This queries the database for any other inbound that still carries the email. The guard is then used to gate both the traffic-stat deletion and the live Xray API removal:
The problem is ordering:
Inbound A (VLESS + Reality) processed first. At this moment Hysteria2 still has the client in the database, so
emailShared = true. The entire runtime-removal block is skipped. The DB is then written: client removed from VLESS+Reality settings.Inbound B (Hysteria2) processed second. Because VLESS+Reality was already removed from the DB in step 1,
emailShared = false.rt.RemoveUseris called on the Xray gRPC handler API for the Hysteria2 inbound tag only. This call succeeds, returningneedRestart = false.Delete()returnsneedRestart = false. The controller (internal/web/controller/client.go:186) does not callSetToNeedRestart(), so the 30-second restart-check cron (internal/web/web.go:314) is never triggered.Net result: the running Xray process still carries the deleted user in the VLESS+Reality inbound indefinitely. Only a full Xray restart (which rebuilds config from the database, where the client is already gone) clears it.
The asymmetric behaviour between protocols you observed is not inherent to VLESS+Reality vs Hysteria2; it is an artifact of which inbound happens to be processed first in the loop. Whichever inbound is enumerated first gets
emailShared = trueand misses the runtime removal.Workaround (current)
Until a fix is available, call the Xray restart endpoint after deleting a multi-inbound client:
This forces a full config reload from the database and the deleted credentials stop working immediately.
What is not affected
emailSharedcheck correctly resolves tofalseandrt.RemoveUseris called normally.NodeID \!= nil) follow a different branch (rt.DeleteUser) and are also affected by the same guard, but failure there marks the node dirty for reconciliation rather than silently succeeding.Version confirmed against: v3.4.0 (the
DelInboundClientByEmaillogic inclient_inbound_apply.gohas not changed since this codepath was introduced, based ongit loghistory).This reply was generated automatically; a maintainer may follow up.
@MHSanaei commented on GitHub (Jun 24, 2026):
Fixed in
896016f7.Root cause:
DelInboundClientByEmailgated the runtimeRemoveUser/DeleteUser(and its push-plan resolution) on!emailShared. But Xray users are keyed by inbound tag + email, so for a client attached to two inbounds, the first inbound processed still saw the email in the sibling inbound (emailShared == true) and skipped the runtime removal — leaving the user live in the running Xray until restart. Your analysis pointing at the!emailSharedguard was exactly right.Fix: the per-inbound runtime removal now always runs for the inbound being deleted from. The
emailSharedguard is kept only where it belongs — preserving the shared, email-keyedclient_traffics/IP DB rows. A regression test reproduces the multi-inbound scenario and fails without the fix.Thanks for the detailed report and source pointer.