404 on user password form after being forced to set up TFA with 0 attempts left

Created on 29 December 2017, over 7 years ago
Updated 26 May 2025, 13 days ago

Problem/Motivation

When a user logs in and is prompted to set up TFA, having exhausted all of their login attempts, the user is not logged in, but is redirected to tfa/locked/UID/HASH, where the situation is explained. A "Set up application" link is provided for the user. When the user clicks this link, the user is directed to a password form, to authenticate prior to setting up TFA. When providing a password and clicking "Confirm", the user is given a 404, regardless of whether or not the password is correct.

Proposed resolution

Fix the issue by correcting form validation logic, making sure to check the password before giving a 404 error.

To be more specific, the validation for the form in tfa/src/Form/BasicSetup.php (BasicSetup->validateForm) checks for whether the account UID matches the current user's UID. This logic won't work as the current user hasn't been logged in yet. We can't allow the user to be logged in because we have to force TFA authentication setup (there are 0 login attempts left). Since the user is not logged in, the current user's UID is 0 (anonymous). This effectively prevents non admin users from ever setting up their TFA when there are 0 login attempts left.

Remaining tasks

Provide patch, test, merge.

User interface changes

None

API changes

N/A

Data model changes

N/A

Original report by ryanissamson

N/A

πŸ› Bug report
Status

Closed: works as designed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States ryan.ryan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024