From 6b2f9e094c9834ee0fd4456f2be3333b47ea7f3d Mon Sep 17 00:00:00 2001 From: thisgun Date: Tue, 26 May 2026 06:32:28 +0000 Subject: [PATCH] =?UTF-8?q?[security]=20ORDER=20BY=20sst/sod=20=ED=99=94?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EB=88=84?= =?UTF-8?q?=EB=9D=BD=20Blind=20SQL=20Injection=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit KVE-2026-0876 동일 패턴 추가 발견 5건 일괄 수정. - shop/itemuselist.php / mobile/shop/itemuselist.php (상품후기 목록) - shop/itemqalist.php / mobile/shop/itemqalist.php (상품문의 목록) → 비회원 접근 가능한 공개 페이지에서 sst/sod 가 ORDER BY 절에 검증 없이 삽입되어 CASE WHEN/SLEEP 기반 blind SQLi 가능했음. sst 는 컬럼 화이트리스트, sod 는 asc/desc 정규식으로 검증. - bbs/list.php (게시판 목록) → sst 는 wr_datetime/wr_hit/wr_good/wr_nogood 화이트리스트 적용 되어 있으나 sod 가 검증 누락되어 ORDER BY 절에 함수 표현식 삽입이 가능했음. sod 에 asc/desc 정규식 검증 추가. Co-Authored-By: Claude Opus 4.7 (1M context) --- bbs/list.php | 3 +++ mobile/shop/itemqalist.php | 3 +++ mobile/shop/itemuselist.php | 3 +++ shop/itemqalist.php | 3 +++ shop/itemuselist.php | 3 +++ 5 files changed, 15 insertions(+) diff --git a/bbs/list.php b/bbs/list.php index 9c4897674..b35e28843 100644 --- a/bbs/list.php +++ b/bbs/list.php @@ -191,6 +191,9 @@ if (!$sst) { if(!$sst) $sst = "wr_num, wr_reply"; +// 정렬 방향 화이트리스트 +$sod = preg_match("/^(asc|desc)$/i", $sod) ? $sod : ''; + if ($sst) { $sql_order = " order by {$sst} {$sod} "; } diff --git a/mobile/shop/itemqalist.php b/mobile/shop/itemqalist.php index 99b4fc76d..7288832d7 100644 --- a/mobile/shop/itemqalist.php +++ b/mobile/shop/itemqalist.php @@ -36,6 +36,9 @@ if (!$sst) { $sst = "a.iq_id"; $sod = "desc"; } +// 정렬 컬럼/방향 화이트리스트 +$sst = in_array($sst, array('a.iq_id', 'a.iq_datetime', 'a.it_id', 'b.it_name'), true) ? $sst : 'a.iq_id'; +$sod = preg_match("/^(asc|desc)$/i", $sod) ? $sod : 'desc'; $sql_order = " order by $sst $sod "; $sql = " select count(*) as cnt diff --git a/mobile/shop/itemuselist.php b/mobile/shop/itemuselist.php index 0a017004c..1513d6f96 100644 --- a/mobile/shop/itemuselist.php +++ b/mobile/shop/itemuselist.php @@ -36,6 +36,9 @@ if (!$sst) { $sst = "a.is_id"; $sod = "desc"; } +// 정렬 컬럼/방향 화이트리스트 +$sst = in_array($sst, array('a.is_id', 'a.is_datetime', 'a.is_score', 'a.it_id', 'b.it_name'), true) ? $sst : 'a.is_id'; +$sod = preg_match("/^(asc|desc)$/i", $sod) ? $sod : 'desc'; $sql_order = " order by $sst $sod "; $sql = " select count(*) as cnt diff --git a/shop/itemqalist.php b/shop/itemqalist.php index a8bd8c735..d15c7b72f 100644 --- a/shop/itemqalist.php +++ b/shop/itemqalist.php @@ -41,6 +41,9 @@ if (!$sst) { $sst = "a.iq_id"; $sod = "desc"; } +// 정렬 컬럼/방향 화이트리스트 +$sst = in_array($sst, array('a.iq_id', 'a.iq_datetime', 'a.it_id', 'b.it_name'), true) ? $sst : 'a.iq_id'; +$sod = preg_match("/^(asc|desc)$/i", $sod) ? $sod : 'desc'; $sql_order = " order by $sst $sod "; $sql = " select count(*) as cnt diff --git a/shop/itemuselist.php b/shop/itemuselist.php index a4d2b43bd..aadc0ba15 100644 --- a/shop/itemuselist.php +++ b/shop/itemuselist.php @@ -41,6 +41,9 @@ if (!$sst) { $sst = "a.is_id"; $sod = "desc"; } +// 정렬 컬럼/방향 화이트리스트 +$sst = in_array($sst, array('a.is_id', 'a.is_datetime', 'a.is_score', 'a.it_id', 'b.it_name'), true) ? $sst : 'a.is_id'; +$sod = preg_match("/^(asc|desc)$/i", $sod) ? $sod : 'desc'; $sql_order = " order by $sst $sod "; $sql = " select count(*) as cnt