English 中文(简体)
3. 午线内的双逃顺序: 要求过滤模块被配置,以否定包含双重越狱顺序的请求。
原标题:double escape sequence inside a url : The request filtering module is configured to deny a request that contains a double escape sequence

在我的协会上。 NET MVC的申请,我试图实施如下的URL:

/product/tags/for+families

当我试图用缺省组合处理我的申请时,我正在用404.11《反应法》获取这一信息:

www.un.org/Depts/DGACM/index_spanish.htm HTTP Error 404.11 - Not Creat

The request filtering module is configured to deny a request that contains a double escape sequence.

我可以通过在我的网站上执行以下守则来克服这一错误:

  <system.webServer>
    <security>
      <requestFiltering allowDoubleEscaping="true" />
    </security>
  </system.webServer>

因此,现在我没有看到任何<代码>404.11。

我所想知道的是,在执行过程中,我打开了什么样的安全漏洞。

BTW,我的申请载于<编码>。 净额框架4.0和在IIS 7.5/code>下运行。

最佳回答

您可能打开的安全漏洞与代码注射有关,即超文本注射、 Java本投射或注射。

缺省环境通过不允许共同的注射战略发挥作用,使你免受半高效的袭击。 你越发越权,就越需要思考一下你通过URLs、GET请求询问、POST请求数据、HTTP负责人等等提供的投入。

例如,如果你正在根据<代码>id进行动态查询。 您的行动方法参数,如:

public ActionResult Tags(string id)
{
    var sql = "SELECT * FROM Tags Where tagName =  " + id + " ";
    // DO STUFF...
}

(...) 是NOT的好主意,即由......实施的违约保护。 NET框架可能阻止一些较为危险的情景,如要求使用URL的用户:

/product/tags/1%27;drop%20table%20Tags;%20--

整个想法是将陶器和其他对行动方法的投入视为可能的威胁。 缺省的安全环境确实为你提供了一些保护。 每次出现违约情况时,你都会变换,使你需要人工处理的潜在弊端更加可能。

我假定,你不以这种方式提出问题。 但是,当你将用户投入储存在你的数据库中,然后展示这些投入时,便会出现更加棘手的问题。 男性用户可以在你的数据库中储存 Java本或超文本,而该数据库则没有编码,从而威胁到你系统的其他用户。

问题回答

Security Risk

<代码>allowDoubleEscaping只适用于path(cs-uri-stem),最好用。 这项技术用于通过统一法两次合并申请来绕过安全控制。 举例说:

/product/tags/for+families --> /product/tags/for%2Bfamilies --> /product/tags/for%252Bfamilies

维护者对<代码>/产品/标签/for+families有具体的安全控制。 一项请求是<代码>/产品/标签/for%252Bfamilies,尽管上述安全管制没有加以控制,但该编码是相同的资源。 我使用了一般的安全控制术语,因为它们可以要求一个真实的用户、对地库进行检查等。

Why Does IIS Block?

附加标志(+)是每个:

Many URI include components consisting of or delimited by, certain special characters. These characters are called "reserved", since their usage within the URI component is limited to their reserved purpose. If the data for a URI component would conflict with the reserved purpose, then the conflicting data must be escaped before forming the URI.

  reserved    = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
                "$" | ","

Wade Hilmo有一个出色的职称:。 • 国际空间法学会如何在URLs中形成特征。 提供了大量信息和背景。 附加标识的具体内容如下:

因此,允许DoubleEscaping/VerificationNormalization似乎是直截了当的。 我为什么说这会造成混乱? 问题是“+”特性出现在URL中。 “+”的特性似乎已经逃脱,因为它不涉及“%”。 而且,《伦敦刑法》第2396号指出,它是一种保留性质,如果它以逃脱形式(%2b)就可列入《欧洲刑法》。 但是,如果允许DoubleEscaping达到其不实价值,我们甚至会以逃脱的形式阻止它。 这是历史原因: 位于吉大港湾的早期,“+”特性被视为空间特性的短距离。 一些信教者,当获得含有“+”的URL时,会将其改装成一个空间。 出于这一原因,我们认为“+”在URL中是不可靠的。 我找不到任何提到“+”这一处理方法的皇家部队,但网络上有许多人提到它是一种历史行为。

根据我自己的经验,我知道,当国际空间法研究所将申请空间用加标取代。 添加标语可能会造成混淆。

Solution

有三个办法可以确定这一点,还有两种方法仍然使用加标。

  1. <>条码> 这将使你整个网站/申请翻一番。 根据内容,这至少可以说是不可取的。 以下指挥人员将设置<代码>allowDoubleEscaping=true。

    appcmd.exe set config "Default Web Site" -section:system.webServer/security/requestFiltering /allowDoubleEscaping:True
    
  2. alwaysAllowedUrls - Request Filtering provide a Whitelist approach. 加上“URL”通往总是低温的Urls”的道路,这一请求不会受到任何其他请求的过滤环境的检查,也不会在该系统的请求管道中继续。 The concern here is that Request Filtering will noteck the request for:

  • Request Limits: maxContentLength, maxUrl, maxQueryString
  • Verbs
  • Query - query string parameters will not be checked
  • Double Escaping
  • High Bit Characters
  • Request Filtering Rules
  • Request Header Limits

以下指挥部将在Default网站添加/product/tags/for+families

    appcmd.exe set config "Default Web Site" -section:system.webServer/security/requestFiltering /+"alwaysAllowedUrls.[url= /product/tags/for+families ]"
  1. Rename - yes, just rename the file/folder/controller/etc. if possible. This is the easiest solution.

I have made a work arround for this . so when you want to put the encripted string inside the url for(IIS) you have to clean it from dirty :{ ";", "/", "?", ":", "@", "&", "=", "+", "$", "," }; and when you want to decript it and use it again , you have to make it dirty again before decript it (to get the wanted result) .

这里是我的法典,我希望它有助于一些人:

 public static string cleanUpEncription(string encriptedstring)
        {
            string[] dirtyCharacters = { ";", "/", "?", ":", "@", "&", "=", "+", "$", "," };
            string[] cleanCharacters = { "p2n3t4G5l6m","s1l2a3s4h","q1e2st3i4o5n" ,"T22p14nt2s", "a9t" , "a2n3nd","e1q2ua88l","p22l33u1ws","d0l1ar5","c0m8a1a"};

            foreach (string dirtyCharacter in dirtyCharacters)
            {
                encriptedstring=encriptedstring.Replace(dirtyCharacter, cleanCharacters[Array.IndexOf(dirtyCharacters, dirtyCharacter)]);
            }
            return encriptedstring;
        }

        public static string MakeItDirtyAgain(string encriptedString)
        {
            string[] dirtyCharacters = { ";", "/", "?", ":", "@", "&", "=", "+", "$", "," };
            string[] cleanCharacters = { "p2n3t4G5l6m", "s1l2a3s4h", "q1e2st3i4o5n", "T22p14nt2s", "a9t", "a2n3nd", "e1q2ua88l", "p22l33u1ws", "d0l1ar5", "c0m8a1a" };
            foreach (string symbol in cleanCharacters)
            {
                encriptedString = encriptedString.Replace(symbol, dirtyCharacters[Array.IndexOf(cleanCharacters,symbol)]);
            }
            return encriptedString;
        }

统一加密的地体分离:

return HttpServerUtility.UrlTokenEncode(Encoding.UTF8.GetBytes("string"));

1. 编码加密的地体分离:

string x = Encoding.UTF8.GetString(HttpServerUtility.UrlTokenDecode(id));

So I ran into this when I was calling an API from an MVC app. Instead of opening the security hole, I modified my path.

First off, I recommend NOT disabling this setting. It is more appropriate to modify the design of the application/resource (e.g. encode the path, pass the data in a header or in the body).

虽然这是个较老的员额,但我认为,如果你用HttpUtility.UrlPathEncode 系统。

I use RestSharp,用于打电话,因此,我的例子就是利用Request:

var tags = new[] { "for", "family" };
var apiRequest = new RestRequest($"product/tags/{HttpUtility.UrlPathEncode(string.Join("+", tags))}");

由此形成了一条与以下目标相同的道路:

/product/tags/for%2Bfamilies

在另一个说明中,NOT公司根据用户的投入建立了动态查询系统。 You SHOULD总使用SqlParaile。 此外,从安全角度来说,至关重要的是,以适当的编码来恢复这些价值观,以防止注射袭击。

我刚刚提出删除要求。 我并不期望以下工作,因为它是上文提到的 t,但我改变了要求,将价值作为质子传递,并且只要你也把价值编码(否则将+作为空间处理),就会进行罚款。

因此:

[HttpDelete("Example/{id}")]
public async Task<ActionResult<bool>> ExampleAsync(string id)

:

[HttpDelete("Example")]
public async Task<ActionResult<bool>> ExampleAsync([BindRequired] string id)

如果有理由不这样做,请让我知道。

这只是网络框架的一个oke笑:试图在客户中使用ur形码:

Uri uri = CreateUri(REPO_PREFIX + $"Name/{Id}/{WebUtility.UrlEncode(name)}/{WebUtility.UrlEncode(data)}");
client.PutAsync(uri, null);

确实造成这一问题,包括:+

但是,删除了明确的陶器编码:

 Uri uri = CreateUri(REPO_PREFIX + $"Name/{Id}/{name}/{data}");

缩略语

PUT localhost:10000/api/v1/xx/Name/8331/Backxxzzzzz%20afternoon/x HTTP/1.1

i 通过以下方式在原木中倾倒:

        request.AppendLine(Request.Method + " " + Request.Host + Request.Path + " " + Request.Protocol);




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签