[Spring Security] CSRF와 XSS 공격

Jeheon Park·2021년 10월 14일
0

문제점

Spring Security를 공부하던 도중 Spring Security는 CSRF 공격을 막기 위해서 CSRF 토큰을 사용해서 요청이 공격자에서 온것이 아니라 고객에게서 온것을 확인한다는 것을 배웠다. 하지만, CSRF 토큰을 탈취하면 말짱꽝 아닌가? 라는 생각이 들었다.

  • csrf 공격의 정의

    Cross-Site Request Forgery (CSRF) is an attack that forces an end user to execute unwanted actions on a web application in which they're currently authenticated. CSRF attacks specifically target state-changing requests, not theft of data, since the attacker has no way to see the response to the forged request. With a little help of social engineering (such as sending a link via email or chat), an attacker may trick the users of a web application into executing actions of the attacker's choosing. If the victim is a normal user, a successful CSRF attack can force the user to perform state changing requests like transferring funds, changing their email address, and so forth. If the victim is an administrative account, CSRF can compromise the entire web application.

  • https://owasp.org/www-community/crsf

해결방안

사실 문제가 그렇게 간단하지 않았다. CSRF 토큰을 탈취할려면 두가지 방법이 있는데 해당 사이트에 스크립트를 인젝션(XSS) 하거나 커널에 멀웨어를 심어서 메모리를 직접 탈취하는 것이다. 따라서 CSRF 토큰 만으로 해당 공격을 쉽게 막아낼 수 없다는것을 알아야한다. XSS 취약점을 보완해야하고 네트워크 상에서 따라 들어오는 멀웨어를 사전에 차단해야한다. XSS 취약점은 입력값이 무제한으로 들어오거나 치환하지 않고 사용하는 것 등이 있다.

ps. 보안에 대해서 조금더 공부해야겠다는 생각이들었다.

출처

https://stackoverflow.com/questions/39536888/steal-csrf-token
http://blog.plura.io/?p=7614

profile
개발자

0개의 댓글