Page MenuHomePhabricator

hCaptcha: Improve support for SiteKey verification
Closed, ResolvedPublic

Description

Summary

In T410024: ConfirmEdit hCaptcha: Verify sitekey in `siteverify` response was the sitekey given to the client as part of validating the captcha, we implemented code to restrict which SiteKey can be used by a client as part of a request. In doing so, we missed that API creations are using SiteKeys that won't map back to a value returned from getSiteKeyForAction().

Acceptance criteria

  • Functionality from T410024 remains in place
  • API account creation and editing is supported in a way that also restricts with SiteKey a request can send

Event Timeline

Change #1208333 had a related patch set uploaded (by Harroyo-wmf; author: Harroyo-wmf):

[mediawiki/extensions/ConfirmEdit@master] hCaptcha: Make site keys specific to the requested action take precedence

https://gerrit.wikimedia.org/r/1208333

Change #1210627 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[operations/mediawiki-config@master] hCaptcha: Define list of valid SiteKeys for createaccount trigger

https://gerrit.wikimedia.org/r/1210627

Change #1208333 merged by jenkins-bot:

[mediawiki/extensions/ConfirmEdit@master] hCaptcha: Allow providing a set of valid keys for site verify per action

https://gerrit.wikimedia.org/r/1208333

Change #1210737 had a related patch set uploaded (by Kosta Harlan; author: Harroyo-wmf):

[mediawiki/extensions/ConfirmEdit@wmf/1.46.0-wmf.3] hCaptcha: Allow providing a set of valid keys for site verify per action

https://gerrit.wikimedia.org/r/1210737

Change #1210771 had a related patch set uploaded (by Samuel (WMF); author: Samuel (WMF)):

[mediawiki/extensions/ConfirmEdit@master] hCaptcha: Clean up `getAllowedSiteKeysForCurrentAction`

https://gerrit.wikimedia.org/r/1210771

The main patch (ConfirmEdit #1208333) was reviewed and merged yesterday, a backport (ConfirmEdit #1210737) is scheduled, a patch updating config (mediawiki-config #1210627) exists and a follow-up (ConfirmEdit #1210771) is being reviewed now, so moving this ticket to In Review.

Change #1210627 merged by jenkins-bot:

[operations/mediawiki-config@master] hCaptcha: Define valid SiteKeys for account creation and edit triggers

https://gerrit.wikimedia.org/r/1210627

Change #1210737 merged by jenkins-bot:

[mediawiki/extensions/ConfirmEdit@wmf/1.46.0-wmf.3] hCaptcha: Allow providing a set of valid keys for site verify per action

https://gerrit.wikimedia.org/r/1210737

Mentioned in SAL (#wikimedia-operations) [2025-11-25T09:32:09Z] <kharlan@deploy2002> Started scap sync-world: Backport for [[gerrit:1210627|hCaptcha: Define valid SiteKeys for account creation and edit triggers (T410657)]], [[gerrit:1210737|hCaptcha: Allow providing a set of valid keys for site verify per action (T410657 T410863)]]

Mentioned in SAL (#wikimedia-operations) [2025-11-25T09:36:24Z] <kharlan@deploy2002> kharlan: Backport for [[gerrit:1210627|hCaptcha: Define valid SiteKeys for account creation and edit triggers (T410657)]], [[gerrit:1210737|hCaptcha: Allow providing a set of valid keys for site verify per action (T410657 T410863)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2025-11-25T09:43:12Z] <kharlan@deploy2002> Finished scap sync-world: Backport for [[gerrit:1210627|hCaptcha: Define valid SiteKeys for account creation and edit triggers (T410657)]], [[gerrit:1210737|hCaptcha: Allow providing a set of valid keys for site verify per action (T410657 T410863)]] (duration: 11m 03s)

Change #1210771 merged by jenkins-bot:

[mediawiki/extensions/ConfirmEdit@master] hCaptcha: Clean up `getAllowedSiteKeysForCurrentAction`

https://gerrit.wikimedia.org/r/1210771

Change #1211668 had a related patch set uploaded (by Harroyo-wmf; author: Harroyo-wmf):

[mediawiki/extensions/ConfirmEdit@master] hcaptcha: Persist the captcha consequence in the user session

https://gerrit.wikimedia.org/r/1211668

As per this comment, we will be adding support for carrying the "always challenge" sitekey into other pages when it is first triggered as the consequence from another, so that if an AbuseFilter first triggers the captcha when editing page A and then the user edits page B wthout solving A's captcha, a new captcha is shown when trying to save page B (i.e. the "Always challenge" key is used on the first load of page B's edit form).

Steps to reproduce:

  1. Make an edit that triggers the AbuseFilter
  2. Navigate to another page, and attempt to make an edit

Ideal behavior: Pressing submit shows the challenge
Actual behavior: The user sees "Please resubmit the form and complete the challenge to save your edit", and after resubmitting, sees the challenge

After recent changes introduced during the code review this is not working anymore: I've been able to send an edit, get redirected to the edit form, and then resubmit the form without actually being asked to solve a captcha (i.e. the "always challenge" key was not there the second time).

After recent changes introduced during the code review this is not working anymore: I've been able to send an edit, get redirected to the edit form, and then resubmit the form without actually being asked to solve a captcha (i.e. the "always challenge" key was not there the second time).

This was due to a misconfiguration in my local environment, moving back to Review.

Dreamy_Jazz subscribed.

(patch is currently in work in progress, so moving back to in progress)

The patch was marked as WiP while addressing things raised during the code review.

Right now, all threads there have been solved, and tests are passing again in Jenkins. Therefore, moving this back to Review.

Change #1211668 merged by jenkins-bot:

[mediawiki/extensions/ConfirmEdit@master] hCaptcha: Persist the captcha consequence in the user session

https://gerrit.wikimedia.org/r/1211668

Change #1215234 had a related patch set uploaded (by Kosta Harlan; author: Harroyo-wmf):

[mediawiki/extensions/ConfirmEdit@wmf/1.46.0-wmf.5] hCaptcha: Persist the captcha consequence in the user session

https://gerrit.wikimedia.org/r/1215234

Change #1215234 merged by jenkins-bot:

[mediawiki/extensions/ConfirmEdit@wmf/1.46.0-wmf.5] hCaptcha: Persist the captcha consequence in the user session

https://gerrit.wikimedia.org/r/1215234

Mentioned in SAL (#wikimedia-operations) [2025-12-04T19:19:00Z] <kharlan@deploy2002> Started scap sync-world: Backport for [[gerrit:1215234|hCaptcha: Persist the captcha consequence in the user session (T410657)]]

Mentioned in SAL (#wikimedia-operations) [2025-12-04T19:21:02Z] <kharlan@deploy2002> kharlan: Backport for [[gerrit:1215234|hCaptcha: Persist the captcha consequence in the user session (T410657)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2025-12-04T19:30:15Z] <kharlan@deploy2002> Finished scap sync-world: Backport for [[gerrit:1215234|hCaptcha: Persist the captcha consequence in the user session (T410657)]] (duration: 11m 16s)