Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

Commit

Permalink
[KVE-2019-0335, 0344 다중 취약점] 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
thisgun committed Mar 19, 2019
1 parent f1c061f commit 07993f6
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 14 deletions.
9 changes: 6 additions & 3 deletions adm/board_form_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

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('게시판 제목을 입력하세요.'); }
Expand Down Expand Up @@ -75,11 +78,11 @@
$_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']}',
Expand Down
3 changes: 1 addition & 2 deletions bbs/alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
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);
Expand All @@ -48,11 +49,9 @@

<script>
alert("<?php echo $msg; ?>");
//document.location.href = "<?php echo $url; ?>";
<?php if ($url) { ?>
document.location.replace("<?php echo str_replace('&amp;', '&', $url); ?>");
<?php } else { ?>
//alert('history.back();');
history.back();
<?php } ?>
</script>
Expand Down
12 changes: 9 additions & 3 deletions bbs/confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 13 additions & 2 deletions lib/common.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -3503,7 +3503,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 ){
Expand All @@ -3514,6 +3514,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
Expand Down Expand Up @@ -3551,7 +3559,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;
}
}
Expand Down
6 changes: 4 additions & 2 deletions plugin/okname/hpcert1.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php
include_once('./_common.php');

if( isset($_REQUEST['exe']) && isset($exe) && $exe ){
die('bad request');
}

// 금일 인증시도 회수 체크
certify_count_check($member['mb_id'], 'hp');

//include_once('./hpcert.config.php');

// KISA 취약점 내용(KVE-2018-0291) hpcert1.php의 $cmd 함수에 대한 인자 값은 hpcert_config.php 파일에서 설정되나, 이를 다른 페이지에서 포함한 뒤 호출할 시 임의 값 설정 가능
// 이에 include_once 를 include 로 수정함
include('./hpcert.config.php');
Expand Down
5 changes: 4 additions & 1 deletion plugin/okname/hpcert2.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php
include_once('./_common.php');
//include_once('./hpcert.config.php');

if( isset($_REQUEST['exe']) && isset($exe) && $exe ){
die('bad request');
}

// KISA 취약점 내용(KVE-2018-0291) hpcert1.php의 $cmd 함수에 대한 인자 값은 hpcert_config.php 파일에서 설정되나, 이를 다른 페이지에서 포함한 뒤 호출할 시 임의 값 설정 가능
// 이에 include_once 를 include 로 수정함
Expand Down
1 change: 1 addition & 0 deletions plugin/okname/ipin.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// key 디렉토리 체크
include_once('./key_dir_check.php');

$exe = '';
// 실행모듈
if(strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
if(PHP_INT_MAX == 2147483647) // 32-bit
Expand Down
4 changes: 4 additions & 0 deletions plugin/okname/ipin1.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
include_once('./_common.php');

if( isset($_REQUEST['exe']) && isset($exe) && $exe ){
die('bad request');
}

// 금일 인증시도 회수 체크
certify_count_check($member['mb_id'], 'ipin');

Expand Down
7 changes: 6 additions & 1 deletion plugin/okname/ipin2.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?php
include_once('./_common.php');
include_once('./ipin.config.php');

if( isset($_REQUEST['exe']) && isset($exe) && $exe ){
die('bad request');
}

include('./ipin.config.php');

//아이핀팝업에서 조회한 PERSONALINFO이다.
@$encPsnlInfo = $_POST["encPsnlInfo"];
Expand Down

0 comments on commit 07993f6

Please sign in to comment.