我有一个运行在IIS6.0上的ASP.NET 4.0MVC web应用程序,它的webconfig自定义错误部分为:
<customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="/Home/Error">
<error statusCode="403" redirect="/Home/Error"/>
<error statusCode="404" redirect="/Home/Error"/>
</customErrors>和一个如下所示的error.aspx页面:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<System.Web.Mvc.HandleErrorInfo>" %>
<%@ Import Namespace="System.Security.Cryptography" %>
<%@ Import Namespace="System.Threading" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Error
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Error Processing your request.</h2>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Scripts" runat="server">
<script runat="server">
void Page_Load() {
byte[] delay = new byte[1];
RandomNumberGenerator prng = new RNGCryptoServiceProvider();
prng.GetBytes(delay);
Thread.Sleep((int)delay[0]);
IDisposable disposable = prng as IDisposable;
if (disposable != null) { disposable.Dispose(); }
}
</script>
</asp:Content>每当我在webconfig自定义错误部分包含上面的"redirectMode="ResponseRewrite"“时,重定向到我的自定义错误页面不再起作用,并且我得到页面错误”redirectMode= error in "/“应用程序资源找不到”。事实上,控制器的动作也被忽略了。当我接受这个设置时,我们的一切都会正常工作。我正在尝试整合Scott Gu针对此处列出的Asp.net安全漏洞的解决方案:http://weblogs.asp.net/scottgu/archive/2010/09/18/important-asp-net-security-vulnerability.aspx
任何帮助都将不胜感激。谢谢,比利
发布于 2010-09-23 22:55:57
不幸的是,根据Scott Guthrie的说法,在<customErrors>块中不能有任何<error>标记。他们肯定在开发补丁,但同时,您必须使用一个非常简单的<customErrors>部分,如下所示:
<customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="~/error.aspx" />发布于 2010-09-28 02:53:37
当我试图在我们的MVC应用程序上实现它时,我遇到的问题是我们使用了一个MVC URL,它需要路由才能作为defaultRedirect工作。不幸的是,由于server.transfer是使用ResponseRewrite redirectMode执行的,所以这不起作用。相反,我不得不让错误的url直接指向aspx文件。此外,您不再拥有访问会话的权限,这是人们在使用ResponseRewrite redirectMode时经常遇到的另一个问题。
发布于 2010-09-25 03:22:53
我也在寻找同样的答案。不过,安德森的回答并不准确。Scott建议响应代码的同质性。他们的.vbs测试脚本会查找几个条件。404和500错误代码是他寻找的全部重定向。如果它们是相同的,则脚本是快乐的。如果其中一个为null,则另一个必须与默认重定向匹配。同样,这也是对同质性的测试。只要您的404和500响应无法区分,他的脚本就会为您的代码开绿灯。
ResponseRewrite的值似乎是要绕过IIS返回的302响应。我估计302可以在任何已处理的404或500错误之前返回,并为攻击者提供时间信息。我不确定你能不能没有ResponseRewrite (微软肯定说你不能)。
https://stackoverflow.com/questions/3779581
复制相似问题