The login CAPTCHA provided by the All In One WP Security & Firewall plugin can be circumvented in multiple ways, allowing an attacker to automate login attempts when the CAPTCHA is enabled.
For feedback or questions about this advisory mail us at sumofpwn at securify.nl
This issue has been found during the Summer of Pwnage hacker event, running from July 1-29. A community summer event in which a large group of security bughunters (worldwide) collaborate in a month of security research on Open Source Software (WordPress this time). For fun. The event is hosted by Securify in Amsterdam.
These issues were successfully tested on the All In One WP Security & Firewall WordPress Plugin version 4.1.2.
The first two findings are resolved in the All In One WP Security & Firewall plugin version 4.1.3.
All In One WP Security & Firewall is a comprehensive, user-friendly, all in one security and firewall plugin for WordPress. One of its options is a login CAPTCHA to prevent automated login attempts. Multiple vulnerabilities exist, allowing an attacker to circumvent the CAPTCHA mechanism.
When the login CAPTCHA is enabled, the plugin will check if the user provided a CAPTCHA answer. If so, the answer will be checked for validity. However, the code does not account for the case where no CAPTCHA answer is provided. If no answer is sent, the login will continue as normal, even though the CAPTCHA setting is enabled.
The vulnerable code is located in wp-security-user-login.php:
//Check if captcha enabled
if ($aio_wp_security->configs->get_value('aiowps_enable_login_captcha') == '1')
if (array_key_exists('aiowps-captcha-answer', $_POST)) //If the login form with captcha was submitted then do some processing
[.. captcha logic ..]
[.. missing else statement ..]
The CAPTCHA answers leak the secret key used to create valid answers. By extracting the secret keys it's possible to forge valid CAPTCHA answers.
The vulnerable code is located at /classes/wp-security-captcha.php:
//Let's encode correct answer
$captcha_secret_string = $aio_wp_security->configs->get_value('aiowps_captcha_secret_key');
$current_time = time();
$enc_result = base64_encode($current_time.$captcha_secret_string.$result);
$equation_string .= '<input type="hidden" name="aiowps-captcha-string-info" id="aiowps-captcha-string-info" value="'.$enc_result.'" />';
$equation_string .= '<input type="hidden" name="aiowps-captcha-temp-string" id="aiowps-captcha-temp-string" value="'.$current_time.'" />';
$equation_string .= '<input type="text" size="2" id="aiowps-captcha-answer" name="aiowps-captcha-answer" value="" />';
The CAPTCHA form adds three fields to the login form:
aiowps-captcha-string-info - A timestamp, a secret CAPTCHA key and the valid answer, base64 encoded
aiowps-captcha-temp-string - The timestamp
aiowps-captcha-answer - Answer to be filled in by the user
For validating the correct answer, aiowps-captcha-string-info is checked against the timestamp provided by the user, combined with the answer provided by the user and the secret CAPTCHA key (base64 encoded).
By decoding the value for aiowps-captcha-string-info, a user can extract the secret key and create valid answers.
The CAPTCHA mechanism (which is described above) is created in such a way that the CAPTCHA answer never expires. A valid answer can be re-used, allowing automated login attempts.
Math questions created by the login CAPTCHA are not obfuscated in any way. The math questions (such as "five + 2") can easily be parsed by a program to generate valid answers.
1. Enable the login CAPTCHA and remove the aiowps-captcha-answer parameter from the POST request. The login will succeed as normal.
2. Base64 decode the hidden field aiowps-captcha-string-info to obtain the CAPTCHA secret and a valid answer.
3. Send two login attempt with the same (valid) aiowps-captcha-string-info, aiowps-captcha-temp-string and aiowps-captcha-answer parameters. The login attempt will be accepted.
4. A programmer can use the array from the number_word_mapping method to evaluate the questions created by the CAPTCHA.