Page MenuHomePhabricator

ConfirmEdit/reCAPTCHA & hCaptcha won't work.
Closed, DeclinedPublicBUG REPORT

Assigned To
None
Authored By
Epopen
Jun 28 2021, 7:17 AM
Referenced Files
F34885612: image.png
Dec 16 2021, 3:36 AM
F34885552: image.png
Dec 16 2021, 2:27 AM
F34884554: issue1.png
Dec 15 2021, 6:33 AM
F34884555: issue2.png
Dec 15 2021, 6:33 AM
F34650613: 未命名.jpg
Sep 22 2021, 7:40 AM
F34529588: createUser_ReCaptchaNoCaptcha_fail.png
Jun 28 2021, 7:17 AM
F34529630: contenpage_QuestyCaptcha.png
Jun 28 2021, 7:17 AM
F34529581: createUser_ReCaptchaNoCaptcha.png
Jun 28 2021, 7:17 AM

Description

Hi All
I am newbie in wikimedia come from Taiwan.
Poor English sorry.

List of steps to reproduce (step by step, including full links if applicable):

  • Retrieved both public and secret key from the Google "ReCaptcha admin panel".
  • Create a mediawiki environment with ConfirmEdit/reCAPTCHA as below
wfLoadExtensions([ 'ConfirmEdit', 'ConfirmEdit/ReCaptchaNoCaptcha' ]);
$wgCaptchaClass = 'ReCaptchaNoCaptcha';
$wgCaptchaTriggers['edit'] = true;
$wgCaptchaTriggers['create'] = true;
$wgCaptchaTriggers['createaccount'] = true;
$wgReCaptchaSiteKey = '6LdIiS....2i7G30gRHXE'; 
$wgReCaptchaSecretKey = '6LdIiSYTAAAA....kUABd';
$wgMainCacheType = CACHE_ANYTHING;  <-- Detail in other information as below...
  • Open wiki page, and enter "Create account" page
  • Click button of "Create your account" and got error (Error message mean: "Incorrect or missing CAPTCHA.")

createUser_ReCaptchaNoCaptcha_fail.png (332×74 px, 4 KB)

What happens?:
In "Create account" page, reCAPTCHA can't be displayed in red square (Button "建立您的帳號 = Create your account").

createUser_ReCaptchaNoCaptcha.png (314×100 px, 14 KB)

What should have happened instead?:
Users can see reCAPTCHA and can create account normally.

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc:
OS: FreeBSD 13.0-Release amd64, Mediawiki: 1.35.2, PHP: 7.4.19

  • About ReCaptcha: Using v2 and firewall opening HTTP port from server to internet(Google).
  • hCaptcha same issue!
  • About $wgMainCacheType, because I using "memcached", therefore assign "CACHE_MEMCACHED" for test, got same failed.
  • For installation confirm, therefore tested "ConfirmEdit/QuestyCaptcha" as below
    • Configure in Localsetting.php as below
wfLoadExtensions([ 'ConfirmEdit', 'ConfirmEdit/QuestyCaptcha' ]);
$wgCaptchaQuestions = [
      'What is the capital of France?' => 'Paris',
      'What is the capital of Spain' => 'MADRID', // Answers are case insensitive
];
  • Open wiki page, and enter "Create account" page, "QuestyCaptcha" can be displayed as below.

createUser_QuestyCaptcha.png (308×165 px, 17 KB)

    • Click button of "建立您的帳號 = Create your account" and Create account successful.
  • Because I using Extension:ContactPage and wish cooperate with ConfirmEdit, therefore tested and result as below
    • ConfirmEdit/reCAPTCHA
      • reCAPTCHA can't be displayed in red square

contenpage_ReCaptchaNoCaptcha.png (392×136 px, 9 KB)

  • Click button of "寄出 = Send" and got fail as below (Error test mean: Fatal exception of type: "RumtimeExpection").

contenpage_ReCaptchaNoCaptcha_submitFail.png (633×125 px, 18 KB)

  • ConfirmEdit/QuestyCaptcha
    • QuestyCaptcha can be displayed in red square

contenpage_QuestyCaptcha.png (451×157 px, 13 KB)

  • Click button of "寄出 = Send" and sent successful.

Event Timeline

Epopen renamed this task from ConfirmEdit/reCAPTCHA won't work. to ConfirmEdit/reCAPTCHA & hCaptcha won't work..Jul 8 2021, 1:39 AM
Epopen updated the task description. (Show Details)

For the Runtime exception:

For information on debugging (including viewing errors), see https://mediawiki.org/wiki/Manual:How_to_debug . A list of related configuration variables is at https://mediawiki.org/wiki/Manual:Configuration_settings#Debug.2Flogging Also see https://mediawiki.org/wiki/Manual:Errors_and_symptoms

For the Runtime exception:

For information on debugging (including viewing errors), see https://mediawiki.org/wiki/Manual:How_to_debug . A list of related configuration variables is at https://mediawiki.org/wiki/Manual:Configuration_settings#Debug.2Flogging Also see https://mediawiki.org/wiki/Manual:Errors_and_symptoms

Thanks you a lot.
But server down unexpected from last week.
Therefore debug it if server online.

Hi Reedy

Sorry long time server-down due hardware damaged.
After new hardware setup, can be debug continue..

Follow your suggestion, debug added as below

  • LocalSettings.php
    • error_reporting( -1 );
    • ini_set( 'display_errors', 1 );
    • $wgShowExceptionDetails = true;
    • $wgShowExceptionDetails = true;
    • $wgDebugToolbar = true;
    • $wgShowDebug = true;
  • php.ini
    • error_reporting = E_ALL
    • display_errors = On

Test case: Create account.
After create account, got debug data (keyword: captcha) as below..

[DBQuery] LCStoreDB::get [0s] sql.epopen.com: SELECT lc_value FROM `wiki_l10n_cache` WHERE lc_lang = 'zh-tw' AND lc_key = 'messages:captcha-ip-whitelist' LIMIT 1
[captcha] Captcha shown on account creation for 60.251.70.131
[DBQuery] LCStoreDB::get [0s] sql.epopen.com: SELECT lc_value FROM `wiki_l10n_cache` WHERE lc_lang = 'zh-tw' AND lc_key = 'messages:renocaptcha-createaccount' LIMIT 1
[captcha] Captcha submitted on account creation for Test
[authentication] MediaWiki\Auth\AuthManager::continueAccountCreation: Fail in pre-authentication by CaptchaPreAuthenticationProvider
[captcha] Captcha shown on account creation for 60.251.70.131
[DBQuery] LCStoreDB::get [0s] sql.epopen.com: SELECT lc_value FROM `wiki_l10n_cache` WHERE lc_lang = 'zh-tw' AND lc_key = 'messages:createacct-imgcaptcha-help' LIMIT 1
[DBQuery] LCStoreDB::get [0s] sql.epopen.com: SELECT lc_value FROM `wiki_l10n_cache` WHERE lc_lang = 'zh-tw' AND lc_key = 'messages:captcha-createaccount-fail' LIMIT 1

Test case: ContactPage
After click button of "寄出 = Send", got exception as below..

[d4c9cb5b5c580b54fe84ea83] /index.php?title=%E7%89%B9%E6%AE%8A:%E8%81%AF%E7%B5%A1 RuntimeException from line 119 of /home/www/www.epopen.com/vendor/guzzlehttp/guzzle/src/functions.php: GuzzleHttp requires cURL, the allow_url_fopen ini setting, or a custom HTTP handler.

Backtrace:

#0 /home/www/www.epopen.com/vendor/guzzlehttp/guzzle/src/HandlerStack.php(42): GuzzleHttp\choose_handler()
#1 /home/www/www.epopen.com/includes/http/GuzzleHttpRequest.php(164): GuzzleHttp\HandlerStack::create(NULL)
#2 /home/www/www.epopen.com/extensions/ConfirmEdit/ReCaptchaNoCaptcha/includes/ReCaptchaNoCaptcha.php(129): GuzzleHttpRequest->execute()
#3 /home/www/www.epopen.com/extensions/ConfirmEdit/SimpleCaptcha/SimpleCaptcha.php(1031): ReCaptchaNoCaptcha->passCaptcha(string, NULL)
#4 /home/www/www.epopen.com/extensions/ContactPage/includes/SpecialContact.php(283): SimpleCaptcha->passCaptchaFromRequest(WebRequest, User)
#5 /home/www/www.epopen.com/includes/htmlform/HTMLForm.php(707): SpecialContact->processInput(array, OOUIHTMLForm)
#6 /home/www/www.epopen.com/includes/htmlform/HTMLForm.php(597): HTMLForm->trySubmit()
#7 /home/www/www.epopen.com/includes/htmlform/HTMLForm.php(613): HTMLForm->tryAuthorizedSubmit()
#8 /home/www/www.epopen.com/extensions/ContactPage/includes/SpecialContact.php(237): HTMLForm->show()
#9 /home/www/www.epopen.com/includes/specialpage/SpecialPage.php(600): SpecialContact->execute(NULL)
#10 /home/www/www.epopen.com/includes/specialpage/SpecialPageFactory.php(635): SpecialPage->run(NULL)
#11 /home/www/www.epopen.com/includes/MediaWiki.php(307): MediaWiki\SpecialPage\SpecialPageFactory->executePath(Title, RequestContext)
#12 /home/www/www.epopen.com/includes/MediaWiki.php(940): MediaWiki->performRequest()
#13 /home/www/www.epopen.com/includes/MediaWiki.php(543): MediaWiki->main()
#14 /home/www/www.epopen.com/index.php(53): MediaWiki->run()
#15 /home/www/www.epopen.com/index.php(46): wfIndexMain()
#16 {main}

Got debug data (keyword: captcha) as below

[DBQuery] LCStoreDB::get [0s] sql.epopen.com: SELECT lc_value FROM `wiki_l10n_cache` WHERE lc_lang = 'zh-tw' AND lc_key = 'messages:captcha-label' LIMIT 1

Checking line 119 of functions.php as below

function choose_handler()
{
    $handler = null;
    if (function_exists('curl_multi_exec') && function_exists('curl_exec')) {
        $handler = Proxy::wrapSync(new CurlMultiHandler(), new CurlHandler());
    } elseif (function_exists('curl_exec')) {
        $handler = new CurlHandler();
    } elseif (function_exists('curl_multi_exec')) {
        $handler = new CurlMultiHandler();                                                                                                                                                             
    }

    if (ini_get('allow_url_fopen')) {
        $handler = $handler
            ? Proxy::wrapStreaming($handler, new StreamHandler())
            : new StreamHandler();
    } elseif (!$handler) {
        throw new \RuntimeException('GuzzleHttp requires cURL, the '
            . 'allow_url_fopen ini setting, or a custom HTTP handler.');
    }

    return $handler;
}

Follow code, I tried to do below

  • Install PHP curl extensions
  • Add 'allow_url_fopen = On' @ php.ini

Test case: Create account.
After create account, problem still, got debug data (keyword: captcha) as below..

[DBQuery] LCStoreDB::get [0s] sql.epopen.com: SELECT lc_value FROM `wiki_l10n_cache` WHERE lc_lang = 'zh-tw' AND lc_key = 'messages:captcha-ip-whitelist' LIMIT 1
[captcha] Captcha shown on account creation for 60.251.70.131
[DBQuery] LCStoreDB::get [0s] sql.epopen.com: SELECT lc_value FROM `wiki_l10n_cache` WHERE lc_lang = 'zh-tw' AND lc_key = 'messages:renocaptcha-createaccount' LIMIT 1
[captcha] Captcha submitted on account creation for Test2
[authentication] MediaWiki\Auth\AuthManager::continueAccountCreation: Fail in pre-authentication by CaptchaPreAuthenticationProvider
[captcha] Captcha shown on account creation for 60.251.70.131
[DBQuery] LCStoreDB::get [0s] sql.epopen.com: SELECT lc_value FROM `wiki_l10n_cache` WHERE lc_lang = 'zh-tw' AND lc_key = 'messages:createacct-imgcaptcha-help' LIMIT 1
[DBQuery] LCStoreDB::get [0s] sql.epopen.com: SELECT lc_value FROM `wiki_l10n_cache` WHERE lc_lang = 'zh-tw' AND lc_key = 'messages:captcha-createaccount-fail' LIMIT 1

Test case: ContactPage
After click button of "寄出 = Send", RuntimeException disappeared, but new error message(CAPTCHA 錯誤 = CAPTCHA error @ red square) screen shown instead as below.

未命名.jpg (761×882 px, 24 KB)

And got debug data (keyword: captcha) as below

[DBQuery] LCStoreDB::get [0s] sql.epopen.com: SELECT lc_value FROM `wiki_l10n_cache` WHERE lc_lang = 'zh-tw' AND lc_key = 'messages:captcha-label' LIMIT 1
[captcha] Unable to validate response: http-curl-error
[DBQuery] LCStoreDB::get [0s] sql.epopen.com: SELECT lc_value FROM `wiki_l10n_cache` WHERE lc_lang = 'zh-tw' AND lc_key = 'messages:contactpage-captcha-error' LIMIT 1

Connect to Google fail look like.
But outgoing HTTPS pass @ firewall and no more information....

How next debug procedure?
Thanks you a lot.

What can you see in your browser console when reCAPTCHA can't be displayed?

Hi @Func

Yes, I can see something in my browser console.
Because I do not know get complete information for you, therefore take by screen capture.

issue1.png (1,830×975 px, 304 KB)

issue2.png (1,843×329 px, 119 KB)

These information generated when I entered the ConfirmEdit page as above comment.

Thanks you a lot.

Because I do not know get complete information for you, therefore take by screen capture.
These information generated when I entered the ConfirmEdit page.

Which page did you get these outputs on? I noticed that the ContactPage extension use ooui which ComfirmEdit didn't support officially.
Maybe you can check the console output when creating an account first, that problem would be easier to solve.
(Your site is not configured to be registerable, otherwise I can try it myself.)

Because I do not know get complete information for you, therefore take by screen capture.
These information generated when I entered the ConfirmEdit page.

Which page did you get these outputs on? I noticed that the ContactPage extension use ooui which ComfirmEdit didn't support officially.
Maybe you can check the console output when creating an account first, that problem would be easier to solve.
(Your site is not configured to be registerable, otherwise I can try it myself.)

Thanks you.
I am sorry, above of "entered the ConfirmEdit page" is mistake,
Corrected as "entered page of generated as Extension:ContactPage"

I enabled function of user register as below

  • $wgGroupPermissions['*' ]['createaccount'] = true;
  • $wgCaptchaTriggers['createaccount'] = true;

Please visit my site as https://www.epopen.com to try it.

Thanks your very much.

@Epopen It seems you have a very strict CSP (Content Security Policy). Please check your config for any $wgCSP* items.

@Epopen It seems you have a very strict CSP (Content Security Policy). Please check your config for any $wgCSP* items.

Hi @Func

First, thanks your big help.

About reCAPTCHA
Have not any $wgCSP* items in config.
But apache server config has as below

Header always set Content-Security-Policy "default-src 'self';"

reCAPTCHA shown after the Content-Security-Policy comment out as below

image.png (359×240 px, 32 KB)

But got error when submit of user registration as

CAPTCHA verification failed due to internal error: http

Note: http port traffic pass @ firewall
I will debug continue.

  1. Can you teach me skill of debug? (I got some 'Content Security Policy: Ignoring “'unsafe-inline'” within script-src: ‘strict-dynamic’ specified' in browser console, tracking.)
  2. Config suggestation about $wgCSP* even "default-src 'self';" @ server config?

About hCaptcha, it still won't work.

Thanks you very much.

@Epopen
According to the document, you can set a file to hold the debug log. Search for Unable to validate response in that file and see what happened.
hCaptcha is quite similar to reCaptcha, it should be able to show up now, right?

For configuration issues, support desk of mediawiki.org is more suitable than here. There are also many useful documents for site admins.
If you want to dig into source code, you can refer to doc.wikimedia.org (mediawiki core) or click the link of "browse repository" in extension page. There is also a source code search engine.

@Epopen
According to the document, you can set a file to hold the debug log. Search for Unable to validate response in that file and see what happened.
hCaptcha is quite similar to reCaptcha, it should be able to show up now, right?

For configuration issues, support desk of mediawiki.org is more suitable than here. There are also many useful documents for site admins.
If you want to dig into source code, you can refer to doc.wikimedia.org (mediawiki core) or click the link of "browse repository" in extension page. There is also a source code search engine.

Hi @Func

Short answer about hCaptcha
In config file as below

  • wfLoadExtensions( array( 'ConfirmEdit', 'ConfirmEdit/hCaptcha' ) );
  • $wgHCaptchaSiteKey = 'fddf5fa1-8646-....';
  • $wgHCaptchaSecretKey = '0x6A5dCC14088....';

Result: Able to show up ( not able to show up before 3 minutes)

Thanks a lot.