diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index 193623167c9..10eb455a312 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -989,7 +989,11 @@ print 'MAIN_ALLOW_SVG_FILES_AS_EXTERNAL_LINKS = '.getDolGlobalS print '
'; print 'MAIN_ALLOW_OBFUSCATION_METHODS_IN_DOL_EVAL = '.getDolGlobalString('MAIN_ALLOW_OBFUSCATION_METHODS_IN_DOL_EVAL', ''.$langs->trans("Undefined").''); -print '   ('.$langs->trans("Recommended").": 0 - The value 1 allows the use of concatenation functions like . or dol_concat into extra fields conditions or formula but is not secured)
"; +print '   ('.$langs->trans("Recommended").": ".$langs->trans("Undefined").' '.$langs->trans("or")." 0 - The value 1 allows the use of concatenation functions like . or dol_concat into extra fields conditions or formula but is not secured)
"; +print '
'; + +print 'MAIN_DISALLOW_UNSECURED_SELECT_INTO_EXTRAFIELDS_FILTER = '.getDolGlobalString('MAIN_DISALLOW_UNSECURED_SELECT_INTO_EXTRAFIELDS_FILTER', ''.$langs->trans("Undefined").''); +print '   ('.$langs->trans("Recommended").": 1 - The value 0 allows the use of subrequests into extrafields conditions. It remains not possible in API filters to avoid bind SQL injections whatever is this value)
"; print '
'; diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 214f6fd9c64..b76ef49b65e 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -118,6 +118,10 @@ require_once DOL_DOCUMENT_ROOT.'/api/class/api_access.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +// In API context, we force the protection to avoid forging of criteria including bind SQL injection +$conf->global->MAIN_DISALLOW_UNSECURED_SELECT_INTO_EXTRAFIELDS_FILTER = 1; + + $url = $_SERVER['PHP_SELF']; if (preg_match('/api\/index\.php$/', $url)) { // sometimes $_SERVER['PHP_SELF'] is 'api\/index\.php' instead of 'api\/index\.php/explorer.php' or 'api\/index\.php/method' $url = $_SERVER['PHP_SELF'].(empty($_SERVER['PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : $_SERVER['PATH_INFO']); diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 766413fe4f4..daaec854b44 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -1350,6 +1350,11 @@ class Conf extends stdClass $this->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1; } + if (!isset($this->global->MAIN_DISALLOW_UNSECURED_SELECT_INTO_EXTRAFIELDS_FILTER)) { + // Note value is always forced to 1 in API context to avoid bind SQL injection into API filters. + $this->global->MAIN_DISALLOW_UNSECURED_SELECT_INTO_EXTRAFIELDS_FILTER = 0; // TODO Move this into 1 by default + } + // For backward compatibility if (!empty($this->global->LDAP_SYNCHRO_ACTIVE)) { if ($this->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {