[GH-ISSUE #5111] [BUG] Client UUID is unexpectedly changed when using Update Client API #3589

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

Originally created by @SomeBytee on GitHub (Jun 9, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5111

Describe the bug

Hi
Description

When using the endpoint:

/panel/api/clients/update/{email}

the client's UUID is automatically regenerated after the update operation.

This behavior occurs even when the request does not intend to modify the UUID and even when a UUID is explicitly provided in the request body.

Additional Information

I understand that the Add Client API currently does not allow specifying a custom UUID and generates it server-side, which is acceptable.

However, the Update Client API should preserve the existing UUID when updating an existing client.

I also attempted to provide the original UUID in the update request, but the server still generated a different UUID.

i used the api execute function in the panel API doc section and used it myself in a python enviroment and got the same result

How to reproduce the problem

  1. Create a client with UUID:
    11111111-1111-1111-1111-111111111111

  2. Update only the traffic limit using:
    /panel/api/clients/update/{email}

  3. Observe that the UUID becomes something like:
    22222222-2222-2222-2222-222222222222

even though no UUID change was requested.

Expected behavior

existing UUID should remain unchanged unless the user explicitly requests UUID regeneration.

Updating client properties should not modify the client's authentication credentials.

Actual behavior

  1. Create a client.
  2. Note the generated UUID.
  3. Call:
    /panel/api/clients/update/{email}
    to modify unrelated fields such as:
  • limit
  • Expiry time
  • Enable/Disable status
  • Telegram ID
  • Subscription settings
  1. After the update completes, the client's UUID is changed to a newly generated value.

Relevant logs


Screenshots

No response

3x-ui version

3.3.0

Xray-core version

26.6.1

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 22.04

Which parts of the panel are affected?

No response

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

None

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 @SomeBytee on GitHub (Jun 9, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5111 ### Describe the bug Hi Description When using the endpoint: /panel/api/clients/update/{email} the client's UUID is automatically regenerated after the update operation. This behavior occurs even when the request does not intend to modify the UUID and even when a UUID is explicitly provided in the request body. Additional Information I understand that the Add Client API currently does not allow specifying a custom UUID and generates it server-side, which is acceptable. However, the Update Client API should preserve the existing UUID when updating an existing client. I also attempted to provide the original UUID in the update request, but the server still generated a different UUID. i used the api execute function in the panel API doc section and used it myself in a python enviroment and got the same result ### How to reproduce the problem 1. Create a client with UUID: 11111111-1111-1111-1111-111111111111 2. Update only the traffic limit using: /panel/api/clients/update/{email} 3. Observe that the UUID becomes something like: 22222222-2222-2222-2222-222222222222 even though no UUID change was requested. ### Expected behavior existing UUID should remain unchanged unless the user explicitly requests UUID regeneration. Updating client properties should not modify the client's authentication credentials. ### Actual behavior 1. Create a client. 2. Note the generated UUID. 3. Call: /panel/api/clients/update/{email} to modify unrelated fields such as: - limit - Expiry time - Enable/Disable status - Telegram ID - Subscription settings 4. After the update completes, the client's UUID is changed to a newly generated value. ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.3.0 ### Xray-core version 26.6.1 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 22.04 ### Which parts of the panel are affected? _No response_ ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? None ### Before submitting - [x] I searched [existing issues](../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:33:33 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@github-actions[bot] commented on GitHub (Jun 9, 2026):

Confirmed bug — root cause identified

Reproduced against the v3.3.0 source. Here is exactly what happens.

Root cause

web/service/client.go — the Update function (line ~829) calls fillProtocolDefaults(&updated, inbound) before falling back to the existing UUID. That helper (lines 642–647) generates a fresh UUID whenever c.ID == "":

// fillProtocolDefaults — web/service/client.go:644
case model.VMESS, model.VLESS:
    if c.ID == "" {
        c.ID = uuid.NewString()  // <-- always fires when "id" is absent from the body
    }

Because the update body is treated as a full replacement (not a patch), any field you omit is zeroed. updated.ID is empty, the helper generates a new UUID, UpdateInboundClient writes it to the inbound settings, and then SyncInbound (line ~4040) propagates that new UUID back to clients.uuid in the database. The old UUID is permanently gone.

The same logic applies to Trojan password and Hysteria auth — omitting those fields also rotates the credential silently.

Why the Swagger "Try it out" makes it worse

The built-in OpenAPI example for POST /panel/api/clients/update/{email} is:

{
  "email": "alice@example.com",
  "totalGB": 107374182400,
  "expiryTime": 1767225600000,
  "tgId": 123456789,
  "enable": true
}

No "id" field. Anyone copying that example will unknowingly trigger UUID rotation.

Workaround until a fix ships

First, fetch the current UUID via:

GET /panel/api/clients/get/{email}

The response includes "client": { "id": "...", ... }.

Then include "id" with the existing value in every update call:

{
  "email": "user@example.com",
  "id": "11111111-1111-1111-1111-111111111111",
  "totalGB": 10737418240,
  "expiryTime": 1767225600000,
  "enable": true
}

The JSON field name accepted by the update endpoint is "id" (not "uuid" — the uuid key only appears in the ClientRecord database model).

Suggested fix

In Update (web/service/client.go, before the inbound loop), merge existing credentials into the updated struct when the caller left them blank:

if updated.ID == "" {
    updated.ID = existing.UUID
}
if updated.Password == "" {
    updated.Password = existing.Password
}
if updated.Auth == "" {
    updated.Auth = existing.Auth
}

This preserves credentials across partial-field updates while still allowing explicit rotation when the caller intentionally supplies a new value.

<!-- gh-comment-id:4656741866 --> @github-actions[bot] commented on GitHub (Jun 9, 2026): ## Confirmed bug — root cause identified Reproduced against the v3.3.0 source. Here is exactly what happens. ### Root cause `web/service/client.go` — the `Update` function (line ~829) calls `fillProtocolDefaults(&updated, inbound)` **before** falling back to the existing UUID. That helper (lines 642–647) generates a fresh UUID whenever `c.ID == ""`: ```go // fillProtocolDefaults — web/service/client.go:644 case model.VMESS, model.VLESS: if c.ID == "" { c.ID = uuid.NewString() // <-- always fires when "id" is absent from the body } ``` Because the update body is treated as a **full replacement** (not a patch), any field you omit is zeroed. `updated.ID` is empty, the helper generates a new UUID, `UpdateInboundClient` writes it to the inbound settings, and then `SyncInbound` (line ~4040) propagates that new UUID back to `clients.uuid` in the database. The old UUID is permanently gone. The same logic applies to Trojan `password` and Hysteria `auth` — omitting those fields also rotates the credential silently. ### Why the Swagger "Try it out" makes it worse The built-in OpenAPI example for `POST /panel/api/clients/update/{email}` is: ```json { "email": "alice@example.com", "totalGB": 107374182400, "expiryTime": 1767225600000, "tgId": 123456789, "enable": true } ``` No `"id"` field. Anyone copying that example will unknowingly trigger UUID rotation. ### Workaround until a fix ships First, **fetch the current UUID** via: ``` GET /panel/api/clients/get/{email} ``` The response includes `"client": { "id": "...", ... }`. Then include **`"id"` with the existing value** in every update call: ```json { "email": "user@example.com", "id": "11111111-1111-1111-1111-111111111111", "totalGB": 10737418240, "expiryTime": 1767225600000, "enable": true } ``` The JSON field name accepted by the update endpoint is **`"id"`** (not `"uuid"` — the `uuid` key only appears in the `ClientRecord` database model). ### Suggested fix In `Update` (`web/service/client.go`, before the inbound loop), merge existing credentials into the updated struct when the caller left them blank: ```go if updated.ID == "" { updated.ID = existing.UUID } if updated.Password == "" { updated.Password = existing.Password } if updated.Auth == "" { updated.Auth = existing.Auth } ``` This preserves credentials across partial-field updates while still allowing explicit rotation when the caller intentionally supplies a new value.
Author
Owner

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

Fixed in 2969f6e9. The Update client API now preserves the existing UUID (and Trojan password / Hysteria auth) when those fields are omitted from the request body, so partial updates no longer silently rotate credentials. Supplying a new value still rotates intentionally.

<!-- gh-comment-id:4659055915 --> @MHSanaei commented on GitHub (Jun 9, 2026): Fixed in 2969f6e9. The `Update` client API now preserves the existing UUID (and Trojan password / Hysteria auth) when those fields are omitted from the request body, so partial updates no longer silently rotate credentials. Supplying a new value still rotates intentionally.
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#3589
No description provided.