sql_query 함수에서 union 관련 질문드립니다.
관련링크
본문
그누4와 그누5 sql_query 함수의 정규식이 조금 틀리더군요
1. 그누보드4
// union의 사용을 허락하지 않습니다.
$sql = preg_replace("#^select.*from.*[^\'\"]union[^\'\"].*#i", "select 1", $sql);
// `information_schema` DB로의 접근을 허락하지 않습니다.
$sql = preg_replace("#^select.*from.*[^\'\"]`?information_schema`?[^\'\"].*#i", "select 1", $sql);
2. 그누보드5
// union의 사용을 허락하지 않습니다.
$sql = preg_replace("#^select.*from.*union.*#i", "select 1", $sql);
// `information_schema` DB로의 접근을 허락하지 않습니다.
$sql = preg_replace("#^select.*from.*where.*`?information_schema`?.*#i", "select 1", $sql);
아래처럼 쿼리문을 작성하고 테스트해보니
select * from g5_board where bo_table = 'union_shop'
1은(그누4) bo_table 에 union 이 포함되어도 해당 결과값이 제대로 나옵니다.
2는(그누5) bo_table 에 union 이 포함되면 select 1 로 나오게 됩니다.
찾아보니 버그게시판에 관련 글이 올라와 있던데 (링크)
보안상 그누보드5처럼 사용하는게 맞을까요?
그렇다면 그누보드4의 해당 함수도 수정해야 되지 않을까요?