[PR #2576] [MERGED] fix(security): persist TOTP lockout across login rollback #5743

Closed
opened 2026-04-16 13:50:58 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-vikunja/vikunja/pull/2576
Author: @tink-bot
Created: 4/9/2026
Status: Merged
Merged: 4/9/2026
Merged by: @kolaente

Base: mainHead: fix-totp-lockout-rollback


📝 Commits (3)

  • cfb1bd4 fix(security): persist TOTP lockout across login rollback
  • 61ad911 test(user): cover TOTP lockout persistence and password-reset unlock
  • 18d38b5 test(webtests): add end-to-end TOTP lockout test

📊 Changes

4 files changed (+170 additions, -21 deletions)

View changed files

📝 pkg/routes/api/v1/login.go (+6 -2)
📝 pkg/user/totp.go (+48 -19)
📝 pkg/user/totp_test.go (+69 -0)
📝 pkg/webtests/login_test.go (+47 -0)

📄 Description

The 10-attempt TOTP lockout never fired: HandleFailedTOTPAuth wrote StatusAccountLocked on the login handler's xorm session, which was then unconditionally rolled back, leaving accounts open to brute-force once the password was known.

HandleFailedTOTPAuth now owns its own transaction and commits the lockout (and the attempt-3 warning notification) independently of the caller. The login handler rolls its own session back before invoking it so the two transactions do not contend for the users-table write lock on SQLite shared-cache. The attempt counter continues to live in the keyvalue store.

Fixes GHSA-fgfv-pv97-6cmj.


🔄 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/go-vikunja/vikunja/pull/2576 **Author:** [@tink-bot](https://github.com/tink-bot) **Created:** 4/9/2026 **Status:** ✅ Merged **Merged:** 4/9/2026 **Merged by:** [@kolaente](https://github.com/kolaente) **Base:** `main` ← **Head:** `fix-totp-lockout-rollback` --- ### 📝 Commits (3) - [`cfb1bd4`](https://github.com/go-vikunja/vikunja/commit/cfb1bd440bff6d359bd4360bb540772bc4e9fac0) fix(security): persist TOTP lockout across login rollback - [`61ad911`](https://github.com/go-vikunja/vikunja/commit/61ad911c305f11c46e61c66983caa46689b9b52c) test(user): cover TOTP lockout persistence and password-reset unlock - [`18d38b5`](https://github.com/go-vikunja/vikunja/commit/18d38b5489bf7306345d7d81fd94a7c29669bd25) test(webtests): add end-to-end TOTP lockout test ### 📊 Changes **4 files changed** (+170 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `pkg/routes/api/v1/login.go` (+6 -2) 📝 `pkg/user/totp.go` (+48 -19) 📝 `pkg/user/totp_test.go` (+69 -0) 📝 `pkg/webtests/login_test.go` (+47 -0) </details> ### 📄 Description The 10-attempt TOTP lockout never fired: `HandleFailedTOTPAuth` wrote `StatusAccountLocked` on the login handler's xorm session, which was then unconditionally rolled back, leaving accounts open to brute-force once the password was known. `HandleFailedTOTPAuth` now owns its own transaction and commits the lockout (and the attempt-3 warning notification) independently of the caller. The login handler rolls its own session back before invoking it so the two transactions do not contend for the users-table write lock on SQLite shared-cache. The attempt counter continues to live in the keyvalue store. Fixes GHSA-fgfv-pv97-6cmj. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-16 13:50:58 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/vikunja#5743