[PR #5970] [MERGED] Repo-wide self-correcting audit: 54 verified bug fixes #6043

Closed
opened 2026-11-02 04:05:58 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5970
Author: @MHSanaei
Created: 7/15/2026
Status: ✅ Merged
Merged: 7/16/2026
Merged by: @MHSanaei

Base: main ← Head: audit/self-correcting-review


📝 Commits (10+)

  • 97dd724 fix(email): resolve a name-addr smtpFrom into bare envelope address and display name
  • 9ffbeb4 fix(email): report a missing sender address from the SMTP connection test
  • 52442cb fix(sub): fall back to the raw subscription when an auto-detected format has no content
  • 448e8c9 fix(node): match prefixed central tags when filtering a selected-mode node snapshot
  • 7b266a9 fix(client): refuse a bulk quota reduction that would fall to or below zero
  • e4ef8a5 fix(client): persist a bulk adjustment's applied field even when the sibling field is skipped
  • 091dbc0 fix(inbound): always create in AddInbound instead of overwriting a row whose id was posted
  • a77c365 fix(inbound): accept WireGuard clients when creating an inbound
  • ade3a8f fix(client): stop holding the inbound-lock registry mutex while waiting on one inbound
  • 0bbcd2a fix(client): honor keepTraffic when deleting a client that is attached to inbounds

📊 Changes

102 files changed (+2733 additions, -395 deletions)

View changed files

📝 frontend/src/api/http-init.ts (+5 -2)
📝 frontend/src/api/websocket.ts (+9 -0)
📝 frontend/src/api/websocketBridge.ts (+3 -17)
📝 frontend/src/components/clients/ConfigBlock.css (+1 -0)
📝 frontend/src/hooks/useWebSocket.ts (+2 -17)
📝 frontend/src/lib/xray/forms/fields/SniffingField.tsx (+11 -3)
📝 frontend/src/pages/clients/ClientFormModal.tsx (+10 -2)
📝 frontend/src/pages/nodes/NodeList.tsx (+1 -1)
📝 frontend/src/pages/xray/basics/BasicsTab.tsx (+2 -1)
📝 frontend/src/pages/xray/outbounds/OutboundCardList.tsx (+9 -9)
📝 frontend/src/pages/xray/outbounds/OutboundsTab.tsx (+21 -10)
📝 frontend/src/pages/xray/outbounds/outbounds-tab-helpers.ts (+13 -0)
📝 frontend/src/pages/xray/outbounds/useOutboundColumns.tsx (+11 -11)
📝 frontend/src/pages/xray/routing/RoutingTab.tsx (+24 -12)
📝 frontend/src/pages/xray/routing/RuleFormModal.tsx (+6 -0)
📝 frontend/src/pages/xray/routing/helpers.ts (+12 -0)
➕ frontend/src/test/basics-happy-eyeballs.test.tsx (+36 -0)
➕ frontend/src/test/client-total-bytes.test.tsx (+20 -0)
📝 frontend/src/test/http-init-msw.test.ts (+29 -0)
📝 frontend/src/test/httpUtil.test.ts (+2 -2)

...and 80 more files

📄 Description

What this is

A repo-wide, self-correcting code audit run in prioritized batches (high-risk backend → rest of backend → frontend → shell scripts → final adversarial re-review). Each batch scanned the code, confirmed every finding by re-reading the cited region, then landed one focused fix + one regression test per confirmed bug, each as its own conventional commit.

54 commits, every fix red/green verified (the test fails before the fix, passes after).

Verification

  • Go: go build ./..., go vet ./..., all packages pass (including internal/web/service/... and internal/eventbus under -race).
  • Frontend: tsc --noEmit, 792 Vitest tests (70 files), vite build — no generated-file drift.

Highlights

Critical (P1)

  • tgbot: the second callback switch ran outside the isAdmin guard, exposing DB backup / traffic reset / add-client to any caller — added default-deny.
  • Routing & Outbounds tables: row actions used the antd positional index against the full, unfiltered array; once a hidden balancer-loopback (_bl_*) row preceded a visible one, edit/delete/probe hit the wrong entry. Fixed on both desktop and mobile paths via an explicit positional→real index mapping.
  • Plus backend P1s from earlier batches (node tag-prefix data loss, MTProto inside the serialized traffic tx, traffic-tick rollback loss, …).

Notable (P2)

  • CSRF: on a 403 the client re-sent the stale <meta> token instead of refetching; now pulls a fresh token from /csrf-token.
  • eventbus: one slow subscriber (email/Telegram) stalled the whole pipeline. Now each subscriber drains its own bounded queue on a dedicated worker — non-blocking, backpressure preserved, one in-flight handler per subscriber (this also removed a data race the first attempt introduced, caught by the final adversarial pass).
  • email: SMTP paths had no connection deadline and leaked a goroutine + socket on a silent server; deadlines added on every path.
  • Xray config UI: a malformed happyEyeballs value white-screened the Basics tab (parse→safeParse); editing a routing rule dropped fields the form doesn't surface; the Sniffing island didn't re-sync to external (advanced-JSON) edits.
  • HttpUtil surfaced only a generic message (read data.message vs the backend's msg); node table used duplicate React keys for transitive sub-nodes; a double WebSocket connection was opened per page.

Adversarial re-review: the five riskiest fixes were independently re-reviewed; it caught an incomplete outbounds fix (mobile card list) and a regression in the first eventbus attempt — both fixed and re-verified in this branch.

Not included (need maintainer input)

  • Shell scripts (x-ui.sh, install.sh, DockerInit.sh, update.sh): 23 findings were identified but not committed — they are Linux/Docker-only and unverifiable on the audit host (no bash -n/shellcheck/Docker), and touch the live install/update path. They should be reviewed and applied on Linux as a separate PR. The most serious (P2): non-TTY panel-triggered update can spin in an infinite read loop on a filtered host; an unattended update can auto-issue an SSL cert; the fail2ban SSH-port exemption can fall back to port 22 on busybox/Debian-12; DockerInit.sh lacks set -e; Docker arch labels don't match TARGETARCH.
  • A few P2/P3 items were deferred with documented reasons (e.g. the Telegram add-client draft globals race — a ~100-site per-chat refactor; the IP-limit grace window — needs a data-model change).

One open decision

MergeClientRecord treats 0 (unlimited / never-expire) as the smallest value, so merging duplicate-email clients during migration can downgrade unlimited→limited or set a past expiry. The past-expiry case looks wrong, but the general merge policy is a judgment call on migration behavior — left for maintainer decision before changing it.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/5970 **Author:** [@MHSanaei](https://github.com/MHSanaei) **Created:** 7/15/2026 **Status:** ✅ Merged **Merged:** 7/16/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `audit/self-correcting-review` --- ### 📝 Commits (10+) - [`97dd724`](https://github.com/MHSanaei/3x-ui/commit/97dd724424c651c0e2b1c0cdff6b6ab5982bf789) fix(email): resolve a name-addr smtpFrom into bare envelope address and display name - [`9ffbeb4`](https://github.com/MHSanaei/3x-ui/commit/9ffbeb493891be56d4db706fbd80c9b4c0c575eb) fix(email): report a missing sender address from the SMTP connection test - [`52442cb`](https://github.com/MHSanaei/3x-ui/commit/52442cb50c459fd30604403741318d5461bbe2dc) fix(sub): fall back to the raw subscription when an auto-detected format has no content - [`448e8c9`](https://github.com/MHSanaei/3x-ui/commit/448e8c97c2f1ecf591da466b9dd9db1ff9f62f3b) fix(node): match prefixed central tags when filtering a selected-mode node snapshot - [`7b266a9`](https://github.com/MHSanaei/3x-ui/commit/7b266a90010784ca32b889954a4a5b6201b46a14) fix(client): refuse a bulk quota reduction that would fall to or below zero - [`e4ef8a5`](https://github.com/MHSanaei/3x-ui/commit/e4ef8a54d482dd78abac07f9894219addaea9a33) fix(client): persist a bulk adjustment's applied field even when the sibling field is skipped - [`091dbc0`](https://github.com/MHSanaei/3x-ui/commit/091dbc0c6e27e065a12323df0c6e15df8bc27272) fix(inbound): always create in AddInbound instead of overwriting a row whose id was posted - [`a77c365`](https://github.com/MHSanaei/3x-ui/commit/a77c365fe4196cbafe1b222281c80729f66686c9) fix(inbound): accept WireGuard clients when creating an inbound - [`ade3a8f`](https://github.com/MHSanaei/3x-ui/commit/ade3a8f87033ddc8a684045866863b8374353f28) fix(client): stop holding the inbound-lock registry mutex while waiting on one inbound - [`0bbcd2a`](https://github.com/MHSanaei/3x-ui/commit/0bbcd2a8f2cd7a53ddff8586e120043c99a86d22) fix(client): honor keepTraffic when deleting a client that is attached to inbounds ### 📊 Changes **102 files changed** (+2733 additions, -395 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/api/http-init.ts` (+5 -2) 📝 `frontend/src/api/websocket.ts` (+9 -0) 📝 `frontend/src/api/websocketBridge.ts` (+3 -17) 📝 `frontend/src/components/clients/ConfigBlock.css` (+1 -0) 📝 `frontend/src/hooks/useWebSocket.ts` (+2 -17) 📝 `frontend/src/lib/xray/forms/fields/SniffingField.tsx` (+11 -3) 📝 `frontend/src/pages/clients/ClientFormModal.tsx` (+10 -2) 📝 `frontend/src/pages/nodes/NodeList.tsx` (+1 -1) 📝 `frontend/src/pages/xray/basics/BasicsTab.tsx` (+2 -1) 📝 `frontend/src/pages/xray/outbounds/OutboundCardList.tsx` (+9 -9) 📝 `frontend/src/pages/xray/outbounds/OutboundsTab.tsx` (+21 -10) 📝 `frontend/src/pages/xray/outbounds/outbounds-tab-helpers.ts` (+13 -0) 📝 `frontend/src/pages/xray/outbounds/useOutboundColumns.tsx` (+11 -11) 📝 `frontend/src/pages/xray/routing/RoutingTab.tsx` (+24 -12) 📝 `frontend/src/pages/xray/routing/RuleFormModal.tsx` (+6 -0) 📝 `frontend/src/pages/xray/routing/helpers.ts` (+12 -0) ➕ `frontend/src/test/basics-happy-eyeballs.test.tsx` (+36 -0) ➕ `frontend/src/test/client-total-bytes.test.tsx` (+20 -0) 📝 `frontend/src/test/http-init-msw.test.ts` (+29 -0) 📝 `frontend/src/test/httpUtil.test.ts` (+2 -2) _...and 80 more files_ </details> ### 📄 Description ## What this is A repo-wide, self-correcting code audit run in prioritized batches (high-risk backend → rest of backend → frontend → shell scripts → final adversarial re-review). Each batch scanned the code, confirmed every finding by re-reading the cited region, then landed **one focused fix + one regression test per confirmed bug**, each as its own conventional commit. **54 commits**, every fix red/green verified (the test fails before the fix, passes after). ## Verification - **Go**: `go build ./...`, `go vet ./...`, all packages pass (including `internal/web/service/...` and `internal/eventbus` under `-race`). - **Frontend**: `tsc --noEmit`, 792 Vitest tests (70 files), `vite build` — no generated-file drift. ## Highlights **Critical (P1)** - **tgbot**: the second callback switch ran outside the `isAdmin` guard, exposing DB backup / traffic reset / add-client to any caller — added default-deny. - **Routing & Outbounds tables**: row actions used the antd *positional* index against the full, unfiltered array; once a hidden balancer-loopback (`_bl_*`) row preceded a visible one, edit/delete/probe hit the wrong entry. Fixed on both desktop and mobile paths via an explicit positional→real index mapping. - Plus backend P1s from earlier batches (node tag-prefix data loss, MTProto inside the serialized traffic tx, traffic-tick rollback loss, …). **Notable (P2)** - **CSRF**: on a 403 the client re-sent the stale `<meta>` token instead of refetching; now pulls a fresh token from `/csrf-token`. - **eventbus**: one slow subscriber (email/Telegram) stalled the whole pipeline. Now each subscriber drains its own bounded queue on a dedicated worker — non-blocking, backpressure preserved, one in-flight handler per subscriber (this also removed a data race the first attempt introduced, caught by the final adversarial pass). - **email**: SMTP paths had no connection deadline and leaked a goroutine + socket on a silent server; deadlines added on every path. - **Xray config UI**: a malformed `happyEyeballs` value white-screened the Basics tab (`parse`→`safeParse`); editing a routing rule dropped fields the form doesn't surface; the Sniffing island didn't re-sync to external (advanced-JSON) edits. - HttpUtil surfaced only a generic message (read `data.message` vs the backend's `msg`); node table used duplicate React keys for transitive sub-nodes; a double WebSocket connection was opened per page. **Adversarial re-review**: the five riskiest fixes were independently re-reviewed; it caught an incomplete outbounds fix (mobile card list) and a regression in the first eventbus attempt — both fixed and re-verified in this branch. ## Not included (need maintainer input) - **Shell scripts (`x-ui.sh`, `install.sh`, `DockerInit.sh`, `update.sh`)**: 23 findings were identified but **not committed** — they are Linux/Docker-only and unverifiable on the audit host (no `bash -n`/shellcheck/Docker), and touch the live install/update path. They should be reviewed and applied on Linux as a separate PR. The most serious (P2): non-TTY panel-triggered update can spin in an infinite `read` loop on a filtered host; an unattended update can auto-issue an SSL cert; the fail2ban SSH-port exemption can fall back to port 22 on busybox/Debian-12; `DockerInit.sh` lacks `set -e`; Docker arch labels don't match `TARGETARCH`. - A few P2/P3 items were deferred with documented reasons (e.g. the Telegram add-client draft globals race — a ~100-site per-chat refactor; the IP-limit grace window — needs a data-model change). ## One open decision `MergeClientRecord` treats `0` (unlimited / never-expire) as the *smallest* value, so merging duplicate-email clients during migration can downgrade unlimited→limited or set a past expiry. The past-expiry case looks wrong, but the general merge policy is a judgment call on migration behavior — left for maintainer decision before changing it. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:05:58 +07:00
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#6043
No description provided.