그누보드 다중 취약점 (17-0295, 334, 355) 수정
This commit is contained in:
@ -382,15 +382,24 @@ function admin_referer_check($return=false)
|
||||
}
|
||||
|
||||
$p = @parse_url($referer);
|
||||
|
||||
$host = preg_replace('/:[0-9]+$/', '', $_SERVER['HTTP_HOST']);
|
||||
$msg = '';
|
||||
|
||||
if($host != $p['host']) {
|
||||
$msg = '올바른 방법으로 이용해 주십시오.';
|
||||
}
|
||||
|
||||
if($return)
|
||||
if( $p['path'] && ! preg_match( '/\/'.preg_quote(G5_ADMIN_DIR).'\//i', $p['path'] ) ){
|
||||
$msg = '올바른 방법으로 이용해 주십시오';
|
||||
}
|
||||
|
||||
if( $msg ){
|
||||
if($return) {
|
||||
return $msg;
|
||||
else
|
||||
} else {
|
||||
alert($msg, G5_URL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ if ($file = $_POST['bo_include_head']) {
|
||||
$purl = parse_url($file);
|
||||
$file = $purl['path'];
|
||||
if (!preg_match("/\.(php|htm['l']?)$/i", $file)) {
|
||||
alert('상단 파일 경로가 php, html 파일이 아닙니다.');
|
||||
alert('상단 파일 경로의 확장자는 php, html 만 허용합니다.');
|
||||
}
|
||||
$_POST['bo_include_head'] = $file;
|
||||
}
|
||||
@ -30,16 +30,16 @@ if ($file = $_POST['bo_include_tail']) {
|
||||
$purl = parse_url($file);
|
||||
$file = $purl['path'];
|
||||
if (!preg_match("/\.(php|htm['l']?)$/i", $file)) {
|
||||
alert('하단 파일 경로가 php, html 파일이 아닙니다.');
|
||||
alert('하단 파일 경로의 확장자는 php, html 만 허용합니다.');
|
||||
}
|
||||
$_POST['bo_include_tail'] = $file;
|
||||
}
|
||||
|
||||
if(!is_include_path_check($_POST['bo_include_head'])) {
|
||||
if(!is_include_path_check($_POST['bo_include_head'], 1)) {
|
||||
alert('/data/file/ 또는 /data/editor/ 포함된 문자를 상단 파일 경로에 포함시킬수 없습니다.');
|
||||
}
|
||||
|
||||
if(!is_include_path_check($_POST['bo_include_tail'])) {
|
||||
if(!is_include_path_check($_POST['bo_include_tail'], 1)) {
|
||||
alert('/data/file/ 또는 /data/editor/ 포함된 문자를 하단 파일 경로에 포함시킬수 없습니다.');
|
||||
}
|
||||
|
||||
|
||||
@ -20,6 +20,22 @@ if ($co_timg_del) @unlink(G5_DATA_PATH."/content/{$co_id}_t");
|
||||
|
||||
$error_msg = '';
|
||||
|
||||
if( $co_include_head ){
|
||||
$purl = parse_url($co_include_head);
|
||||
$file = $purl['path'];
|
||||
if (!preg_match("/\.(php|htm['l']?)$/i", $file)) {
|
||||
alert('상단 파일 경로의 확장자는 php, html 만 허용합니다.');
|
||||
}
|
||||
}
|
||||
|
||||
if( $co_include_tail ){
|
||||
$purl = parse_url($co_include_tail);
|
||||
$file = $purl['path'];
|
||||
if (!preg_match("/\.(php|htm['l']?)$/i", $file)) {
|
||||
alert('하단 파일 경로의 확장자는 php, html 만 허용합니다.');
|
||||
}
|
||||
}
|
||||
|
||||
if( $co_include_head && ! is_include_path_check($co_include_head) ){
|
||||
$co_include_head = '';
|
||||
$error_msg = '/data/file/ 또는 /data/editor/ 포함된 문자를 상단 파일 경로에 포함시킬수 없습니다.';
|
||||
|
||||
@ -10,12 +10,28 @@ check_admin_token();
|
||||
|
||||
$error_msg = '';
|
||||
|
||||
if( $qa_include_head && ! is_include_path_check($qa_include_head) ){
|
||||
if( $qa_include_head ){
|
||||
$purl = parse_url($qa_include_head);
|
||||
$file = $purl['path'];
|
||||
if (!preg_match("/\.(php|htm['l']?)$/i", $file)) {
|
||||
alert('상단 파일 경로의 확장자는 php, html 만 허용합니다.');
|
||||
}
|
||||
}
|
||||
|
||||
if( $qa_include_tail ){
|
||||
$purl = parse_url($qa_include_tail);
|
||||
$file = $purl['path'];
|
||||
if (!preg_match("/\.(php|htm['l']?)$/i", $file)) {
|
||||
alert('하단 파일 경로의 확장자는 php, html 만 허용합니다.');
|
||||
}
|
||||
}
|
||||
|
||||
if( $qa_include_head && ! is_include_path_check($qa_include_head, 1) ){
|
||||
$qa_include_head = '';
|
||||
$error_msg = '/data/file/ 또는 /data/editor/ 포함된 문자를 상단 파일 경로에 포함시킬수 없습니다.';
|
||||
}
|
||||
|
||||
if( $qa_include_tail && ! is_include_path_check($qa_include_tail) ){
|
||||
if( $qa_include_tail && ! is_include_path_check($qa_include_tail, 1) ){
|
||||
$qa_include_tail = '';
|
||||
$error_msg = '/data/file/ 또는 /data/editor/ 포함된 문자를 하단 파일 경로에 포함시킬수 없습니다.';
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ if ($is_guest)
|
||||
$g5['title'] = '내 쪽지함';
|
||||
include_once(G5_PATH.'/head.sub.php');
|
||||
|
||||
if (!$kind) $kind = 'recv';
|
||||
$kind = $kind ? clean_xss_tags(strip_tags($kind)) : 'recv';
|
||||
|
||||
if ($kind == 'recv')
|
||||
$unkind = 'send';
|
||||
|
||||
@ -153,7 +153,7 @@ function alert($msg='', $url='', $error=true, $post=false)
|
||||
global $g5, $config, $member;
|
||||
global $is_admin;
|
||||
|
||||
if (!$msg) $msg = '올바른 방법으로 이용해 주십시오.';
|
||||
$msg = $msg ? strip_tags($msg, '<br>') : '올바른 방법으로 이용해 주십시오.';
|
||||
|
||||
$header = '';
|
||||
if (isset($g5['title'])) {
|
||||
@ -168,6 +168,8 @@ function alert($msg='', $url='', $error=true, $post=false)
|
||||
function alert_close($msg, $error=true)
|
||||
{
|
||||
global $g5;
|
||||
|
||||
$msg = strip_tags($msg, '<br>');
|
||||
|
||||
$header = '';
|
||||
if (isset($g5['title'])) {
|
||||
@ -3302,46 +3304,54 @@ function get_call_func_cache($func, $args=array()){
|
||||
}
|
||||
|
||||
// include 하는 경로에 data file 경로가 포함되어 있는지 체크합니다.
|
||||
function is_include_path_check($path='')
|
||||
function is_include_path_check($path='', $is_input='')
|
||||
{
|
||||
if( $path ){
|
||||
try {
|
||||
// whether $path is unix or not
|
||||
$unipath = strlen($path)==0 || $path{0}!='/';
|
||||
$unc = substr($path,0,2)=='\\\\'?true:false;
|
||||
// attempts to detect if path is relative in which case, add cwd
|
||||
if(strpos($path,':') === false && $unipath && !$unc){
|
||||
$path=getcwd().DIRECTORY_SEPARATOR.$path;
|
||||
if($path{0}=='/'){
|
||||
$unipath = false;
|
||||
if ($is_input){
|
||||
try {
|
||||
// whether $path is unix or not
|
||||
$unipath = strlen($path)==0 || $path{0}!='/';
|
||||
$unc = substr($path,0,2)=='\\\\'?true:false;
|
||||
// attempts to detect if path is relative in which case, add cwd
|
||||
if(strpos($path,':') === false && $unipath && !$unc){
|
||||
$path=getcwd().DIRECTORY_SEPARATOR.$path;
|
||||
if($path{0}=='/'){
|
||||
$unipath = false;
|
||||
}
|
||||
}
|
||||
|
||||
// resolve path parts (single dot, double dot and double delimiters)
|
||||
$path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
|
||||
$parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
|
||||
$absolutes = array();
|
||||
foreach ($parts as $part) {
|
||||
if ('.' == $part){
|
||||
continue;
|
||||
}
|
||||
if ('..' == $part) {
|
||||
array_pop($absolutes);
|
||||
} else {
|
||||
$absolutes[] = $part;
|
||||
}
|
||||
}
|
||||
$path = implode(DIRECTORY_SEPARATOR, $absolutes);
|
||||
// resolve any symlinks
|
||||
// put initial separator that could have been lost
|
||||
$path = !$unipath ? '/'.$path : $path;
|
||||
$path = $unc ? '\\\\'.$path : $path;
|
||||
} catch (Exception $e) {
|
||||
//echo 'Caught exception: ', $e->getMessage(), "\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
// resolve path parts (single dot, double dot and double delimiters)
|
||||
$path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
|
||||
$parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
|
||||
$absolutes = array();
|
||||
foreach ($parts as $part) {
|
||||
if ('.' == $part){
|
||||
continue;
|
||||
}
|
||||
if ('..' == $part) {
|
||||
array_pop($absolutes);
|
||||
} else {
|
||||
$absolutes[] = $part;
|
||||
}
|
||||
if( preg_match('/\/data\/(file|editor)\/[A-Za-z0-9_]{1,20}\//', $path) ){
|
||||
return false;
|
||||
}
|
||||
$path = implode(DIRECTORY_SEPARATOR, $absolutes);
|
||||
// resolve any symlinks
|
||||
// put initial separator that could have been lost
|
||||
$path = !$unipath ? '/'.$path : $path;
|
||||
$path = $unc ? '\\\\'.$path : $path;
|
||||
} catch (Exception $e) {
|
||||
//echo 'Caught exception: ', $e->getMessage(), "\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
if( preg_match('/\/data\/(file|editor)\/[A-Za-z0-9_]{1,20}\//', $path) ){
|
||||
$extension = pathinfo($path, PATHINFO_EXTENSION);
|
||||
|
||||
if($extension && preg_match('/(jpg|jpeg|png|gif|bmp|conf)$/', $extension)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user