diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example index 1cc028ff137..5325523f8e5 100644 --- a/htdocs/conf/conf.php.example +++ b/htdocs/conf/conf.php.example @@ -302,7 +302,7 @@ $dolibarr_main_restrict_ip=''; // This might be required if you access Dolibarr behind a proxy that make bad URL rewriting, to avoid false alarms. // In most cases, you should always keep this to 0. // Default value: 0 -// Possible values: 0 or 1 +// Possible values: 0 or 1 (no strict CSRF test, only test on referer) or 2 (no CSRF test at all) // Examples: // $dolibarr_nocsrfcheck='0'; // diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 08ecd37f995..80f167057df 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -206,7 +206,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; // when we post forms (we allow GET and HEAD to accept direct link from a particular page). // Note about $_SERVER[HTTP_HOST/SERVER_NAME]: http://shiflett.org/blog/2006/mar/server-name-versus-http-host // See also CSRF protections done into main.inc.php -if (!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck)) { +if (!defined('NOCSRFCHECK') && isset($dolibarr_nocsrfcheck) && $dolibarr_nocsrfcheck == 1) { // If $dolibarr_nocsrfcheck is 0, there is a strict CSRF test with token in main if (!empty($_SERVER['REQUEST_METHOD']) && !in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD')) && !empty($_SERVER['HTTP_HOST'])) { $csrfattack = false; if (empty($_SERVER['HTTP_REFERER'])) {