Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSRF #62

Open
conan1992 opened this issue Aug 13, 2020 · 0 comments
Open

CSRF #62

conan1992 opened this issue Aug 13, 2020 · 0 comments
Labels
security 安全

Comments

@conan1992
Copy link
Owner

conan1992 commented Aug 13, 2020

CSRF

CSRF(Cross-site request forgery)跨站请求伪造:攻击者诱导受害者进入第三方网站,在第三方网站中,向被攻击网站发送跨站请求。利用受害者在被攻击网站已经获取的注册凭证,绕过后台的用户验证,达到冒充用户对被攻击的网站执行某项操作的目的。

类型

  • GET类型的CSRF
 <img src="http://bank.example/withdraw?amount=10000&for=hacker" > 
  • POST类型的CSRF
 <form action="http://bank.example/withdraw" method=POST>
    <input type="hidden" name="account" value="xiaoming" />
    <input type="hidden" name="amount" value="10000" />
    <input type="hidden" name="for" value="hacker" />
</form>
<script> document.forms[0].submit(); </script> 
  • 链接类型的CSRF

特点

  • 攻击一般发起在第三方网站,而不是被攻击的网站。被攻击的网站无法防止攻击发生。
  • 攻击利用受害者在被攻击网站的登录凭证,冒充受害者提交操作;而不是直接窃取数据。
  • 整个过程攻击者并不能获取到受害者的登录凭证,仅仅是“冒用”。
  • 跨站请求可以用各种方式:图片URL、超链接、CORS、Form提交等等。部分请求方式可以直接嵌入在第三方论坛、文章中,难以进行追踪

防护策略

  • 同源检测
    Origin Header;Referer Header
  • token验证
  • Samesite Cookie

参考

@conan1992 conan1992 added the security 安全 label Aug 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
security 安全
Projects
None yet
Development

No branches or pull requests

1 participant