Unverified Commit 3dc4475c authored by Cédric Anne's avatar Cédric Anne Committed by GitHub
Browse files

Merge pull request from GHSA-jwpv-7m4h-5gvc

* Prevent SQL injection through search API

* better solution
parent 3ae40f08
......@@ -1631,8 +1631,8 @@ abstract class API extends CommonGLPI {
if (isset($params['criteria']) && is_array($params['criteria'])) {
// use a recursive closure to check each nested criteria
$check_criteria = function($criteria) use (&$check_criteria, $soptions) {
foreach ($criteria as $criterion) {
$check_criteria = function(&$criteria) use (&$check_criteria, $soptions) {
foreach ($criteria as &$criterion) {
// recursive call
if (isset($criterion['criteria'])) {
return $check_criteria($criterion['criteria']);
......@@ -1653,6 +1653,9 @@ abstract class API extends CommonGLPI {
&& $soptions[$criterion['field']]['nosearch']) {
return __("Forbidden field ID in search criteria");
}
// Escape value to prevent SQL injection
$criterion['value'] = Toolbox::addslashes_deep($criterion['value']);
}
return true;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment