Timing Attack in Google Authenticator - Per User Prompt
The plugin compares a submitted application password against the stored hash using a strict equality check, which leaks timing information. An attacker could brute force the application password through a timing attack and log in without the real password or a valid one-time token.
Originally disclosed on HackerOne
- Paid in 2 hours
- Disclosed after 13 days
Google Authenticator - Per User Prompt contains a timing attack vulnerability in how it validates the application password for a user account.
if ( sha1( $attempted_password_plaintext ) === $valid_password_hash || wp_check_password( $attempted_password_plaintext, $valid_password_hash ) ) {
$this->is_using_application_password = true;
return $user;
}
wp-content/plugins/google-authenticator-per-user-prompt/google-authenticator-per-user-prompt.php
As the above code runs on the authenticate hook, and uses a strict equality check, it's possible to brute force an application password using a timing attack and gain access to the account, without needing the real password or even a valid OTP token.
The plugin adds two authenticate hooks, one for the above app password check, then a second that does the OTP validation stuff, but only if the not using an app password. This means that we only need the app password to login, which we can brute force via timing attack.
if ( 'enabled' == trim( get_user_option( 'googleauthenticator_enabled', $user->ID ) ) && ! $this->is_using_application_password ) {
// ... OTP stuff
}
The correct way to check the app password is to use hash_equals(), which is safe from timing attacks - https://secure.php.net/manual/en/function.hash-equals.php
Example:
if ( hash_equals( sha1( $attempted_password_plaintext ), $valid_password_hash ) || ... {
It's worth noting that hash_equals() is already in use in Google_Authenticator_Per_User_Prompt::verify_login_nonce().
All accounts that have an app password enabled (which is not by default) are vulnerable to takeover using this method.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The application password was compared with a strict equality operator instead of a constant-time comparison function, so the check leaks timing information.
Impact
Any account with an application password enabled could be taken over via the timing attack, without the real password or a valid OTP token.
What the attacker needed
App password enabled on the account; ability to send many login attempts
The fix
The comparison should be replaced with a constant-time function such as hash_equals(), which the plugin already uses elsewhere.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
The plugin compares the password with a strict equality check, which can leak timing information. An attacker could measure delays to brute force the application password and log in without the real one.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.