简体   繁体   English

优雅地处理Umbraco CMS中潜在危险的Request.Form值

[英]Gracefully handling potentially dangerous Request.Form values in Umbraco CMS

I am close to launching my first Umbraco site, but am just running through the last-minute testing. 我即将启动我的第一个Umbraco网站,但正在最后一刻进行测试。

I tried being a 'hacker' and entering dangerous stuff in my search form and contact form, which .NET blocked with a big yellow error page and the following error: 我尝试成为一名“黑客”,并在搜索表单和联系表单中输入了危险的东西,.NET阻止了该错误,并显示了一个大的黄色错误页面和以下错误:

A potentially dangerous Request.Form value was detected from the client (Subject="test <b> 'haha").

I have researched this error and found many solutions where people post ways of disabling this error, but I am concerned that if I do, it will allow malicious data to be posted, as I don't (knowingly) have anything in place to safely handle it. 我研究了此错误,并找到了许多解决方案,人们在其中发布了禁用此错误的方法,但我担心如果这样做,它将允许发布恶意数据,因为我(不知道)没有适当的位置来安全处理它。

I am using uContactor for the contact form, and the search facility is based on the tutorial here . 我正在使用uContactor作为联系表单,并且搜索功能基于此处的教程。

In my previous days developing in classic ASP, it was just a case of HTML-Encoding the request (and replacing a few naughty characters such as < and > etc) but I would appreciate some advice on the best way to handle such things on an ASP.NET MVC / Umbraco site, as it's still very new to me. 在前几天使用经典ASP开发的过程中,这只是对请求进行HTML编码的一种情况(并替换了一些顽皮的字符,例如<和>等),但我希望您能从中找到一些有关处理此类问题的最佳方法的建议ASP.NET MVC / Umbraco网站,因为它对我来说仍然很新。

(I don't want to prevent people from entering these things, just for the site to handle it safely and gracefully). (我不想阻止人们输入这些东西,只是为了网站可以安全优雅地处理它们)。 Thank you. 谢谢。

This error checking actually happens a level above Umbraco. 此错误检查实际上发生在Umbraco之上的级别。 This gets picked up by ASP.Net before Umbraco runs. 在Umbraco运行之前,ASP.Net会对此进行处理。

You can turn it off as you've discovered, but whether or not the site will handle the potentially dangerous input correctly will be down to what the pages do with the data and how they store/render it. 您可以根据自己的发现将其关闭,但是网站是否会正确处理潜在的危险输入将取决于页面对数据的处理方式以及它们如何存储/呈现数据。

You can turn it off on a per page basis, that way you can allow it on pages where you may want invalid characters to be submitted (eg if you have a field that accepts HTML). 您可以逐页关闭它,这样您就可以在可能要提交无效字符的页面上启用它(例如,如果您的字段接受HTML)。 I'd say this is probably better that blanket disabling it. 我想说这可能比完全禁用它更好。 This does mean it's down to you to mitigate against any dangerous input however. 但这确实意味着您要减轻任何危险的输入。

The question here shows you how to disable request validation for specific controller methods in MVC: 这里的问题向您展示了如何为MVC中的特定控制器方法禁用请求验证:

I can't turn off Request Validation for an ASP.NET MVC Controller 我无法关闭ASP.NET MVC控制器的请求验证

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM