diff --git a/adm/board_form_update.php b/adm/board_form_update.php index 2222baadb..497d1df01 100644 --- a/adm/board_form_update.php +++ b/adm/board_form_update.php @@ -9,7 +9,10 @@ auth_check($auth[$sub_menu], 'w'); check_admin_token(); -if (!$_POST['gr_id']) { alert('그룹 ID는 반드시 선택하세요.'); } +$gr_id = isset($_POST['gr_id']) ? preg_replace('/[^a-z0-9_]/i', '', $_POST['gr_id']) : ''; +$bo_admin = isset($_POST['bo_admin']) ? preg_replace('/[^a-z0-9_\, \|\#]/i', '', $_POST['bo_admin']) : ''; + +if (!$gr_id) { alert('그룹 ID는 반드시 선택하세요.'); } if (!$bo_table) { alert('게시판 TABLE명은 반드시 입력하세요.'); } if (!preg_match("/^([A-Za-z0-9_]{1,20})$/", $bo_table)) { alert('게시판 TABLE명은 공백없이 영문자, 숫자, _ 만 사용 가능합니다. (20자 이내)'); } if (!$_POST['bo_subject']) { alert('게시판 제목을 입력하세요.'); } @@ -75,11 +78,11 @@ $str_bo_category_list = isset($_POST['bo_category_list']) ? preg_replace("/[\<\> $_POST['bo_subject'] = strip_tags($_POST['bo_subject']); $_POST['bo_mobile_subject'] = strip_tags($_POST['bo_mobile_subject']); -$sql_common = " gr_id = '{$_POST['gr_id']}', +$sql_common = " gr_id = '{$gr_id}', bo_subject = '{$_POST['bo_subject']}', bo_mobile_subject = '{$_POST['bo_mobile_subject']}', bo_device = '{$_POST['bo_device']}', - bo_admin = '{$_POST['bo_admin']}', + bo_admin = '{$bo_admin}', bo_list_level = '{$_POST['bo_list_level']}', bo_read_level = '{$_POST['bo_read_level']}', bo_write_level = '{$_POST['bo_write_level']}', diff --git a/bbs/alert.php b/bbs/alert.php index 1d74ad4b4..fbac90876 100644 --- a/bbs/alert.php +++ b/bbs/alert.php @@ -35,6 +35,7 @@ $url = clean_xss_tags($url); if (!$url) $url = clean_xss_tags($_SERVER['HTTP_REFERER']); $url = preg_replace("/[\<\>\'\"\\\'\\\"\(\)]/", "", $url); +$url = preg_replace('/\r\n|\r|\n|[^\x20-\x7e]/','', $url); // url 체크 check_url_host($url, $msg); @@ -48,11 +49,9 @@ if($error) { diff --git a/bbs/confirm.php b/bbs/confirm.php index a80f5eab1..5e71c009a 100644 --- a/bbs/confirm.php +++ b/bbs/confirm.php @@ -2,9 +2,15 @@ include_once('./_common.php'); include_once(G5_PATH.'/head.sub.php'); -$url1 = preg_replace("/[\<\>\'\"\\\'\\\"\(\)]/", "", clean_xss_tags($url1)); -$url2 = preg_replace("/[\<\>\'\"\\\'\\\"\(\)]/", "", clean_xss_tags($url2)); -$url3 = preg_replace("/[\<\>\'\"\\\'\\\"\(\)]/", "", clean_xss_tags($url3)); +$pattern1 = "/[\<\>\'\"\\\'\\\"\(\)]/"; +$pattern2 = "/\r\n|\r|\n|[^\x20-\x7e]/"; + +$url1 = preg_replace($pattern1, "", clean_xss_tags($url1)); +$url1 = preg_replace($pattern2, "", $url1); +$url2 = preg_replace($pattern1, "", clean_xss_tags($url2)); +$url2 = preg_replace($pattern2, "", $url2); +$url3 = preg_replace($pattern1, "", clean_xss_tags($url3)); +$url3 = preg_replace($pattern2, "", $url3); // url 체크 check_url_host($url1); diff --git a/lib/common.lib.php b/lib/common.lib.php index 80552e574..d4197e468 100644 --- a/lib/common.lib.php +++ b/lib/common.lib.php @@ -3488,7 +3488,7 @@ function get_call_func_cache($func, $args=array()){ return $result; } -// include 하는 경로에 data file 경로가 포함되어 있는지 체크합니다. +// include 하는 경로에 data file 경로나 안전하지 않은 경로가 있는지 체크합니다. function is_include_path_check($path='', $is_input='') { if( $path ){ @@ -3499,6 +3499,14 @@ function is_include_path_check($path='', $is_input='') if( stripos($path, 'rar:') !== false || stripos($path, 'php:') !== false || stripos($path, 'zlib:') !== false || stripos($path, 'bzip2:') !== false || stripos($path, 'zip:') !== false || stripos($path, 'data:') !== false || stripos($path, 'phar:') !== false ){ return false; } + + $replace_path = str_replace('\\', '/', $path); + $slash_count = substr_count(str_replace('\\', '/', $_SERVER['SCRIPT_NAME']), '/'); + $peer_count = substr_count($replace_path, '../'); + + if ( $peer_count && $peer_count > $slash_count ){ + return false; + } try { // whether $path is unix or not @@ -3536,7 +3544,10 @@ function is_include_path_check($path='', $is_input='') return false; } - if( preg_match('/\/data\/(file|editor|qa|cache|member|member_image|session|tmp)\/[A-Za-z0-9_]{1,20}\//i', str_replace('\\', '/', $path)) ){ + if( preg_match('/\/data\/(file|editor|qa|cache|member|member_image|session|tmp)\/[A-Za-z0-9_]{1,20}\//i', $replace_path) ){ + return false; + } + if( preg_match('/\.\.\//i', $replace_path) && preg_match('/plugin\//i', $replace_path) && preg_match('/okname\//i', $replace_path) ){ return false; } } diff --git a/plugin/okname/hpcert1.php b/plugin/okname/hpcert1.php index 97e856421..45c64bd8f 100644 --- a/plugin/okname/hpcert1.php +++ b/plugin/okname/hpcert1.php @@ -1,11 +1,13 @@