From 614b040960c0c63898cb752514d2722967d0cbd5 Mon Sep 17 00:00:00 2001 From: thisgun Date: Mon, 13 Apr 2026 05:43:21 +0000 Subject: [PATCH] =?UTF-8?q?[security]KVE-2026-0673=20=EB=B9=84=EC=9D=B8?= =?UTF-8?q?=EC=A6=9D=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=EC=9D=84=20=ED=86=B5=ED=95=9C=20=EA=B3=84=EC=A0=95=20=ED=83=88?= =?UTF-8?q?=EC=B7=A8=20=EC=B7=A8=EC=95=BD=EC=A0=90=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit register_email_update.php에 로그인 검증·소유권 강제·ckey HMAC 검증·SQL 이스케이프 추가 member_cert_refresh_update.php에 로그인 검증 및 소유권 강제 추가 (연관 IDOR 선제 조치) Co-Authored-By: Claude Opus 4.6 (1M context) --- bbs/member_cert_refresh_update.php | 8 +++++++- bbs/register_email.php | 1 + bbs/register_email_update.php | 25 ++++++++++++++++++++----- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/bbs/member_cert_refresh_update.php b/bbs/member_cert_refresh_update.php index 041716d8f..1d276b267 100644 --- a/bbs/member_cert_refresh_update.php +++ b/bbs/member_cert_refresh_update.php @@ -3,13 +3,19 @@ define('G5_CERT_IN_PROG', true); include_once('./_common.php'); global $g5; +// 로그인 검증 (본인인증 갱신은 로그인 필수) +if (!$is_member) { + alert('로그인 후 이용해 주십시오.', G5_BBS_URL.'/login.php'); +} + if (!($w == '' || $w == 'u')) { alert('w 값이 제대로 넘어오지 않았습니다.'); } $url = urldecode($url); if($w == '') { - $mb_id = isset($_POST['mb_id']) ? trim($_POST['mb_id']) : ''; + // 본인 계정만 수정 가능 (POST mb_id 무시, 세션 회원 ID 사용) + $mb_id = $member['mb_id']; $mb_name = isset($_POST['mb_name']) ? trim($_POST['mb_name']) : ''; $mb_hp = isset($_POST['mb_hp']) ? trim($_POST['mb_hp']) : ''; } else diff --git a/bbs/register_email.php b/bbs/register_email.php index 1aa9d9c5c..4dbf8d57a 100644 --- a/bbs/register_email.php +++ b/bbs/register_email.php @@ -28,6 +28,7 @@ if(!$ckey || $ckey !== $key)
+
diff --git a/bbs/register_email_update.php b/bbs/register_email_update.php index 0dda117d9..b10ad011f 100644 --- a/bbs/register_email_update.php +++ b/bbs/register_email_update.php @@ -3,13 +3,28 @@ include_once('./_common.php'); include_once(G5_CAPTCHA_PATH.'/captcha.lib.php'); include_once(G5_LIB_PATH.'/mailer.lib.php'); -$mb_id = isset($_POST['mb_id']) ? substr(clean_xss_tags($_POST['mb_id']), 0, 20) : ''; +// 로그인 검증 +if (!$is_member) { + alert('로그인 후 이용해 주십시오.', G5_BBS_URL.'/login.php'); +} + +// 본인 계정만 수정 가능 (POST mb_id 무시, 세션 회원 ID 사용) +$mb_id = $member['mb_id']; $mb_email = isset($_POST['mb_email']) ? get_email_address(trim($_POST['mb_email'])) : ''; if(!$mb_id || !$mb_email) alert('올바른 방법으로 이용해 주십시오.', G5_URL); -$sql = " select mb_name from {$g5['member_table']} where mb_id = '{$mb_id}' and substring(mb_email_certify, 1, 1) = '0' "; +// ckey 검증 (register_email.php 폼에서 전달받은 인증키) +$ckey = isset($_POST['ckey']) ? trim($_POST['ckey']) : ''; +$key = get_email_cert_key($mb_id, $member['mb_datetime']); +if (!$ckey || $ckey !== $key) { + alert('올바른 방법으로 이용해 주십시오.', G5_URL); +} + +$esc_mb_id = sql_real_escape_string($mb_id); + +$sql = " select mb_name from {$g5['member_table']} where mb_id = '{$esc_mb_id}' and substring(mb_email_certify, 1, 1) = '0' "; $mb = sql_fetch($sql); if (!$mb) { alert("이미 메일인증 하신 회원입니다.", G5_URL); @@ -19,7 +34,7 @@ if (!chk_captcha()) { alert('자동등록방지 숫자가 틀렸습니다.'); } -$sql = " select count(*) as cnt from {$g5['member_table']} where mb_id <> '{$mb_id}' and mb_email = '$mb_email' "; +$sql = " select count(*) as cnt from {$g5['member_table']} where mb_id <> '{$esc_mb_id}' and mb_email = '$mb_email' "; $row = sql_fetch($sql); if ($row['cnt']) { alert("{$mb_email} 메일은 이미 존재하는 메일주소 입니다.\\n\\n다른 메일주소를 입력해 주십시오."); @@ -33,7 +48,7 @@ $mb_name = $mb['mb_name']; // 어떠한 회원정보도 포함되지 않은 일회용 난수를 생성하여 인증에 사용 $mb_md5 = md5(pack('V*', rand(), rand(), rand(), rand())); -sql_query(" update {$g5['member_table']} set mb_email_certify2 = '$mb_md5' where mb_id = '$mb_id' "); +sql_query(" update {$g5['member_table']} set mb_email_certify2 = '$mb_md5' where mb_id = '{$esc_mb_id}' "); $certify_href = G5_BBS_URL.'/email_certify.php?mb_id='.$mb_id.'&mb_md5='.$mb_md5; @@ -44,7 +59,7 @@ ob_end_clean(); mailer($config['cf_admin_email_name'], $config['cf_admin_email'], $mb_email, $subject, $content, 1); -$sql = " update {$g5['member_table']} set mb_email = '$mb_email' where mb_id = '$mb_id' "; +$sql = " update {$g5['member_table']} set mb_email = '$mb_email' where mb_id = '{$esc_mb_id}' "; sql_query($sql); alert("인증메일을 {$mb_email} 메일로 다시 보내 드렸습니다.\\n\\n잠시후 {$mb_email} 메일을 확인하여 주십시오.", G5_URL); \ No newline at end of file