mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[GH-ISSUE #5903] [Bug]: Rare data inconsistency: client UUID in panel credentials differs from UUID in generated subscription links #4091
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#4091
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 @HamedSanaei on GitHub (Jul 11, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5903
Describe the bug
Describe the bug
I encountered a rare but serious data inconsistency when creating a client through the API.
The client is created successfully, but the UUID shown in the panel credentials is different from the UUID used in the generated subscription links/configs.
In the panel UI, inside the client's credentials section, the UUID is shown as:
Screenshots
No response
3x-ui version
3.4.2
Xray-core version
26.6.27
How did you install 3x-ui?
install.sh script
Operating system
ubuntu 26
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 (Jul 11, 2026):
Confirmed in source: the panel stores each client credential set in two separate places that are reconciled only under specific conditions, and there is a concrete code path where a repeated
/panel/api/clients/addcall can desync them. This matches every symptom in the report.Title:
Create(backingPOST /panel/api/clients/add) can mint a fresh UUID for a client identity that already exists, desyncing the normalized client record from the inbound(s) that still hold the original credentialSeverity: High
Category: Correctness
Why this matters:
3x-ui keeps two representations of a client:
clients[]array inside each inbound Settings JSON column — this is what Xray-core actually loads and enforces for that inbound.clientstable (model.ClientRecord), kept in sync from the JSON bySyncInbound(internal/web/service/client_link.go:12).These two paths diverge for link generation:
clientstable (internal/sub/service.go:252matchingClientscallingGetClientsBySubId, explicitly documented as "resolved from the normalized clients/client_inbounds tables ... instead of parsing the settings JSON").GET /panel/api/clients/links/:email->GetAllClientLinks->internal/sub/links.go:38LinksForClient) builds a freshSubServiceper call with an empty cache, so it falls through toclientForLink(internal/sub/service.go:138), which parses that specific inbound raw Settings JSON directly viainboundService.GetClients(inbound).Normally
SyncInboundkeepsclients.uuidequal to whatever is in the inbound JSON. ButSyncInboundreconciles by email only, last write wins (internal/web/service/client_link.go:69-71,if incoming.UUID != "" { row.UUID = incoming.UUID }), andCreate(internal/web/service/client_crud.go:45) does not guard against regenerating a credential for an identity that already exists:Createallows a second call for an email that is already taken as long as the payloadsubIdmatches the stored one (client_crud.go:76-84) — this is the intended way to attach an existing identity to another inbound via/add.Update(client_crud.go:335-341, which explicitly seedsupdated.ID = existing.UUIDwhen the payload omits it, with a comment stating this is precisely to stopfillProtocolDefaultsfrom silently rotating the client UUID),Createnever seedsclient.IDfrom theexistingrecord it already loaded for the collision check. It callsfillProtocolDefaults(client_crud.go:126) directly on the raw incoming payload.frontend/src/pages/api-docs/endpoints.ts:588), the UUID is generated server-side when omitted, so callers can send only the universal fields — so a caller that issues a separate/clients/addcall per node/inbound for the same client email plus subId, omittingideach time (a reasonable reading of that same documentation), gets a new random UUID minted on every call.SyncInboundthen overwrites the single sharedclients.uuidrow with whichever call ran last, while every other already-attached inbound Settings JSON — and therefore what is actually enforced there — keeps its own original UUID.Attach(client_crud.go:537) andBulkAttach(client_bulk.go:32) both correctly seed the outgoing client from the existing record (existing.ToClient()/rec.ToClient()) before callingfillProtocolDefaults, so they do not have this problem.Net effect: subscription links (DB-table sourced) can silently diverge from one or more of the client actual per-inbound credentials (JSON sourced), with no error surfaced anywhere. Devices that pull the subscription authenticate correctly against at most one of the attached inbounds/nodes and silently fail on the rest. This is a DB-level data divergence, not a runtime cache, so restarting the panel, as the reporter tried, cannot fix it.
Recommendation: Mirror the existing-credential-preservation guard already in
UpdateinsideCreate: when the email/subId collision check finds a matchingexistingrecord, seedclient.ID/Password/Auth/Secretfromexisting(same fieldsUpdatealready preserves) before callingfillProtocolDefaults, so a repeat/clients/addcall for an already-existing identity reuses the stored credential instead of minting a new one — the same patternAttach/BulkAttachalready follow. Worth checking whetherBulkCreate(client_bulk.go:1127) needs the same guard, since it processes each payload independently in the same way. Not opening a PR — happy to implement this if @MHSanaei confirms the approach.Example:
Confidence: Medium-high. Every element of this chain is confirmed directly in source on the current
main(same as the reportedv3.4.2, no relevant changes since), and it reproduces every reported symptom (rare, API-created, identical wrong UUID on all node-generated configs, unaffected by restart). What cannot be confirmed without more detail is the exact call sequence used, so that is requested below rather than assumed.To pin down the exact trigger, please confirm:
/panel/api/clients/addcall with all 4 inbound IDs ininboundIds, or via separate calls (e.g., one per node)?idfield, or was it left blank?GET /panel/api/clients/get/:emailcurrently returnee068537-...(the normalized record used by the subscription)? If so, which of the 4 inbounds raw settings (GET /panel/api/inbounds/get/:id) still contains419fc244-..., and do the other inbounds each hold yet another distinct UUID?@MHSanaei for visibility — this looks like a real gap in
Createversus the safeguard already present inUpdate/Attach/BulkAttach.This reply was generated automatically. A maintainer may follow up.