zoukankan      html  css  js  c++  java
  • 一起谈.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

  • 相关阅读:
    二进制位运算
    Leetcode 373. Find K Pairs with Smallest Sums
    priority_queue的用法
    Leetcode 110. Balanced Binary Tree
    Leetcode 104. Maximum Depth of Binary Tree
    Leetcode 111. Minimum Depth of Binary Tree
    Leetcode 64. Minimum Path Sum
    Leetcode 63. Unique Paths II
    经典的递归练习
    案例:java中的基本排序
  • 原文地址:https://www.cnblogs.com/waw/p/2162652.html
Copyright © 2011-2022 走看看