You say that spam request don’t run your custom hooks. But some hook (like “email”) has to run (or otherwise the spam request is pointless)
About hooks yes, I was wrong a half. Emails hook are working, but captcha hook doesn’t. And captcha wasn’t even exist before spam-requests appeared, so I guess spammers are passing their own list of hooks & validators someway.
Does the requests have the parameters “pageId” and “af_action”?
Yes
What version of AjaxForm do you use? Maybe the vulnerability was introduce in a specific version.
Was 1.1.9 (latest official), but in update 1.2.2 (latest fork) nothing fixed too.
Are you sure your AjaxForm tag ([[!AjaxForm?...]]
) is correct?
Yes
[[!AjaxForm?
&snippet=`FormIt`
&form=`form.measurement_request`
&submitVar=`measurement_request_form`
&emailTpl=`mail.measurement_request`
&emailTo=`[[++emailsender]]`
&validate=`fullname:blank,phone:required:minLength=^18^:maxLength=^18^,g-recaptcha-response:required`
&hooks=`spam,csrfhelper_formit,recaptchav2,FormIt_custom_protections,FormItSaveForm,CRM_hook`
&emailSubject=`Application for calculation/measurement`
&successMessage=`Your application has been sent! Our manager will call you shortly <script>$.fancybox.close();</script>`
&validationErrorMessage=`Data filled in incorrectly`
&_frontend_css=``
&csrfKey=`measurement_request_csrf`
&for=`[[+for]]`
]]
Do you see any “weird” request parameters (or “weird” parameter values) that may change the code logic?
Only this:
if (!function_exists('mrs_log')) {
function mrs_log($arr) {
$log = '/absolute/path/to/oursite.com/public_html/mrs.log';
if (!file_exists($log)) {
touch($log);
}
$fp = fopen($log, 'a');
fwrite($fp, json_encode($arr, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) . "\n\n");
fclose($fp);
}
}
mrs_log([
'when' => date('d.m.Y H:i:s'),
'phone' => $_REQUEST['phone'],
'ip' => $_SERVER['REMOTE_ADDR'],
'browser' => $_SERVER['HTTP_USER_AGENT'],
'referer' => $_SERVER['HTTP_REFERER'],
'uri_que' => $_SERVER['QUERY_STRING'],
'reqwith' => $_SERVER['HTTP_X_REQUESTED_WITH'],
'request' => $_REQUEST,
]);
{
"when": "08.07.2024 20:30:43",
"phone": "+1 (111) 123-45-67",
"ip": "123.45.67.89",
"browser": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:127.0) Gecko/20100101 Firefox/127.0",
"referer": "https://oursite.com/",
"uri_que": "",
"reqwith": "XMLHttpRequest",
"request": {
"amocrm_action": "submitted a request for a free estimate/measurement",
"measurement_request_form": "1",
"nospam:blank": "",
"form_title": "",
"page_id": "29",
"page_name": "Page name",
"build_type": "",
"build_kind": "",
"page_kind": "",
"csrf_token": "MTcyMDExNDU3OS0tNmJiMzBjMzYxODE1YWZhMTEzMWNmY2IxYzI3OGI2OTI1ZGQyYWFiMDgxNGZhZWNiZWI3ZDM5NzQ3YWQ4ZmY2ZTNlNDQ5ZGQ3YmU1MzU1ZDk5ZGU2ODIzZGFhZTEwZmU2ZmY5YWQ0MWE3YmU1YjUzMThhODdhNDM5MTM0YTA1YjA=",
"fullname": "",
"phone": "+1 (111) 123-45-67",
"af_action": "4479c5f4947beb78ab1afe9e101e5aef",
"pageId": "29"
}
}
Forgot only to check php://input