Skip to content

Commit

Permalink
세션 고정 취약점 수정 #257
Browse files Browse the repository at this point in the history
  • Loading branch information
thisgun committed Aug 16, 2023
1 parent 6868cee commit e43e424
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 7 additions & 0 deletions bbs/login_check.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@

@include_once($member_skin_path.'/login_check.skin.php');

if (! (defined('SKIP_SESSION_REGENERATE_ID') && SKIP_SESSION_REGENERATE_ID)) {
session_regenerate_id(false);
if (function_exists('session_start_samesite')) {
session_start_samesite();
}
}

// 회원아이디 세션 생성
set_session('ss_mb_id', $mb['mb_id']);
// FLASH XSS 공격에 대응하기 위하여 회원의 고유키를 생성해 놓는다. 관리자에서 검사함 - 110106
Expand Down
10 changes: 7 additions & 3 deletions common.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ function g5_path()
$_SERVER['SERVER_ADDR'] = isset($_SERVER['LOCAL_ADDR']) ? $_SERVER['LOCAL_ADDR'] : '';
}

// Cloudflare 환경을 고려한 https 사용여부
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === "https") {
$_SERVER['HTTPS'] = 'on';
}

// multi-dimensional array에 사용자지정 함수적용
function array_map_deep($fn, $array)
{
Expand Down Expand Up @@ -221,7 +226,7 @@ function sql_escape_string($str)
ini_set("session.gc_probability", 1); // session.gc_probability는 session.gc_divisor와 연계하여 gc(쓰레기 수거) 루틴의 시작 확률을 관리합니다. 기본값은 1입니다. 자세한 내용은 session.gc_divisor를 참고하십시오.
ini_set("session.gc_divisor", 100); // session.gc_divisor는 session.gc_probability와 결합하여 각 세션 초기화 시에 gc(쓰레기 수거) 프로세스를 시작할 확률을 정의합니다. 확률은 gc_probability/gc_divisor를 사용하여 계산합니다. 즉, 1/100은 각 요청시에 GC 프로세스를 시작할 확률이 1%입니다. session.gc_divisor의 기본값은 100입니다.

session_set_cookie_params(0, '/');
session_set_cookie_params(0, '/', null, false, true);
ini_set("session.cookie_domain", G5_COOKIE_DOMAIN);

function chrome_domain_session_name(){
Expand Down Expand Up @@ -366,8 +371,7 @@ function session_start_samesite($options = array())
|| preg_match('/(iPhone|iPod|iPad).*AppleWebKit.*Safari/i', $_SERVER['HTTP_USER_AGENT'])
|| preg_match('~MSIE|Internet Explorer~i', $_SERVER['HTTP_USER_AGENT'])
|| preg_match('~Trident/7.0(; Touch)?; rv:11.0~',$_SERVER['HTTP_USER_AGENT'])
|| !(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on')
|| !(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == "https")){
|| !(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on')) {
return $res;
}
}
Expand Down

0 comments on commit e43e424

Please sign in to comment.