[security]KVE-2026-0685 소셜 로그인 계정 연결 CSRF 방어

popup.php에서 mylink 진입 시 Referer 검증 및 세션 토큰 설정
functions.php에서 social_user_profile_replace() 호출 전 세션 토큰 검증

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
thisgunandClaude Opus 4.6 committed 2026-04-16 03:23:50 +00:00
1 parent 0037f72cce
commit 758bb67b7b
2 files changed
+35

No files matched your search

+12
View File
@@ -549,6 +549,18 @@ function social_check_login_before($p_service=''){
if( $mylink ){
// CSRF 토큰 검증 (popup.php에서 설정한 세션 토큰 확인)
$mylink_token = get_session('ss_social_mylink_token');
set_session('ss_social_mylink_token', '');
if (!$mylink_token) {
if ($use_popup == 1 || !$use_popup) {
alert_close('올바른 방법으로 이용해 주십시오.');
} else {
alert('올바른 방법으로 이용해 주십시오.');
}
exit;
}
social_user_profile_replace($member['mb_id'], $provider_name, $user_profile);
if( is_object( $adapter ) ){ //연결한것은 인증 받은 즉시 로그아웃한다.
+23
View File
@@ -17,6 +17,29 @@ if( !$provider_name ){
alert('서비스 이름이 넘어오지 않았습니다.');
}
// 소셜 계정 연결(mylink) CSRF 방어
if (isset($_REQUEST['mylink']) && !empty($_REQUEST['mylink'])) {
if (!$is_member) {
alert('로그인 후 이용해 주십시오.');
}
// 최초 진입(redirect_to_idp 없음) 시에만 Referer 검증 및 세션 토큰 설정
if (!isset($_REQUEST['redirect_to_idp'])) {
$referer = isset($_SERVER['HTTP_REFERER']) ? trim($_SERVER['HTTP_REFERER']) : '';
$ref_host = $referer ? @parse_url($referer, PHP_URL_HOST) : '';
$site_host = defined('G5_URL') ? @parse_url(G5_URL, PHP_URL_HOST) : '';
if ($ref_host) $ref_host = preg_replace('/^www\./i', '', $ref_host);
if ($site_host) $site_host = preg_replace('/^www\./i', '', $site_host);
if (!$ref_host || !$site_host || strcasecmp($ref_host, $site_host) !== 0) {
alert_close('올바른 방법으로 이용해 주십시오.');
}
set_session('ss_social_mylink_token', md5(uniqid(rand(), true)));
}
}
if( isset( $_REQUEST["redirect_to_idp"] ) ){
$content = social_check_login_before();