【发布时间】:2016-06-09 21:40:39
【问题描述】:
我在我的网站上使用 AJAX 并使用令牌来防止 CSRF。 使用不同的 HTTP 方法而不是 POST 来增加对 CSRF 的保护是否有任何意义?或任何其他攻击?
假设: 我们使用不同的安全令牌和恒定的 HTTP 方法。为什么不让它可变呢? 如果坏人通过 POST 方法发送数据,但服务器等待该特定用户的 PUT 方法。
【问题讨论】:
-
为什么不google呢?
-
当我询问 HTTP 方法时,它都是关于安全令牌的
-
An alternate defense which is particularly well suited for AJAX endpoints is the use of a custom request header. This defense relies on the same-origin policy (SOP) restriction that only JavaScript can be used to add a custom header, and only within its origin. By default, browsers don't allow JavaScript to make cross origin requests. A particularly attractive custom header and value to use is:X-Requested-With: XMLHttpRequest对我来说似乎是一种 HTTP 方法。谷歌上的第一篇文章。不过,仅将其用作检查将是不好的做法。 -
对我来说似乎是自定义标头中的一个额外标记。
标签: ajax xmlhttprequest xss csrf csrf-protection