When its Necessary to Protect Forms with Token (CSRF attacks)?

坚强是说给别人听的谎言 提交于 2019-12-05 16:02:08

Generally speaking, you want to protect your form anytime its submission will result in a change of content/state; be it adding it, removing it, editing it or sharing it with an external source ("share on xyz !").

An exemple of forms you wouldn't need to protect is a search box, since it doesn't result in any change of content.

If you're unsure, any form which will result in something being saved/deleted (whether it's on your site or not) should be protected.

And if you are really unsure just add the token, doesn't cost anything to be safe.

The danger that CSRF tries to prevent is when you have the following situation:

  1. The user has signed-in or whatever, and has a certain level of authority
  2. The bad guy exploits that authority without the user's permission

Sometimes this is by tricking the user into making an HTTP request without knowing it, for example in an image's source attribute.

The forms you want to protect are the forms that require this authority.

On the crazy, off-chance that this didn't actually make sense, Chris Shiflett has an awesome article on CSRF (which you may very well have already read :/)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!