discuz x3.5第三方插件报错"您当前的访问请求当中含有非法字符,已经被系统拒绝"的解决办法
discuz x3.5绗笁鏂规彃浠舵姤閿"鎮ㄥ綋鍓嶇殑璁块棶璇锋眰褰撲腑鍚湁闈炴硶瀛楃锛屽凡缁忚绯荤粺鎷掔粷"鐨勮В鍐冲姙娉曪細
Discuz!绯荤粺鐨刜xss_check()鍑芥暟鍘熸湰鐨勬剰涔夋槸涓轰簡璁哄潧瀹夊叏锛岄槻姝SS鏀诲嚮锛屼竴鑸綉绔欎娇鐢ㄦ槸涓嶄細鍑虹幇浠涔堥棶棰樼殑锛屼絾鏄湁浜涚綉绔欒鎺ュ叆绗笁鏂规帴鍙o紝褰撶涓夋柟鎺ュ彛鍚戞湰绔檖ost鏁版嵁鐨勬椂鍊欏氨浼氭姤"鎮ㄥ綋鍓嶇殑璁块棶璇锋眰褰撲腑鍚湁闈炴硶瀛楃锛屽凡缁忚绯荤粺鎷掔粷"锛屾湰鏂囦粙缁嶄竴绉嶇畝鍗曠殑淇敼鏂规硶閬垮厤姝ら敊璇
瑙e喅鏂规濡備笅锛
\source\class\discuz\discuz_application.php
鏌ユ壘锛銆愮害363~395琛屻
鏇挎崲涓猴細
鈿犱慨鏀逛笉浼氬绯荤粺浜х敓鏄庢樉褰卞搷锛屾潵婧愮敱浣滆呮彁渚涚殑瀹樻柟鏂规锛https://www.yuque.com/zimuyun/zhaopin/rvz0p9
Discuz!绯荤粺鐨刜xss_check()鍑芥暟鍘熸湰鐨勬剰涔夋槸涓轰簡璁哄潧瀹夊叏锛岄槻姝SS鏀诲嚮锛屼竴鑸綉绔欎娇鐢ㄦ槸涓嶄細鍑虹幇浠涔堥棶棰樼殑锛屼絾鏄湁浜涚綉绔欒鎺ュ叆绗笁鏂规帴鍙o紝褰撶涓夋柟鎺ュ彛鍚戞湰绔檖ost鏁版嵁鐨勬椂鍊欏氨浼氭姤"鎮ㄥ綋鍓嶇殑璁块棶璇锋眰褰撲腑鍚湁闈炴硶瀛楃锛屽凡缁忚绯荤粺鎷掔粷"锛屾湰鏂囦粙缁嶄竴绉嶇畝鍗曠殑淇敼鏂规硶閬垮厤姝ら敊璇
瑙e喅鏂规濡備笅锛
\source\class\discuz\discuz_application.php
鏌ユ壘锛銆愮害363~395琛屻
- private function _xss_check() {
- static $check = array('"', '>', '<', '\'', '(', ')', 'CONTENT-TRANSFER-ENCODING');
- if(isset($_GET['formhash']) && $_GET['formhash'] !== formhash()) {
- if(defined('CURMODULE') && constant('CURMODULE') == 'logging' && isset($_GET['action']) && $_GET['action'] == 'logout') {
- header("HTTP/1.1 302 Found");
- header("Location: index.php");
- exit();
- } else {
- system_error('request_tainting');
- }
- }
- if($_SERVER['REQUEST_METHOD'] == 'GET' ) {
- $temp = $_SERVER['REQUEST_URI'];
- } elseif(empty ($_GET['formhash'])) {
- $temp = $_SERVER['REQUEST_URI'].http_build_query($_POST);
- } else {
- $temp = '';
- }
- if(!empty($temp)) {
- $temp = strtoupper(urldecode(urldecode($temp)));
- foreach ($check as $str) {
- if(strpos($temp, $str) !== false) {
- system_error('request_tainting');
- }
- }
- }
- return true;
- }
鏇挎崲涓猴細
- private function _xss_check() {
- $temp = strtoupper(urldecode(urldecode($_SERVER['REQUEST_URI'])));
- if (strpos($temp, '<') !== false || strpos($temp, '"') !== false || strpos($temp, 'CONTENT-TRANSFER-ENCODING') !== false) {
- system_error('request_tainting');
- }
- return true;
- }
鈿犱慨鏀逛笉浼氬绯荤粺浜х敓鏄庢樉褰卞搷锛屾潵婧愮敱浣滆呮彁渚涚殑瀹樻柟鏂规锛https://www.yuque.com/zimuyun/zhaopin/rvz0p9