[PR #3884] [MERGED] feat: mask password in telegram notification on 2FA failure #5548

Closed
opened 2026-10-31 20:47:44 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/3884
Author: @rydve
Created: 3/4/2026
Status: ✅ Merged
Merged: 3/4/2026
Merged by: @MHSanaei

Base: main ← Head: tgbot_2fa_issue_psswd_compromised


📝 Commits (1)

  • fe5e09b feat: mask password in telegram notification on 2FA failure

📊 Changes

15 files changed (+33 additions, -13 deletions)

View changed files

📝 web/controller/index.go (+11 -2)
📝 web/service/user.go (+9 -11)
📝 web/translation/translate.ar_EG.toml (+1 -0)
📝 web/translation/translate.en_US.toml (+1 -0)
📝 web/translation/translate.es_ES.toml (+1 -0)
📝 web/translation/translate.fa_IR.toml (+1 -0)
📝 web/translation/translate.id_ID.toml (+1 -0)
📝 web/translation/translate.ja_JP.toml (+1 -0)
📝 web/translation/translate.pt_BR.toml (+1 -0)
📝 web/translation/translate.ru_RU.toml (+1 -0)
📝 web/translation/translate.tr_TR.toml (+1 -0)
📝 web/translation/translate.uk_UA.toml (+1 -0)
📝 web/translation/translate.vi_VN.toml (+1 -0)
📝 web/translation/translate.zh_CN.toml (+1 -0)
📝 web/translation/translate.zh_TW.toml (+1 -0)

📄 Description

What is the pull request?

This PR improves security by masking the user's password in Telegram login notifications when a two-factor authentication (2FA) failure occurs.
Previously, if a user entered a correct password but an incorrect 2FA code, the system would treat it as a failed login and send the actual (correct) password to the Telegram bot. This could lead to sensitive data being stored in Telegram chat history.

Changes:

  • Updated UserService.CheckUser to return specific errors for credential vs. 2FA failures.

  • Modified IndexController.login to detect 2FA errors and replace the password with a masked string *** (2FA Failed) in the Telegram notification.

  • Added localized strings for 2faFailed across all supported languages in TOML files.

Resolves: #3058

Which part of the application is affected by the change?

  • Frontend
  • Backend

Type of Changes

  • Bug fix
  • New feature
  • Refactoring
  • Other

Screenshots

Before (incorrect 2FA, correct login and password):

image

After:

image

🔄 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/3884 **Author:** [@rydve](https://github.com/rydve) **Created:** 3/4/2026 **Status:** ✅ Merged **Merged:** 3/4/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `tgbot_2fa_issue_psswd_compromised` --- ### 📝 Commits (1) - [`fe5e09b`](https://github.com/MHSanaei/3x-ui/commit/fe5e09b555543e44f756c9c6c2bbd857e51777a2) feat: mask password in telegram notification on 2FA failure ### 📊 Changes **15 files changed** (+33 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `web/controller/index.go` (+11 -2) 📝 `web/service/user.go` (+9 -11) 📝 `web/translation/translate.ar_EG.toml` (+1 -0) 📝 `web/translation/translate.en_US.toml` (+1 -0) 📝 `web/translation/translate.es_ES.toml` (+1 -0) 📝 `web/translation/translate.fa_IR.toml` (+1 -0) 📝 `web/translation/translate.id_ID.toml` (+1 -0) 📝 `web/translation/translate.ja_JP.toml` (+1 -0) 📝 `web/translation/translate.pt_BR.toml` (+1 -0) 📝 `web/translation/translate.ru_RU.toml` (+1 -0) 📝 `web/translation/translate.tr_TR.toml` (+1 -0) 📝 `web/translation/translate.uk_UA.toml` (+1 -0) 📝 `web/translation/translate.vi_VN.toml` (+1 -0) 📝 `web/translation/translate.zh_CN.toml` (+1 -0) 📝 `web/translation/translate.zh_TW.toml` (+1 -0) </details> ### 📄 Description ## What is the pull request? This PR improves security by masking the user's password in Telegram login notifications when a two-factor authentication (2FA) failure occurs. Previously, if a user entered a correct password but an incorrect 2FA code, the system would treat it as a failed login and send the actual (correct) password to the Telegram bot. This could lead to sensitive data being stored in Telegram chat history. Changes: - Updated UserService.CheckUser to return specific errors for credential vs. 2FA failures. - Modified IndexController.login to detect 2FA errors and replace the password with a masked string *** (2FA Failed) in the Telegram notification. - Added localized strings for 2faFailed across all supported languages in TOML files. Resolves: #3058 ## Which part of the application is affected by the change? - [ ] Frontend - [x] Backend ## Type of Changes - [x] Bug fix - [ ] New feature - [ ] Refactoring - [ ] Other ## Screenshots ### Before (incorrect 2FA, correct login and password): <img width="304" height="150" alt="image" src="https://github.com/user-attachments/assets/b68d001a-b317-44e3-9c0f-38c26601664b" /> ### After: <img width="325" height="161" alt="image" src="https://github.com/user-attachments/assets/b7243c6d-5a4f-4c35-b6d1-3edcc2704d56" /> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 20:47:44 +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#5548
No description provided.