简体   繁体   English

PHP cURL Google reCaptcha2标头注入

[英]PHP cURL Google reCaptcha2 Header Injection

i have some Trouble with cURL and Google reCaptcha2 to avoid "Robot" & "Spammer" Auto-Reg´s. 我在使用cURL和Google reCaptcha2时遇到了一些麻烦,以避免使用“机器人”和“垃圾邮件发送者”自动注册。

So i Chose google´s reCaptcha2 to check the User´s on WWW Site . 因此,我选择Google的reCaptcha2来检查WWW网站上的用户。

The Problem: 问题:

after checking the code, i found there is an Header Injection in 'curl_setopt_array' via '$curlConfig' 检查代码后,我发现Header Injection in 'curl_setopt_array' via '$curlConfig'有一个Header Injection in 'curl_setopt_array' via '$curlConfig'

My Serverside reCaptcha using cURL because of PHP File getContent blocked by PHP Config. 我的服务器端reCaptcha使用cURL,因为PHP File getContent被PHP Config阻止了。

My reCaptcha Code: 我的验证码:

if (isset($_POST['g-recaptcha-response'])) {
$captcha = $_POST['g-recaptcha-response'];
$privatekey = '######### Priv Key ###############';
$url = 'https://www.google.com/recaptcha/api/siteverify';
$data = array(
    'secret' => $privatekey,
    'response' => $captcha,
    'remoteip' => $_SERVER['REMOTE_ADDR']
);



$curlConfig = array(
    CURLOPT_URL => $url,
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS => $data
);

$ch = curl_init();
curl_setopt_array($ch, $curlConfig);
$response = curl_exec($ch);
curl_close($ch);}

So, as result we decode the data from json String back: 因此,结果是我们将json字符串中的数据解码回去:

$jsonResponse = json_decode($response);
if ($jsonResponse->success == "true") { Good } else { Exit not good! }

The Injection ? 注射? Data= Array ? 数据=数组 $Serve ? $ Serve?

thanks for help 感谢帮助

i don't see any code injection vulnerabilities here, but you don't show us how you handle the event of no g-recaptcha-response being in the POST request at all. 我在这里没有看到任何代码注入漏洞,但是您没有向我们展示如何处理POST请求中根本没有g-recaptcha-response的事件。 most likely, you don't handle that event, and all an hacker needs to do, to get past your captcha, is to not send the g-recaptcha-response field at all. 最有可能的是,您不处理该事件,黑客要做的就是越过验证码,就是根本不发送g-recaptcha-response字段。 instead of if (isset($_POST['g-recaptcha-response'])) , do something like if (empty($_POST['g-recaptcha-response'])) {http_response_code(400);die('no captcha answer provided!');}} 代替if (isset($_POST['g-recaptcha-response'])) ,执行类似if (empty($_POST['g-recaptcha-response'])) {http_response_code(400);die('no captcha answer provided!');}}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM