ASP.Net MVC:通过 HTTP_REFERER 将 JSON 请求锁定到站点内
假设我有一个 ASP.Net MVC 站点。如何锁定控制器方法(可能使用操作上的属性)以便 HTTP_REFERER 必须指向我的站点?
扩展一下:
我的控制器上有许多标记为 [Authorize] 的 JSON 操作,以防止 uncookied* 用户进入。
有人偷偷摸摸 构建攻击者网页并将其通过电子邮件发送给登录我网站的用户。该页面包含一个从我的 JSON 控制器操作获取的脚本。这会导致用户的浏览器将登录的 cookie 发送到我的授权控制器方法,将该用户的数据返回到攻击者的网页,然后他们可以读取该数据并将其传递到其他地方。
如果我可以锁定这些请求,以便 HTTP_REFERER 必须指向我的站点,则可以防止请求 JSON 的跨站点攻击。最简单的方法是什么?
请注意,我显然不想锁定所有请求、JSON、授权或否 - 人们仍然需要能够链接到该网站。但是,除了我们网站上的页面之外,任何授权 JSON 请求都不应被访问。
*是的,这个词是我编造的。
Suppose I have an ASP.Net MVC site. How do I lock controller methods (perhaps with an Attribute on the Action) so that HTTP_REFERER must point to my site?
To expand:
I have many JSON actions on my Controllers that are marked [Authorize], to prevent an uncookied* user from getting in.
Someone sneaky builds an attacker webpage and emails it to a user logged-in to my site. That page includes a script that fetches from my JSON Controller action. That causes the user's browser to send a logged-in cookie to my authorized controller method, getting that user's data back to the attacker's webpage, which they can then read and pass elsewhere.
If I could just lock these requests so that HTTP_REFERER must point to my site, a cross-site attack to request the JSON would be prevented. What's the simplest way?
Note that I obviously don't want to lock all requests, JSON, Authorized, or no - people still need to be able to link to the site. But no Authorized JSON request should ever be accessible from anything but pages on our site.
*Yes I made this word up.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论