如何测试我的 wasp.net MVC 3 网站是否受到 CSRF 攻击

发布于 2024-12-27 17:38:59 字数 137 浏览 3 评论 0原文

我在接受用户输入的所有视图中使用防伪造令牌 html 帮助程序,并在相关操作方法上使用 [ValidateAntiForgeryToken],以防止任何可能的 CSRF 攻击。 但我面临的问题是如何测试这些代码行是否运行良好并且它们将防止任何可能的攻击。 BR

I am using the Anti forgery token html helper at all the views that accept user input and the [ValidateAntiForgeryToken] on the associated action methods to protect from any possible CSRF attacks.
But i am facing a problem on how i can test that these line of codes is working well and they will prevent any possible attack.
BR

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

∞琼窗梦回ˉ 2025-01-03 17:39:00

您可以编写一个可以在任何地方托管的静态 HTML 页面。甚至不需要网络服务器,您可以使用 file:///c:/foo.htm 例如。在此 HTML 页面中创建一个简单的

,它将包含与您想要针对 CSRF 进行测试的某些 ASP.NET MVC 视图相同的输入元素(相同的名称)。表单的 action 将指向与 ASP.NET MVC 视图相同的操作。然后提交表格。如果抛出 AntiForgeryToken 异常,那么您是安全的。另一方面,如果执行了控制器操作,则您很容易受到 CSRF 攻击。

要了解有关 CSRF 的更多信息,请参阅以下文章。 Jeff Atwood 还 博客它。

并且不要仅仅期望您运行一些神奇的工具,它会显示绿灯或红灯。如果存在这样的工具,黑客就不会存在,因为所有网站都会受到保护,他们不会有任何东西可以黑客攻击。

确保您的网站安全的最佳方法是咨询安全专家,他们将进行广泛的审核和代码审查。

You could write a static HTML page that you could host just anywhere. Don't even need a web server, you could use the file:///c:/foo.htm for example. In this HTML page create a simple <form> that will contain the same input elements (same names) as some of the ASP.NET MVC views that you want to test against CSRF. The action of the form will point to the same action as your ASP.NET MVC views. Then submit the form. If an AntiForgeryToken exception is thrown, you are safe. If on the other hand the controller action is executed, you are vulnerable to a CSRF attack.

To learn more about CSRF look at the following article. Jeff Atwood also blogged about it.

And don't just expect some miracle tool that you will run and it will show a green or red light. If such tool existed, hackers wouldn't exist, as all sites would be protected and they wouldn't have anything to hack.

The best way to ensure that your site is safe is to consult with a security specialist who will perform an extensive audit and code review.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文