• 一起谈.NET技术,ASP.NET 安全漏洞临时解决方案 狼人:


      在上周五一个安全会议上披露了微软ASP.NET的一个安全漏洞,利用该漏洞攻击者可以请求并下载一些ASP.NET Web.config文件,攻击者可以发送密文并根据默认错误页信息来得到Machine Key。微软目前并没有新的补丁下载,但ScottGu在自己的博客中给出了一个临时解决方案,这里简单翻译一下,大家可做参考。

      在ASP.NET 1.1 到 ASP.NET 3.5中,可以通过在Web.config中创建<customErrors>节点来解决,注意,ErrorMode必须设置为On,且对于所有的错误都转向同一个错误页,主要是防止攻击者根据不同的错误也跳转来猜测服务器发生了什么错误:

    <configuration>
    <
    system.web>
    <
    customErrors mode="On" defaultRedirect="~/error.html" />
    </
    system.web>
    </
    configuration>

      在ASP.NET 3.5 SP1到ASP.NET 4.0中,在Web.config中创建<customErrors>节点,设置ErrorMode为On,设置RedirectMode模式为ResponseRewrite,对于所有的错误跳转到同一个错误页:

    <configuration>
    <
    system.web>
    <
    customErrors mode="On" redirectMode="ResponseRewrite"
    defaultRedirect="~/error.aspx" />
    </
    system.web>
    </
    configuration>

      并且ScottGu还建议在错误页的Page_Load()事件中加上如下代码:

    <%@ Page Language="C#" AutoEventWireup="true" %>
    <%
    @ Import Namespace="System.Security.Cryptography" %>
    <%
    @ Import Namespace="System.Threading" %><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>

    <html>
    <
    head id="Head1" runat="server">
    <
    title>Error</title>
    </
    head>
    <
    body>
    <
    div>
    An error occurred while processing your request.
    </div>
    </
    body>
    </
    html>

      另外ScottGu也提供了一个vbs脚本,可以用来测试服务器上ASP.NET 应用程序的<customErrors>节点配置,大家可以到这里下载。

      参考信息:

      1. Important: ASP.NET Security Vulnerability
      2. Microsoft Security Advisory 2416728
      3. Understanding the ASP.NET Vulnerability

      4. Microsoft Security Response Center Blog Post

  • 相关阅读:
    js 生成随机数
    解决微信浏览器无法使用reload()刷新页面
    js 去除左右空格
    小程序开发入门-第一天
    我的第一个JSP——动态web
    2019-3-6 复制粘贴
    2019-2-19 异常练习
    2019-1-19 object祖宗类的equals重写
    2019-1-15 课堂笔记
    2019-1-15 课后作业
  • 原文地址:https://www.cnblogs.com/waw/p/2162652.html
Copyright © 2020-2023  润新知