[PR #5610] [MERGED] fix(settings): require re-2FA confirmation for sensitive setting changes #5928

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5610
Author: @n0ctal
Created: 6/27/2026
Status: ✅ Merged
Merged: 6/28/2026
Merged by: @MHSanaei

Base: main ← Head: pr-2fa-sensitive-settings


📝 Commits (5)

  • b138d05 fix(settings): require server-side 2fa for sensitive changes
  • 6d15f81 Merge branch 'main' into pr-2fa-sensitive-settings
  • a23e6f3 Merge branch 'main' into pr-2fa-sensitive-settings
  • b31afdb Merge branch 'main' into pr-2fa-sensitive-settings
  • 92867d1 fix(lint): group third-party imports separately from local (goimports)

📊 Changes

7 files changed (+97 additions, -23 deletions)

View changed files

📝 frontend/src/api/queries/useAllSettings.ts (+9 -4)
📝 frontend/src/pages/settings/SecurityTab.tsx (+21 -9)
📝 frontend/src/pages/settings/SettingsPage.tsx (+2 -1)
📝 frontend/src/test/api-token-date.test.tsx (+1 -1)
📝 internal/web/controller/setting.go (+23 -6)
📝 internal/web/service/setting.go (+20 -2)
📝 internal/web/service/setting_security_test.go (+21 -0)

📄 Description

Summary

When two-factor auth is enabled, changing sensitive settings did not require a fresh 2FA confirmation. This adds a server-side re-2FA check on sensitive setting mutations, with the corresponding Security-tab UX.

Why

A hijacked session (or an unattended logged-in panel) could alter security-relevant settings without re-asserting the second factor. Gating sensitive changes on a fresh 2FA code restores the second-factor guarantee for the actions that matter most.

Scope

  • internal/web/service/setting.go + internal/web/controller/setting.go: server-side 2FA requirement on sensitive setting changes (server-side enforced, not just UI).
  • frontend/src/pages/settings/SecurityTab.tsx (+ SettingsPage / useAllSettings): prompt for the 2FA code on those changes.
  • internal/web/service/setting_security_test.go: coverage.

Validation

go test ./internal/web/service passes.

Risk

Low. Only adds a confirmation gate; non-sensitive settings and 2FA-disabled setups are unaffected.


🔄 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/5610 **Author:** [@n0ctal](https://github.com/n0ctal) **Created:** 6/27/2026 **Status:** ✅ Merged **Merged:** 6/28/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `pr-2fa-sensitive-settings` --- ### 📝 Commits (5) - [`b138d05`](https://github.com/MHSanaei/3x-ui/commit/b138d056df09e492329e87b8ec1f6564acd8874c) fix(settings): require server-side 2fa for sensitive changes - [`6d15f81`](https://github.com/MHSanaei/3x-ui/commit/6d15f812938eb3f3822051e0f3da44162c1b1cb9) Merge branch 'main' into pr-2fa-sensitive-settings - [`a23e6f3`](https://github.com/MHSanaei/3x-ui/commit/a23e6f3635a8dca6bb5f32cca314638a7b8f42f7) Merge branch 'main' into pr-2fa-sensitive-settings - [`b31afdb`](https://github.com/MHSanaei/3x-ui/commit/b31afdb2b12d6b35e46195205f4973328e9b5593) Merge branch 'main' into pr-2fa-sensitive-settings - [`92867d1`](https://github.com/MHSanaei/3x-ui/commit/92867d15a430d94f0a33708f9489d5a78cb38eff) fix(lint): group third-party imports separately from local (goimports) ### 📊 Changes **7 files changed** (+97 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/api/queries/useAllSettings.ts` (+9 -4) 📝 `frontend/src/pages/settings/SecurityTab.tsx` (+21 -9) 📝 `frontend/src/pages/settings/SettingsPage.tsx` (+2 -1) 📝 `frontend/src/test/api-token-date.test.tsx` (+1 -1) 📝 `internal/web/controller/setting.go` (+23 -6) 📝 `internal/web/service/setting.go` (+20 -2) 📝 `internal/web/service/setting_security_test.go` (+21 -0) </details> ### 📄 Description ## Summary When two-factor auth is enabled, changing sensitive settings did not require a fresh 2FA confirmation. This adds a server-side re-2FA check on sensitive setting mutations, with the corresponding Security-tab UX. ## Why A hijacked session (or an unattended logged-in panel) could alter security-relevant settings without re-asserting the second factor. Gating sensitive changes on a fresh 2FA code restores the second-factor guarantee for the actions that matter most. ## Scope - `internal/web/service/setting.go` + `internal/web/controller/setting.go`: server-side 2FA requirement on sensitive setting changes (server-side enforced, not just UI). - `frontend/src/pages/settings/SecurityTab.tsx` (+ SettingsPage / useAllSettings): prompt for the 2FA code on those changes. - `internal/web/service/setting_security_test.go`: coverage. ## Validation `go test ./internal/web/service` passes. ## Risk Low. Only adds a confirmation gate; non-sensitive settings and 2FA-disabled setups are unaffected. --- <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:06 +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#5928
No description provided.