URL 中的 %2F 禁止 IIS 403

IIS 403 forbidden with %2F in the URL

我有 IIS (Microsoft-IIS/7.5) return 返回 403 禁止,我无法弄清楚为什么。我已经将它缩小到 %2F 但只有当它前面有一个字母时。知道是什么原因造成的吗?

这些工作...

但是如果你在 %2F 前面放任何一个字母,它就会失败并返回 403。

这些失败...

谢谢!

更新: 我已经排除了 ColdFusion,因为它给出了相同的 403:http://example.com/mySite123/indexdotcfm?x=a%2F

更新:

Top Level IIs:
Checked:  
  Allow unlisted file name extensions
  Allow unlisted verbs
  Allow high-bit characters
Unchecked:
  Allow double escaping

Request Limits:
Maximum allowed content length (Bytes):  30000000 Maximum URL length (Bytes):
4096 Maximum query string (Bytes):  2048

Sites
mySite123:
  Checked:  
    Allow unlisted verbs
    Allow high-bit characters
  Unchecked:
    Allow unlisted file name extensions
    Allow double escaping

  Request Limits:
    Maximum allowed content length (Bytes):  2147483647
    Maximum URL length (Bytes):  4096
    Maximum query string (Bytes):  2048

  Deny URL
    /CFIDE/Administrator
    /CFIDE/adminapi

更新: 如果我更改我正在访问的目录,我可以将 403 更改为 404。示例:

这 return 是预期的 404: http://www.example.com/anything.anything?anything=x%2Fanything

这 return 是一个 403: http://www.example.com/mySite123/anything.anything?anything=x%2Fanything

那么可以安全地假设 403 问题与 "mySite123" 虚拟目录设置有关吗?

我很确定您收到的 403 Forbidden 响应是 IIS 的一项安全功能。这是一个已知的攻击向量。字符序列 %2F 只是 /(正斜杠)字符的 URL 编码表示。显然,这对浏览器和互联网具有特殊意义。它用于目录遍历。在 URL 中编码特殊字符是一种绕过一些基本安全措施的黑客技巧。请参阅 Path Traversal from OWASP. From the Full text of "The Web Application Hacker Handbook"(该页面的一半左右):

Chapter 10 Attacking Back-End Components 575

HACK STEPS

  1. Always try path traversal sequences using both forward slashes and back slashes. Many input filters check for only one of these, when the filesystem may support both.

  2. Try simple URL-encoded representations of traversal sequences using the following encodings. Be sure to encode every single slash and dot within your input:

    Dot — %2e
    Forward slash — %2f
    Backslash — %5c

  3. Try using 1 6-bit Unicode encoding:

    Dot — %u002e
    Forward slash — %u22l5
    Backslash — %u22l6

  4. Try double URL encoding:

    Dot-%252e
    Forward slash — %252f
    Backslash — %255c

  5. Try overlong UTF-8 Unicode encoding:

    Dot — %c0%2e, %e0%40%ae, %c0ae, and so on
    Forward slash — %cO%af , %e0%80%af , %c0%2f , and so on
    Backslash — %c0%5c, %c0%80%5c, and so on

    ...

粗体是我的重点)

您可能会想出一种允许这样做的方法,但您为什么会这样做?我不推荐它。您想向潜在攻击开放您的服务器吗?我认为最好一起避免这个 URL 序列。 URL 查询字符串中真的需要正斜杠字符吗?与其寻找在查询字符串中允许此字符的方法,不如使用另一种不那么危险且不会暴露您的服务器的方法。对于那个特定的 URL 变量,您可以查找这个不同的字符并将其替换为您在服务器端需要的字符。类似于:

而不是

http://example.com/index.cfm?x=a%2Fblah

使用

http://example.com/index.cfm?x=a-blah

然后在服务器上您知道 x 变量中的 -(破折号)字符,因此您将其替换为服务器上的 /(正斜杠)字符.或者需要什么字符。

在 ColdFusion 中

<cfset x = Replace(URL.x,"-","/","ALL") />

请务必使用该字符串中不存在的一些独特字符。 永远记住清理服务器上所有用户提供的输入。

以下是我发现的一些关于 URL 中易受攻击的 %2f 字符序列的参考资料:

Component titles containing '/' (forward slash) characters

IIS URL Decoding Vulnerability

URL-encoded slash in URL

Generic Google search about the topic

请注意,上面的一些参考资料与 IIS 以外的 Web 服务器相关,但它们表明存在漏洞。

您可以尝试的其他方法是对序列进行双重转义。因此,您有 %252F 而不是 %2f%25 是百分号)。但是您也需要在 IIS 中进行更改以支持此功能。参考 - if I name an image with a %2F, I cannot access it and when navigating to it, I get a 404. I think this would be a last resort though. Double Encoding

与我共事的服务器管理员表示:

"The problem stopped after an update was done to the JAVA.

I installed the latest security update to Java 1.7 (update 25 - 64-bit) Saturday.

After the web server was restarted the problem is now gone."

更新:几天前我接受了这个作为答案,但现在问题似乎又回来了。

更新(2015 年 8 月 31 日): 已解决。这与其他答案提到的内容无关。数据中心防火墙人员设置了一些无效 settings/rules。我无法详细说明。调整防火墙规则是解决方法。

只是为了向该线程添加一些细节,%2f(如前所述,它只是 / 的编码版本)困扰了 Microsoft 一段时间,目录遍历漏洞允许黑客访问 Web 目录之外的文件。流行的入侵防御系统(如 Snort) have rules to block this sort of behavior. Here is a detailed write up of the issue 以及攻击字符串和安全建议的历史示例。%2f 编码给 Web 服务器管理员、安全管理员带来了多年的痛苦(以及攻击的变体时至今日仍被积极利用。

总而言之,我正在努力解决 SharePoint 上的 TermStoreManager 问题,并且 发现我的托管元数据应用程序代理在查看 使用 Get-SPTaxonomySession 的 TaxonomySession 内容。

但是,由于某种原因,术语库管理器页面未显示任何术语集。

问题恰好是术语库管理器代码 javascript 的 URL!

https://SharepointSite/_layouts/15/termstoremanager.js?rev=J%2Fry%2BNGddRWsDNgR25iEFA%3D%3D

J%2F 在我的服务器上触发了主机入侵防御服务 (HIP) 运行 以阻止 "Standard SQL Injection" 攻击请求。

我明天会和我的 firewall/HIPs 人谈谈。感谢 post!它帮助我找到了解决类似问题的正确方向。