
CVE-2023-45503 참조
Macrob7 Macs Framework Content Management System(CMS) 1.1.4f 및 이전 버전에서는 사용자 입력의 안전하지 않은 처리로 인해 16개의 SQL 인젝션 취약점이 발생합니다. 임의의 SQL 쿼리를 실행할 수 있게 되면 사용자 비밀번호 해시를 포함한 개인 데이터가 유출되고 다른 사용자의 자격 증명과 권한 수준을 수정할 수 있습니다. 그 영향에는 권한 상승과 잠재적 원격 코드 실행(RCE)이 포함될 수 있습니다.
각 영향받는 엔드포인트, 취약한 매개변수 및 취약한 함수를 설명하는 스프레드시트는 이 링크에서 확인할 수 있습니다.
CWE 분류: CWE-89: SQL 명령에서 사용되는 특수 요소의 부적절한 중화('SQL 인젝션')
보고자: Ally Petitt
영향받는 제품: Macrob7 Macs CMS
영향받는 버전: 1.1.4f 및 이전 버전
내가 발견한 16개 사례에서 사용자 입력은 적절한 정화(sanitization)나 매개변수화(parameterization) 없이 수신되었습니다. 예를 들어, 이 CMS의 "Forgot Password" 기능에서는 이메일 주소를 요청합니다.
Application/plugins/CMS/controllers/CMS.php:224
public function forgotPasswordProcess()
{
$this->loadModels();
$emailAddress = Post::getByKey('emailAddress');
$user = $this->usersModel->getUserByEmailAddress($emailAddress);
이메일 주소는 getUserByEmailAddress() 메서드로 전달되며, 이 메서드는 이메일을 주입된 SQL 쿼리로부터 제대로 보호하지 못하는 selectSingle() 메서드로 전달합니다.
Application/plugins/CMS/models/Users_Model.php:41
public function getUserByEmailAddress($emailAddress)
{
return $this->selectSingle( $this->getCMSTableNameUsers(), array('EmailAddress'=>$emailAddress));
}
그런 다음 selectSingle()은 전달받은 사용자 입력을 사용해 select()를 호출합니다.
Application/core/DB.php:200
public function selectSingle($tableName, array $where = array(), array $fields = array('*'))
{
$return = $this->select($tableName, $where, $fields);
$single = NULL;
if( count($return) > 0 )
$single = $return[0];
return $single;
}
취약한 select() 함수는 전달된 매개변수를 이어 붙여 이후에 실행되는 SQL 쿼리를 생성합니다.
Application/core/DB.php:186
public function select($tableName, array $where = array(), array $fields = array('*'))
{
$fieldsString = $this->generatePair($fields, ',');
$whereString = $this->generateKeyValuePair($where, '=', 'AND');
$sql = 'SELECT '.$fieldsString.' FROM '.$tableName;
if($whereString !='')
$whereString = ' WHERE '.$whereString;
$sql = $sql.' '.$whereString.';';
return $this->execute($sql)->fetchAll($this->returnType, $this->className);
}
입력값에 대한 정화(sanitization), 검증 및 매개변수화가 이루어지지 않았기 때문에 이 함수는 SQL 인젝션 공격에 여전히 취약합니다.
안타깝게도 이 CMS의 유지보수 부족으로 인해 패치된 업데이트는 제공되지 않습니다. 개별 사용자는 사용자 입력을 데이터베이스에 전달할 때 연결(concatenation)에 의존하는 대신 매개변수화된 SQL 쿼리를 포함하도록 코드를 수정할 수 있습니다. 준비된 문(Prepared statements)은 이를 달성할 수 있는 완화 조치의 한 예입니다.