
이것은 CVE-2023-27372에 대한 PoC이며 완전한 대화형 셸을 생성합니다.
이는 비밀번호 재설정 기능 (spip.php?page=spip_pass) 내에서 /ecrire/balise/formulaire_.php 파일의 #ENV 태그를 위험하게 사용하는 역직렬화 결함입니다. 구체적으로 다음 라인입니다:
function protege_champ($texte){
if (is_array($texte))
$texte = array_map('protege_champ',$texte);
else {
// ne pas corrompre une valeur serialize
if (preg_match(",^[abis]:\d+[:;],", $texte) AND unserialize($texte)!=false)
return $texte;
$texte = entites_html($texte);
$texte = str_replace("'","'",$texte);
}
return $texte;
}
protege_champ 함수는 여러 결함을 가지고 있습니다. 입력을 검증하는 데 사용되는 정규 표현식(RE) 검사는 결함이 있어 쉽게 우회할 수 있습니다. 이 코드는 적절한 검증 없이 unserialize() 함수를 호출하여 임의 코드 실행을 허용합니다. 수동으로 매우 쉽게 익스플로잇할 수 있습니다. 예를 들어 phpinfo();를 실행하고 싶다면 다음과 같이 할 수 있습니다:
oubli=s:19:"<?phpinfo(); ?>";
서버가 예상된 출력을 반환하면 취약한 것입니다. 어떻게 패치할 수 있을까요? 사실 꽤 간단합니다. 아래에 기본적인 패치를 작성했습니다:
function protege_champ($texte) {
if (is_array($texte)) {
$texte = array_map('protege_champ', $texte);
} else {
if (!isValidInput($texte)) {
$texte = 'Malicious input detected';
} else {
$texte = entites_html($texte);
$texte = str_replace("'", "'", $texte);
}
}
return $texte;
}
패치된 protege_champ() 함수는 입력 검증, 살균 및 악성 입력 처리를 포함합니다.