mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #3974] [CLOSED] fix: 11 bugs including critical data-loss and security issues #5572
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#5572
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?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/3974
Author: @mishrarenu066-beep
Created: 3/28/2026
Status: ❌ Closed
Base:
main← Head:fix/comprehensive-bugfixes📝 Commits (1)
0404fcefix: comprehensive bug fixes across the codebase📊 Changes
7 files changed (+63 additions, -84 deletions)
View changed files
📝
sub/sub.go(+6 -3)📝
web/controller/inbound.go(+14 -16)📝
web/controller/websocket.go(+17 -18)📝
web/job/check_cpu_usage.go(+1 -1)📝
web/service/inbound.go(+19 -39)📝
web/service/setting.go(+1 -2)📝
web/web.go(+5 -5)📄 Description
Summary
This PR fixes 11 bugs found through a comprehensive deep scan of the entire codebase, including 4 critical issues that cause data loss or security vulnerabilities.
🔴 Critical Fixes
1. DATA LOSS: 5 functions silently delete all other clients when updating one
Files:
web/service/inbound.goFunctions:
SetClientTelegramUserID,ToggleClientEnableByEmail,ResetClientIpLimitByEmail,ResetClientExpiryTimeByEmail,ResetClientTrafficLimitByEmailAll five functions had the same copy-paste bug: they built a
newClientsslice by only appending the client matching the target email, then replaced the entire client list with just that one client. Every other client in the inbound was silently deleted.2. DATA LOSS:
ResetSettings()never deletes user credentialsFile:
web/service/setting.goThe function called
.Where("1 = 1").Errorinstead of.Delete(model.User{}).Error. This only reads the error from a query that does nothing — users were never deleted on reset.3. SECURITY: WebSocket
CheckOriginallows cross-origin hijackingFile:
web/controller/websocket.goThe fallback
|| originHost == "" || requestHost == ""accepted any origin with a missing host component, allowing WebSocket hijacking from malicious sites. Removed the fallback and added proper host normalization.4. GRACEFUL SHUTDOWN:
Server.Stop()uses cancelled contextFiles:
web/web.go,sub/sub.gos.cancel()was called befores.httpServer.Shutdown(s.ctx), making the context already-done.Shutdownreturned immediately (forced kill) instead of gracefully draining connections. Moveds.cancel()to end and usedcontext.WithTimeout(10s).🟡 Medium Fixes
5. Wrong success messages on error paths (~11 endpoints)
File:
web/controller/inbound.goWhen validation failed, endpoints returned messages like
"inboundUpdateSuccess"alongside the error. Fixed to use"somethingWentWrong"for all error paths.6.
resetAllTraffics/resetAllClientTrafficstrigger restart on errorSetToNeedRestart()was in anelseblock that ran even on failure. Restructured to only call after confirming success.7.
disableInvalidClientshas duplicate unreachable error checkSame
"User %s not found"string check was nested twice. Removed the inner duplicate.8.
DelInboundlogs uninitializedtagvariableThe
elsebranch logged the emptytagvariable instead of the actual inboundid.9.
check_cpu_usage.goindex-out-of-range paniccpu.Percent()can return an empty slice. Addedlen(percent) > 0guard.10. Dead code:
cron.Remove(entry)on never-added entryvar entry cron.EntryIDdefaults to 0;cron.Remove(0)is a no-op.11.
checkEmailExistForInboundduplicatescheckEmailsExistForClientsRefactored to delegate to existing function instead of reimplementing.
Files Changed
web/controller/inbound.go— error messages + flow fixesweb/controller/websocket.go— CheckOrigin security fixweb/service/inbound.go— 5 client-discard fixes + refactorweb/service/setting.go— ResetSettings fixweb/web.go— graceful shutdown + dead code removalsub/sub.go— graceful shutdown fixweb/job/check_cpu_usage.go— panic guard🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.