mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5504] [Bug/Potential]: Node sync can create recursive inbound/client imports between panels #3841
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#3841
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 @atem32 on GitHub (Jun 23, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5504
Describe the bug
The new node feature can import inbounds and clients from another 3x-ui panel via API.
When the node feature is enabled, the panel requests another panel through the API and stores the received data into local
inboundsandclients.As a result, the local panel may contain both its own local inbounds/clients and remote inbounds/clients imported from another panel.
This can potentially create a recursive import loop if multiple panels are configured as nodes of each other.
Example topology:
In this situation, Panel 1 imports data from Panel 2 and Panel 3.
If Panel 3 also imports data from Panel 1, and Panel 1 already contains imported data from Panel 2 and Panel 3, then Panel 3 may import not only Panel 1's own local data, but also data that Panel 1 previously imported from Panel 2 and Panel 3.
This may create duplicated inbounds/clients or recursive propagation of remote data between panels.
The same problem may happen in the opposite direction when Panel 1 imports Panel 3 again after Panel 3 has already imported data from Panel 1.
The concern is that the node sync mechanism may not distinguish between:
and
If imported remote data is exported again through the API and then imported by another panel, this can create a loop.
How to reproduce the problem
Create three panels:
Enable the node feature on Panel 1.
Configure Panel 1 to import data from:
Enable the node feature on Panel 3.
Configure Panel 3 to import data from:
Let both panels perform node sync.
Panel 1 imports inbounds and clients from Panel 2 and Panel 3.
Panel 3 imports inbounds and clients from Panel 1 and Panel 2.
If the API response from Panel 1 includes not only Panel 1's own local data, but also data previously imported from Panel 2 and Panel 3, then Panel 3 may import duplicated or already-imported data.
After another sync cycle, the same data may be propagated back again.
This can potentially create a loop like this:
But since Panel 1 data may already contain Panel 2 and Panel 3 imported data, Panel 3 may effectively receive:
This may lead to duplicated inbounds, duplicated clients, inconsistent ownership, or repeated propagation between panels.
Expected behavior
The node sync mechanism should avoid recursive imports.
A panel should not re-export remote data that was imported from another node, unless this behavior is explicitly intended and safely deduplicated.
The panel should distinguish between:
and
When Panel 3 imports data from Panel 1, it should receive only Panel 1's local data, not data that Panel 1 previously imported from Panel 2 or Panel 3.
Alternatively, every imported inbound/client should have metadata such as:
The sync process should use this metadata to prevent loops and duplicates.
For example, if Panel 3 receives an inbound from Panel 1, but that inbound originally came from Panel 3, it should be ignored.
If the same client or inbound already exists from the same original source, it should be updated or skipped instead of duplicated.
The system should also detect circular node configurations and either block them or show a warning before saving.
Example warning:
The safest expected behavior would be:
or:
Actual behavior
It looks like the node feature stores imported API data into local
inboundsandclients.If these imported objects are then exposed again through the same API used by other panels, another panel may import already-imported data.
In a topology where panels are connected to each other as nodes, this can potentially create recursive data propagation.
Example:
Panel 1 stores:
Panel 3 then imports Panel 1.
If Panel 1 exposes all stored data through API, Panel 3 may receive:
This means Panel 3 can receive its own data back through Panel 1, and may also receive Panel 2 data twice.
This may cause duplicated inbounds, duplicated clients, incorrect ownership, or continuous data growth after repeated sync cycles.
I am reporting this as a potential bug / design issue because the current behavior should be clarified and protected against circular node configurations.
Relevant logs
Screenshots
No screenshots available at the moment.
A diagram of the problematic topology:
Potential loop:
3x-ui version
3.3.1
Xray-core version
26.1.1
How did you install 3x-ui?
install.sh script
Operating system
Debian 12
Which parts of the panel are affected?
Multi-node (sub-nodes)
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 23, 2026):
Claude finished @MHSanaei's task in 3m 2s —— View job
Node sync: recursive-import analysis
Thanks for the detailed report. I traced the node-sync path end to end. Short version: your core observation is correct — the sync API does return inbounds a panel previously imported from its own sub-nodes, not just its local ones — but this is intentional for the chained
Node1 → Node2 → Node3topology (#4983), and it is partly protected. The genuine gap is that there is no guard against a true cycle (two panels importing each other), where data can round-trip and create duplicates.How node sync actually works
The relationship is master → node (import). The master pulls a snapshot from each node and stores it locally:
internal/web/job/node_traffic_sync_job.go:345—FetchTrafficSnapshotper node, thenSetRemoteTrafficmerges it.internal/web/runtime/remote.go:615-624— the snapshot is fetched from the node'spanel/api/inbounds/listendpoint.InboundService.GetInbounds(internal/web/service/inbound.go:152-163), which returns every inbound owned by the user — including ones withnode_idset, i.e. inbounds the node itself imported from its sub-nodes.setRemoteTrafficLocked(internal/web/service/inbound_node.go:227). Imported inbounds are stored locally withnode_id = <that node>and anorigin_node_guidattributing them to the panel that physically hosts them (originGuidFor,inbound_node.go:247-252; create path:439-470).So yes — when Panel 3 fetches Panel 1's list, it receives Panel 1's own inbounds plus Panel 1's imported Panel 2/Panel 3 inbounds. This is deliberate: it is exactly how a master sees inbounds two hops down through an intermediate node.
What is already protected
origin_node_guid, not by which node forwarded the data.recountByGuid(internal/web/service/node_tree.go:165-241) buckets each inbound and online client under its true physical-host GUID, so a forwarded inbound is not double-counted in the Nodes page. The chained DAG case relies on this and works correctly.client_trafficsis keyed unique onemail, and the import upsert usesOnConflict{email} DoNothing(inbound_node.go:634), so a re-seen email does not create a second client row.n<id>-prefix fallback (pickFreeTag,inbound_node.go:406-437).inbound_node.go:521-533).The actual gap
There is no check that skips importing an inbound whose
origin_node_guidequals the importing panel's own GUID, and no detection of circular node configuration.originGuidForkeeps any different, non-empty origin as-is — it never asks "is this origin me?" In a true cycle (Panel 1 ↔ Panel 3):origin_node_guid = guid3).node_id = <Panel 1's node row>. Because the tag collides with Panel 3's own local inbound,pickFreeTagassigns then<id>-prefixed variant — a duplicate inbound.(node, email)baseline, on top of Panel 3's local Xray counting them — i.e. inflated/double-counted traffic for the round-tripped clients.The clients themselves stay single rows (email-unique), but the duplicate inbounds and traffic inflation are real, and each sync cycle can keep re-propagating, matching what you described.
Important caveat: this requires an operator to deliberately point two panels at each other as nodes. It is a misconfiguration the system neither prevents nor warns about — not something that arises from a normal tree/DAG of nodes.
On the suggested fixes
origin/source) already exists asorigin_node_guid(internal/database/model/model.go); it is just not used as a loop-breaker on the import side.The cleanest fix within the existing patterns would be, on import in
setRemoteTrafficLocked, to skip any snapshot inbound whoseorigin_node_guidequals this panel's ownpanelGuid(available viaSettingService.GetPanelGuid(), already used atinbound_node.go:956). That breaks the cycle while preserving legitimate chaining, since a genuine sub-node's inbound never carries the importing panel's own GUID. A complementary, lower-priority improvement would be a warning when a configured node's reportedpanelGuidmatches this panel's own GUID (a self/cycle reference), surfaced where duplicate GUIDs are already detected (warnOnDuplicateGuid,node.go:723).Note this is research only — I have not made any code change. I have confirmed the data flow and the missing self-origin guard in the current
main; whether and how to address it is for the maintainer to decide.·
claude/issue-5504-20260623-1531