mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5111] [BUG] Client UUID is unexpectedly changed when using Update Client API #3589
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#3589
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 @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
Create a client with UUID:
11111111-1111-1111-1111-111111111111
Update only the traffic limit using:
/panel/api/clients/update/{email}
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
/panel/api/clients/update/{email}
to modify unrelated fields such as:
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
@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— theUpdatefunction (line ~829) callsfillProtocolDefaults(&updated, inbound)before falling back to the existing UUID. That helper (lines 642–647) generates a fresh UUID wheneverc.ID == "":Because the update body is treated as a full replacement (not a patch), any field you omit is zeroed.
updated.IDis empty, the helper generates a new UUID,UpdateInboundClientwrites it to the inbound settings, and thenSyncInbound(line ~4040) propagates that new UUID back toclients.uuidin the database. The old UUID is permanently gone.The same logic applies to Trojan
passwordand Hysteriaauth— 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:No
"id"field. Anyone copying that example will unknowingly trigger UUID rotation.Workaround until a fix ships
First, fetch the current UUID via:
The response includes
"client": { "id": "...", ... }.Then include
"id"with the existing value in every update call:The JSON field name accepted by the update endpoint is
"id"(not"uuid"— theuuidkey only appears in theClientRecorddatabase 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:This preserves credentials across partial-field updates while still allowing explicit rotation when the caller intentionally supplies a new value.
@MHSanaei commented on GitHub (Jun 9, 2026):
Fixed in
2969f6e9. TheUpdateclient 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.