recaptcha validation bypassed for AJAX requests
-
As the title states, validation is entirely bypassed if the request is made via an AJAX call.
This exact issue was raised by Arlind here, 1 year ago: https://ww.wp.xz.cn/support/topic/bypassed-validation-via-admin-ajax-php/
For anyone attempting to validate a form via an AJAX POST call, the validation is entirely bypassed due to the first few lines ofgglcptch_is_recaptcha_required:if ( wp_is_json_request() ) {
return false;
}The above check sees the JSON header that AJAX appends to the request and then the reCAPTCHA validation that this plugin provides is entirely skipped on that grounds alone. That means that
gglcptch_verify_recaptchareturns true despite no validation check being done, even when the user should not reasonably be able to submit the form.
I have set up my form to be validated using a POST request via AJAX, returning the correct redirect url (only if reCAPTCHA is validated) and submitting the form accordingly. This is not an uncommon use case to prevent form submission/page refresh prior to reCAPTCHA validation. I would recommend removing the above JSON request bypass entirely. If, however, it is included in your plugin for a good reason then I would recommend you make this bypass very clear to users of your plugin, lest they be unaware their reCAPTCHA via AJAX is silently being bypassed.
The topic ‘recaptcha validation bypassed for AJAX requests’ is closed to new replies.