Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于【Apache HTTPD 未知后缀解析漏洞】的配置与实际漏洞场景有偏差问题 #93

Open
c0ny1 opened this issue Jan 3, 2019 · 9 comments

Comments

@c0ny1
Copy link

c0ny1 commented Jan 3, 2019

经过测试,认为和真实漏洞环境有些偏差,觉得apache配置文件有问题。具体说明如下:


都知道apache的解析漏洞依赖于一个特性: Apache默认一个文件可以有多个以点分割的后缀,当最右边的后缀无法识别(不在mime.types文件内),则继续向左识别,直到识别到合法后缀才进行解析。
而这个特性源于apache的配置。

也就是说如果分别访问存在漏洞的环境下的a.php.jpga.php.xxx。那么a.php.jpg会被识别为按照jpg图片进行解析,而a.php.xxx才会被当成php脚本进行解析。

看了下vulhub下的Apache HTTPD 未知后缀解析漏洞的配置如下:

AddHandler application/x-httpd-php .php

经过测试问题来了,a.php.jpga.php.xxx都被当成php脚本进行解析了。这显然不太符合实际环境中Apache HTTPD 未知后缀解析漏洞的中间件特性。

@c0ny1 c0ny1 changed the title 关于【Apache HTTPD 未知后缀解析漏洞】的配置于实际漏洞场景有偏差问题 关于【Apache HTTPD 未知后缀解析漏洞】的配置与实际漏洞场景有偏差问题 Jan 3, 2019
@phith0n
Copy link
Member

phith0n commented Jan 3, 2019

确实不能称为“未知后缀解析漏洞”,因为这个漏洞环境不管是何种后缀,都会被解析。(只要没有设置其他的Handler)


说明一下Apache的解析方式。你说的这个例子涉及两个指令:

  • AddType
  • AddHandler

前者设置一个后缀的mime-type,后者设置一个后缀的处理器。

就你举得这个例子而言,.jpg对应image/jpeg,是AddType进行设置的;而.php对应的处理器application/x-httpd-php,是AddHandler设置的,二者不冲突。但因为application/x-httpd-php返回的content-type覆盖了image/jpeg,所以最后显示出来是一个html。

我们引用文档中一段原文来解释在多个后缀下如何处理:

Care should be taken when a file with multiple extensions gets associated with both a media-type and a handler. This will usually result in the request being handled by the module associated with the handler. For example, if the .imap extension is mapped to the handler imap-file (from mod_imagemap) and the .html extension is mapped to the media-type text/html, then the file world.imap.html will be associated with both the imap-file handler and text/html media-type. When it is processed, the imap-file handler will be used, and so it will be treated as a mod_imagemap imagemap file.

所以这个环境本身是没有问题的,就是标题不太准确。

@phith0n
Copy link
Member

phith0n commented Jan 3, 2019

实际环境中的“未知后缀解析漏洞”,可能是另一种漏洞。我暂时没找到复现环境,期待你能提供相关的测试站点或配置文件。

@c0ny1
Copy link
Author

c0ny1 commented Jan 3, 2019

    phpstudy官方集成环境的这个版本就存在apache的解析漏洞,下载地址:
http://phpstudy.php.cn/phpstudy/phpStudy(PHP5.2).zip

    我也在制作实际环境中的“未知后缀解析漏洞”的docker镜像,无奈上网并没有提起具体如何配置才导致漏洞。明天看下表哥提供的资料,下一步准备研究下apache的配置,有进展再来交流。

@phith0n
Copy link
Member

phith0n commented Jan 3, 2019

好的,明天搭建一下试试。

@phith0n phith0n closed this as completed in 464e6bd Jan 3, 2019
@phith0n phith0n reopened this Jan 3, 2019
@phith0n
Copy link
Member

phith0n commented Jan 3, 2019

后续相关讨论,可以继续在这个issue中进行。

@c0ny1
Copy link
Author

c0ny1 commented Jan 3, 2019

ok

@leezp
Copy link

leezp commented Jun 29, 2020

各位表哥,后续呢

@hongwei520
Copy link

此贴终结 哈哈

@tiantop
Copy link

tiantop commented Mar 31, 2022

表哥,后续呢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants