[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

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

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:

  • VLESS + Reality
  • Hysteria2

After the delete API succeeds:

  • The client no longer appears in the panel/API client list.
  • The subscription for that client no longer updates successfully.
  • The old Hysteria2 local config stops working.
  • The old VLESS Reality local config still connects.

After calling the official Xray restart endpoint, the old VLESS Reality config immediately stops working.

How to reproduce the problem

  1. Install 3x-ui v3.4.0.

  2. Use Xray Core 26.6.22.

  3. Create two enabled inbounds:

    • one VLESS + Reality inbound
    • one Hysteria2 inbound
  4. Create one enabled client and attach the same client email/identity to both inbounds.

  5. Import the subscription into a VPN client.

  6. Confirm both nodes can connect.

  7. Delete the client through the official API:

    POST /panel/api/clients/del/{email}?keepTraffic=0
    
  8. Confirm through the API/panel that the client is gone.

  9. Do not update the subscription in the VPN client.

  10. 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:

  • VLESS Reality
  • Hysteria2

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:

POST /panel/api/server/restartXrayService

or running an equivalent Xray restart makes the old VLESS Reality config fail immediately.

I also tested applying Xray settings after delete:

POST /panel/api/xray/update

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:

  • delete API returns success
  • client list no longer contains the deleted client
  • subscription no longer works for that client
  • old VLESS Reality local config still connects until Xray restart

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?

  • Backend (API endpoints, login, settings)
  • Xray config generation

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:

internal/web/service/client_inbound_apply.go

In DelInboundClientByEmail, runtime removal appears to be guarded by !emailShared:

emailShared, err := inboundSvc.emailUsedByOtherInbounds(email, inboundId)
...
if len(email) > 0 && !emailShared {
    if oldInbound.NodeID == nil {
        if needApiDel {
            err1 := rt.RemoveUser(context.Background(), oldInbound, email)
            ...
        }
    }
}

For a client attached to multiple inbounds, emailShared can be true while deleting from one inbound. That makes sense for preserving shared traffic/accounting rows, but it may be incorrect for skipping runtime RemoveUser, because Xray users are attached to a specific inbound tag.

In other words:

  • traffic records may be shared by email
  • runtime users are scoped by inbound tag + email

So runtime deletion probably should not be skipped just because the same email still exists in another inbound.

Workaround

After deleting the client, calling:

POST /panel/api/server/restartXrayService

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

  • 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 @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: - VLESS + Reality - Hysteria2 After the delete API succeeds: - The client no longer appears in the panel/API client list. - The subscription for that client no longer updates successfully. - The old Hysteria2 local config stops working. - The old VLESS Reality local config still connects. After calling the official Xray restart endpoint, the old VLESS Reality config immediately stops working. ### How to reproduce the problem 1. Install 3x-ui v3.4.0. 2. Use Xray Core 26.6.22. 3. Create two enabled inbounds: - one VLESS + Reality inbound - one Hysteria2 inbound 4. Create one enabled client and attach the same client email/identity to both inbounds. 5. Import the subscription into a VPN client. 6. Confirm both nodes can connect. 7. Delete the client through the official API: ```http POST /panel/api/clients/del/{email}?keepTraffic=0 ``` 8. Confirm through the API/panel that the client is gone. 9. Do not update the subscription in the VPN client. 10. 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: - VLESS Reality - Hysteria2 ### 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: ```http POST /panel/api/server/restartXrayService ``` or running an equivalent Xray restart makes the old VLESS Reality config fail immediately. I also tested applying Xray settings after delete: ```http POST /panel/api/xray/update ``` 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: - delete API returns success - client list no longer contains the deleted client - subscription no longer works for that client - old VLESS Reality local config still connects until Xray restart ### 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? - Backend (API endpoints, login, settings) - Xray config generation ### 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: ```text internal/web/service/client_inbound_apply.go ``` In `DelInboundClientByEmail`, runtime removal appears to be guarded by `!emailShared`: ```go emailShared, err := inboundSvc.emailUsedByOtherInbounds(email, inboundId) ... if len(email) > 0 && !emailShared { if oldInbound.NodeID == nil { if needApiDel { err1 := rt.RemoveUser(context.Background(), oldInbound, email) ... } } } ``` For a client attached to multiple inbounds, `emailShared` can be true while deleting from one inbound. That makes sense for preserving shared traffic/accounting rows, but it may be incorrect for skipping runtime `RemoveUser`, because Xray users are attached to a specific inbound tag. In other words: - traffic records may be shared by email - runtime users are scoped by inbound tag + email So runtime deletion probably should not be skipped just because the same email still exists in another inbound. ### Workaround After deleting the client, calling: ```http POST /panel/api/server/restartXrayService ``` 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 - [x] I searched [existing issues](https://github.com/MHSanaei/3x-ui/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:35:32 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@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 emailShared guard in DelInboundClientByEmail (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, calling DelInboundClientByEmail for each. Inside that function, at line 771:

emailShared, err := inboundSvc.emailUsedByOtherInbounds(email, inboundId)

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:

if len(email) > 0 && \!emailShared {
    if oldInbound.NodeID == nil {
        if needApiDel {
            // rt.RemoveUser(...) called here
        }
    }
}

The problem is ordering:

  1. 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.

  2. Inbound B (Hysteria2) processed second. Because VLESS+Reality was already removed from the DB in step 1, emailShared = false. rt.RemoveUser is called on the Xray gRPC handler API for the Hysteria2 inbound tag only. This call succeeds, returning needRestart = false.

  3. Delete() returns needRestart = false. The controller (internal/web/controller/client.go:186) does not call SetToNeedRestart(), 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 = true and misses the runtime removal.

Workaround (current)

Until a fix is available, call the Xray restart endpoint after deleting a multi-inbound client:

POST /panel/api/server/restartXrayApi

This forces a full config reload from the database and the deleted credentials stop working immediately.

What is not affected

  • Single-inbound clients are not affected; the second emailShared check correctly resolves to false and rt.RemoveUser is called normally.
  • Node inbounds (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 DelInboundClientByEmail logic in client_inbound_apply.go has not changed since this codepath was introduced, based on git log history).

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

<!-- gh-comment-id:4793342121 --> @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 `emailShared` guard in `DelInboundClientByEmail` (`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, calling `DelInboundClientByEmail` for each. Inside that function, at line 771: ```go emailShared, err := inboundSvc.emailUsedByOtherInbounds(email, inboundId) ``` 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: ```go if len(email) > 0 && \!emailShared { if oldInbound.NodeID == nil { if needApiDel { // rt.RemoveUser(...) called here } } } ``` The problem is ordering: 1. **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. 2. **Inbound B (Hysteria2) processed second.** Because VLESS+Reality was already removed from the DB in step 1, `emailShared = false`. `rt.RemoveUser` is called on the Xray gRPC handler API for the Hysteria2 inbound tag only. This call succeeds, returning `needRestart = false`. 3. `Delete()` returns `needRestart = false`. The controller (`internal/web/controller/client.go:186`) does not call `SetToNeedRestart()`, 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 = true` and misses the runtime removal. **Workaround (current)** Until a fix is available, call the Xray restart endpoint after deleting a multi-inbound client: ```http POST /panel/api/server/restartXrayApi ``` This forces a full config reload from the database and the deleted credentials stop working immediately. **What is not affected** - Single-inbound clients are not affected; the second `emailShared` check correctly resolves to `false` and `rt.RemoveUser` is called normally. - Node inbounds (`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 `DelInboundClientByEmail` logic in `client_inbound_apply.go` has not changed since this codepath was introduced, based on `git log` history). *This reply was generated automatically; a maintainer may follow up.*
Author
Owner

@MHSanaei commented on GitHub (Jun 24, 2026):

Fixed in 896016f7.

Root cause: DelInboundClientByEmail gated the runtime RemoveUser/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 !emailShared guard was exactly right.

Fix: the per-inbound runtime removal now always runs for the inbound being deleted from. The emailShared guard is kept only where it belongs — preserving the shared, email-keyed client_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.

<!-- gh-comment-id:4793452470 --> @MHSanaei commented on GitHub (Jun 24, 2026): Fixed in 896016f7. **Root cause:** `DelInboundClientByEmail` gated the runtime `RemoveUser`/`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 `!emailShared` guard was exactly right. **Fix:** the per-inbound runtime removal now always runs for the inbound being deleted from. The `emailShared` guard is kept only where it belongs — preserving the shared, email-keyed `client_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.
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#3868
No description provided.