Skip to content

security: reject failed reCAPTCHA verifications - #675

Open
obaidur-dev wants to merge 1 commit into
sergix44:3.xfrom
obaidur-dev:security/recaptcha-verification
Open

obaidur-dev wants to merge 1 commit into
sergix44:3.xfrom
obaidur-dev:security/recaptcha-verification

Conversation

@obaidur-dev

Copy link
Copy Markdown

AuthController::checkRecaptcha() refuses a request only when the verification succeeded with a score below 0.5:

if ($recaptcha->success && $recaptcha->score < 0.5) {

When Google answers success: false, which it does for a forged, expired, replayed or missing token, the condition is false and the login, registration or password recovery request goes through. The check also fails open when the verification endpoint cannot be reached.

This change:

  • requires a successful verification with an acceptable score,
  • rejects a missing or unparsable answer,
  • URL-encodes the secret and the token before they are put in the verification URL.

Affected release: 3.8.2, app/Controllers/Auth/AuthController.php lines 16 to 23.

Test

tests/Feature/Auth/RecaptchaVerificationTest.php fakes the verification endpoint with a local stream wrapper (tests/Support/RecaptchaResponseStream.php), so no request leaves the machine. It covers a failed verification, a low score, an unreachable endpoint and a successful verification.

Before the fix 2 of the 4 tests fail: the failed verification is accepted and the unreachable endpoint returns 500. After the fix all 4 pass.

git apply pr.patch
composer install
vendor/bin/phpunit

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant