[SPIP] v3.2.1-->v3.2.2
[lhc/web/www.git] / www / config / ecran_securite.php
index 0bd8e65..d33df61 100644 (file)
@@ -5,7 +5,7 @@
  * ------------------
  */
 
-define('_ECRAN_SECURITE', '1.2.4'); // 2016-03-10
+define('_ECRAN_SECURITE', '1.3.8'); // 2018-10-31
 
 /*
  * Documentation : http://www.spip.net/fr_article4200.html
@@ -23,24 +23,172 @@ if (isset($_GET['test_ecran_securite']))
  * var_isbot=1 peut etre utilise pour monitorer la disponibilite pour les bots (sujets a 503 de delestage si
  * le load depasse ECRAN_SECURITE_LOAD)
  */
-if (!defined('_IS_BOT') and isset($_GET['var_isbot']))
-               define('_IS_BOT',$_GET['var_isbot']?true:false);
+if (!defined('_IS_BOT') and isset($_GET['var_isbot'])){
+       define('_IS_BOT', $_GET['var_isbot'] ? true : false);
+}
 
 /*
  * Détecteur de robot d'indexation
  */
-if (!defined('_IS_BOT'))
+if (!defined('_IS_BOT')){
        define('_IS_BOT',
                isset($_SERVER['HTTP_USER_AGENT'])
-               and preg_match(
-           // mots generiques
-           ',bot|slurp|crawler|spider|webvac|yandex|'
-           // MSIE 6.0 est un botnet 99,9% du temps, on traite donc ce USER_AGENT comme un bot
-           . 'MSIE 6\.0|'
-           // UA plus cibles
-           . '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti'
-           . ',i', (string) $_SERVER['HTTP_USER_AGENT'])
+               and preg_match(','
+               . implode ('|', array(
+                       // mots generiques
+                       'bot',
+                       'slurp',
+                       'crawler',
+                       'spider',
+                       'webvac',
+                       'yandex',
+                       'MSIE 6\.0', // botnet 99,9% du temps
+                       // UA plus cibles 
+                       '200please',
+                       '80legs',
+                       'a6-indexer',
+                       'aboundex',
+                       'accoona',
+                       'addthis',
+                       'adressendeutschland',
+                       'alexa',
+                       'altavista',
+                       'analyticsseo',
+                       'archive',
+                       'aspseek',
+                       'baidu',
+                       'begunadvertising',
+                       'bingpreview',
+                       'bloglines',
+                       'browsershots',
+                       'bubing',
+                       'butterfly',
+                       'changedetection',
+                       'charlotte',
+                       'chilkat',
+                       'china',
+                       'coccoc',
+                       'crowsnest',
+                       'dataminr',
+                       'daumoa',
+                       'dlweb',
+                       'ec2linkfinder',
+                       'estyle',
+                       'ezooms',
+                       'facebookexternalhit',
+                       'facebookplatform',
+                       'fairshare',
+                       'feedfetcher',
+                       'feedfetcher-google',
+                       'feedly',
+                       'fetch',
+                       'flipboardproxy',
+                       'genieo',
+                       'google',
+                       'grapeshot',
+                       'hatena-useragent',
+                       'head',
+                       'hosttracker',
+                       'hubspot',
+                       'ia_archiver',
+                       'ichiro',
+                       'iltrovatore-setaccio',
+                       'immediatenet',
+                       'ina',
+                       'infegyatlas',
+                       'infohelfer',
+                       'instapaper',
+                       'jabse',
+                       'james',
+                       'kumkie',
+                       'linkdex',
+                       'linkfluence',
+                       'linkwalker',
+                       'litefinder',
+                       'loadimpactpageanalyzer',
+                       'luminate',
+                       'lycos',
+                       'lycosa',
+                       'mediapartners-google',
+                       'msai',
+                       'najdi',
+                       'netcraftsurveyagent',
+                       'netestate',
+                       'netseer',
+                       'nuhk',
+                       'owlin',
+                       'panscient',
+                       'parsijoo',
+                       'plukkie',
+                       'proximic',
+                       'qirina',
+                       'qualidator',
+                       'rambler',
+                       'readability',
+                       'sbsearch',
+                       'scooter',
+                       'scrapy',
+                       'scrubby',
+                       'scrubbybloglines',
+                       'shareaholic',
+                       'shopwiki',
+                       'sistrix',
+                       'sitechecker',
+                       'siteexplorer',
+                       'sogou',
+                       'special_archiver',
+                       'speedy',
+                       'spinn3r',
+                       'spreadtrum',
+                       'steeler',
+                       'subscriber',
+                       'suma',
+                       'superdownloads',
+                       'svenska-webbsido',
+                       'teoma',
+                       'thumbshots',
+                       'tineye',
+                       'trendiction',
+                       'tweetedtimes',
+                       'tweetmeme',
+                       'uaslinkchecker',
+                       'undrip',
+                       'unwindfetchor',
+                       'vedma',
+                       'vkshare',
+                       'vm',
+                       'wch',
+                       'webalta',
+                       'webcookies',
+                       'webthumbnail',
+                       'wesee',
+                       'wise-guys',
+                       'woko',
+                       'wotbox',
+                       'y!j-bri',
+                       'y!j-bro',
+                       'y!j-brw',
+                       'y!j-bsc',
+                       'yahoo',
+                       'yahoo!',
+                       'yahooysmcm',
+                       'yats',
+                       'yeti',
+                       'zeerch'
+               )) . ',i',
+               (string)$_SERVER['HTTP_USER_AGENT'])
        );
+}
+if (!defined('_IS_BOT_FRIEND')){
+       define('_IS_BOT_FRIEND',
+               isset($_SERVER['HTTP_USER_AGENT'])
+               and preg_match(',' . implode ('|', array(
+                       'facebookexternalhit',
+                       'flipboardproxy'
+               )) . ',i',
+               (string)$_SERVER['HTTP_USER_AGENT'])
+       );
+}
 
 /*
  * Interdit de passer une variable id_article (ou id_xxx) qui ne
@@ -71,7 +219,7 @@ $cjpeg_command = '';
 /*
  * Contrôle de quelques variables (XSS)
  */
-foreach(array('lang', 'var_recherche', 'aide', 'var_lang_r', 'lang_r', 'var_ajax_ancre') as $var) {
+foreach(array('lang', 'var_recherche', 'aide', 'var_lang_r', 'lang_r', 'var_ajax_ancre', 'nom_fichier') as $var) {
        if (isset($_GET[$var]))
                $_REQUEST[$var] = $GLOBALS[$var] = $_GET[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_GET[$var]);
        if (isset($_POST[$var]))
@@ -116,6 +264,15 @@ if (isset($_REQUEST['exec'])
 and $_REQUEST['exec'] == 'auteurs'
 and preg_match(',[<],', (string)$_REQUEST['recherche']))
        $ecran_securite_raison = "recherche";
+if (isset($_REQUEST['exec'])
+and $_REQUEST['exec'] == 'info_plugin'
+and preg_match(',[<],', (string)$_REQUEST['plugin']))
+       $ecran_securite_raison = "plugin";
+if (isset($_REQUEST['exec'])
+and $_REQUEST['exec'] == 'puce_statut'
+and isset($_REQUEST['id'])
+and !intval($_REQUEST['id']))
+       $ecran_securite_raison = "puce_statut";
 if (isset($_REQUEST['action'])
 and $_REQUEST['action'] == 'configurer') {
        if (@file_exists('inc_version.php')
@@ -210,6 +367,19 @@ if (isset($_POST['tmp_lkojfghx3']))
 if (isset($_REQUEST['transformer_xml']))
        $ecran_securite_raison = "transformer_xml";
 
+/*
+ * Outils XML mal sécurisés again
+ */
+if (isset($_REQUEST['var_url']) and $_REQUEST['var_url'] and isset($_REQUEST['exec']) and $_REQUEST['exec']=='valider_xml'){
+       $url = trim($_REQUEST['var_url']);
+       if (strncmp($url,'/',1)==0
+         or (($p=strpos($url,'..'))!==false AND strpos($url,'..',$p+3)!==false)
+         or (($p=strpos($url,'..'))!==false AND strpos($url,'IMG',$p+3)!==false)
+               or (strpos($url,'://')!==false or strpos($url,':\\')!==false)) {
+               $ecran_securite_raison = 'URL interdite pour var_url';
+       }
+}
+
 /*
  * Sauvegarde mal securisée < 2.0.9
  */
@@ -262,6 +432,14 @@ and $_REQUEST['reinstall'] == 'oui')
 if (isset($_SERVER['HTTP_REFERER']))
        $_SERVER['HTTP_REFERER'] = strtr($_SERVER['HTTP_REFERER'], '<>"\'', '[]##');
 
+
+/*
+ * Echappement HTTP_X_FORWARDED_HOST
+ */
+if (isset($_SERVER['HTTP_X_FORWARDED_HOST']))
+       $_SERVER['HTTP_X_FORWARDED_HOST'] = strtr($_SERVER['HTTP_X_FORWARDED_HOST'], "<>?\"\{\}\$'` \r\n", '____________');
+
+
 /*
  * Réinjection des clés en html dans l'admin r19561
  */
@@ -325,6 +503,7 @@ if (
        defined('_ECRAN_SECURITE_LOAD')
        and _ECRAN_SECURITE_LOAD > 0
        and _IS_BOT
+       and !_IS_BOT_FRIEND
        and $_SERVER['REQUEST_METHOD'] === 'GET'
        and (
                (function_exists('sys_getloadavg')