From 76d83c2bae7dee59ebd8267fd7e29f8e10a3b848 Mon Sep 17 00:00:00 2001 From: thisgun Date: Fri, 5 Jun 2026 07:20:58 +0000 Subject: [PATCH] =?UTF-8?q?=EA=B2=8C=EC=8B=9C=ED=8C=90=20=EC=A0=95?= =?UTF-8?q?=EB=A0=AC=20=ED=95=84=EB=93=9C=20=ED=99=94=EC=9D=B4=ED=8A=B8?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EA=B2=80=EC=A6=9D=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 게시판 설정의 bo_sort_field 가 허용 목록 검증 없이 저장·사용되어 목록 조회 ORDER BY 절에 임의 표현식이 들어갈 수 있던 문제 수정. 정렬값은 따옴표로 감싸지 않아 escape 로 막히지 않으므로, 게시판 관리 권한 계정이 저장한 값이 비로그인 목록 조회에서 실행될 수 있었음. get_board_sort_fields() 의 허용 목록(관리자 드롭다운과 동일)으로 저장(adm/board_form_update.php)과 사용(bbs/list.php) 양쪽을 검증. 허용 목록 외 값은 기본 정렬로 무력화하여 이미 저장된 값도 차단. function_exists 가드로 부분 패치 환경 대비. Co-Authored-By: Claude Opus 4.8 (1M context) --- adm/board_form_update.php | 12 +++++++++++- bbs/list.php | 8 +++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/adm/board_form_update.php b/adm/board_form_update.php index 713661932..c4a9223bf 100644 --- a/adm/board_form_update.php +++ b/adm/board_form_update.php @@ -176,7 +176,17 @@ $bo_write_min = isset($_POST['bo_write_min']) ? (int) $_POST['bo_write_min'] : 0 $bo_write_max = isset($_POST['bo_write_max']) ? (int) $_POST['bo_write_max'] : 0; $bo_comment_min = isset($_POST['bo_comment_min']) ? (int) $_POST['bo_comment_min'] : 0; $bo_comment_max = isset($_POST['bo_comment_max']) ? (int) $_POST['bo_comment_max'] : 0; -$bo_sort_field = isset($_POST['bo_sort_field']) ? addslashes(clean_xss_tags(stripslashes($_POST['bo_sort_field']), 1, 1)) : ''; +$bo_sort_field = isset($_POST['bo_sort_field']) ? trim(stripslashes($_POST['bo_sort_field'])) : ''; +$bo_allowed_sort_field = array(''); +if (function_exists('get_board_sort_fields')) { + foreach (get_board_sort_fields(isset($board) ? $board : array()) as $bo_sort_v) { + $bo_allowed_sort_field[] = $bo_sort_v[0]; + } +} +if (!in_array($bo_sort_field, $bo_allowed_sort_field, true)) { + $bo_sort_field = ''; +} +$bo_sort_field = addslashes($bo_sort_field); if (strpbrk($bo_skin.$bo_mobile_skin, "?%*:|\"<>") !== false) { alert('스킨 디렉토리명 오류!'); diff --git a/bbs/list.php b/bbs/list.php index b35e28843..8e66fa756 100644 --- a/bbs/list.php +++ b/bbs/list.php @@ -170,7 +170,13 @@ $td_width = (int)(100 / $bo_gallery_cols); // 인덱스 필드가 아니면 정렬에 사용하지 않음 //if (!$sst || ($sst && !(strstr($sst, 'wr_id') || strstr($sst, "wr_datetime")))) { if (!$sst) { - if ($board['bo_sort_field']) { + $bo_allowed_sort_field = array(); + if (function_exists('get_board_sort_fields')) { + foreach (get_board_sort_fields($board) as $bo_sort_v) { + $bo_allowed_sort_field[] = $bo_sort_v[0]; + } + } + if ($board['bo_sort_field'] && in_array($board['bo_sort_field'], $bo_allowed_sort_field, true)) { $sst = $board['bo_sort_field']; } else { $sst = "wr_num, wr_reply";