Announcing the availability of ModSecurity extension for IIS
来源:互联网 发布:海洋电影源码 编辑:程序博客网 时间:2024/06/15 19:03
By:
- Greg Wroblewski, Microsoft Security Engineering Center
- Ryan Barnett, Trustwave SpiderLabs
Vulnerabilities in on-line services, like cross-site scripting, cross-site request forgery, or even information disclosure, are important areas of focus for the Microsoft Security Response Center (MSRC). Over the last few years Microsoft has developed a number of tools capable of mitigating selected web specific vulnerabilities (for example,UrlScan). To help on this front we have participated in a community effort to bring the popular open source moduleModSecurity to the IIS platform. Yesterday atBlack Hat Las Vegas, we have announced the availability of an RC version and we expect that stable release will be available soon.
Installation
Although the source code of ModSecurity’s IIS components is fully published and the binary building process is publicly described (see mod_security/iis/winbuild/howto.txt inSourceForge repository), it is highly not recommended to self-build the module for non-research or non-development purpose.
A standard MSI installer of ModSecurity for IIS 7 and later versions is available fromSourceForge files repository of ModSecurity project and in the future designated maintainers will be keeping it updated with latest patches and minor versions of the module.
Configuration
The IIS installer does not interfere with currently running web applications. This means that the installation process must be followed by an application pool restart or recycling in order to load the new module into the application pool process. For the RC version of the module the restart/recycle step is also highly recommended each time a ModSecurity configuration file has been changed:
After successful load of the module into the application pool process a series of informational events is recorded in the application event log:
Runtime messages and notifications generated during the operational phase, both coming from the user-defined rules and system specific events or errors, are sent to the same application event log repository.
To apply a ModSecurity configuration file to a web application or a path, one has to use IIS configuration schema extension, like in the example below:
<?xml version="1.0" encoding="UTF-8"?><configuration> <system.webServer> <ModSecurity enabled="true" configFile="c:\inetpub\wwwroot\test.conf" /> </system.webServer></configuration>
The c:\inetpub\wwwroot\test.conf config file is a regular ModSecurity configuration containing the same directives as used on the Apache web server.
Examples of Protection
The most common application of ModSecurity is a protection layer called “virtual patching” (see Resources section, [5]). Using two recent vulnerabilities as an example we would like to show how this layer can be specified in an environment with IIS server running with ModSecurity.
CVE-2011-3414
In December 2011 a vulnerability was addressed in ASP.NET that allowed attackers to cause excessive processor load on most ASP.NET web applications. The hash collision issue required attacker to send a large (typically 1MB or 4MB) POST request to the server, with tens of thousands of arguments with specially crafted names. There are at least four ways to mitigate this kind of attack:
- Restrict the request body size.
- Restrict the number of arguments.
- Identify repetitive payloads.
- Check arguments names against PoC data.
The approach of checking for the presence of repetitive payload is the most sophisticated one and it can be implemented in ModSecurity using the following chain of rules:
SecRule &ARGS "@ge 1000" "chain,id:1234,phase:2,t:none,deny,msg:'Possible Hash DoS Attack Identified.',tag:'http://blogs.technet.com/b/srd/archive/2011/12/27/more‑information‑about‑the‑december‑2011‑asp‑net‑vulnerability.aspx?Redirected=true'" SecRule REQUEST_BODY "^\w*?=(.*?)&\w*?=(.*?)&\w*?=(.*?)&\w*?=(.*?)&" "chain,capture" SecRule TX:1 "@streq %{tx.2}" "chain,setvar:tx.hash_dos_match=+1" SecRule TX:2 "@streq %{tx.3}" "chain,setvar:tx.hash_dos_match=+1" SecRule TX:3 "@streq %{tx.4}" "chain,setvar:tx.hash_dos_match=+1" SecRule TX:HASH_DOS_MATCH "@eq 3"
When this rule is loaded into an IIS server configuration and the attack is launched on the protected path, the Windows application event log will record an access denied message from ModSecurity:
At the same time the attacker will see HTTP response 403, stopping the attack before it reaches ASP.NET vulnerable component.
CVE-2012-1859
In July 2012, Microsoft patched a classic case of reflected cross-site scripting vulnerability in Microsoft SharePoint 2010. For the attacks to exploit the vulnerability it was enough to trick user into clicking on a malicious URL, like the one below:
http://sharepoint/_layouts/scriptresx.ashx?culture=en‑us&name=SP.JSGrid.Res&rev=laygpE0lqaosnkB4iqx6mA%3D%3D§ions=All<script>alert(‘Hacked!!!’)</script>z
The script injected by the attacker could gain access to the entire data set available to the victim through the hacked SharePoint server.
One possible way to block this attack is a whitelist approach: let the URL with sections argument that does contain only valid characters pass through, while block all other URLs. Below is a ModSecurity rule implementing this approach for alphanumeric characters:
SecRule REQUEST_FILENAME "@contains /_layouts/scriptresx.ashx" "chain,phase:1,block,msg:'SharePoint Sections Param Violation - Illegal Chars" SecRule ARGS:sections "!@rx ^\w+$"
The rule included through ModSecurity config file into the SharePoint web.config file, generates the following event when any invalid character (indicating possible attack attempt) is discovered in the corresponding SharePoint URL:
Feedback
We encourage you to download and try out the tool. If you have any feedback on your experiences with the tool, you can reach us atswitech@microsoft.com or on the ModSecurity Users Mail-list.
Acknowledgments
The following people have contributed to the multi-platform effort of ModSecurity:
- Microsoft – ModSecurity Port for IIS
- Greg Wroblewski – Senior Security Developer
- Suha Can – Security Researcher / Developer
- Trustwave - ModSecurity
- Ziv Mador – Director of Security Research
- Ryan Barnett – Security Researcher Lead
- Breno Pinto – ModSecurity Researcher & Developer
- Open community - Security Port for Nginx
- Alan Silva - Security Software Engineer at Locaweb
We would like to thank: Wade Hilmo and Nazim Lala, members of the Microsoft’s IIS team , for their support and help in solving many technical problems.
Resources
[1] ModSecurity home page: http://www.modsecurity.org/
[2] OWASP Core Rule Set for ModSecurity: https://www.owasp.org/index.php/Category:OWASP_ModSecurity_Core_Rule_Set_Project
[3] http://blog.modsecurity.org/files/enough_with_default_allow_r1_draft.pdf
[4] http://www.modsecurity.org/documentation/Securing_Web_Services_with_ModSecurity_2.0.pdf
[5] https://www.blackhat.com/presentations/bh-dc-09/Barnett/BlackHat-DC-09-Barnett-WAF-Patching-Challenge-Whitepaper.pdf
- Announcing the availability of ModSecurity extension for IIS
- FastCGI Extension for IIS 下载
- Beyond Apache: ModSecurity for IIS/Nginx is Coming
- How to Build an High Availability MQTT Cluster for the Internet of Things
- How to Build an High Availability MQTT Cluster for the Internet of Things
- High Availability for the HDFS Namenode
- Extension of the Month @ JDJ
- Announcing a preview of F# 4.0 and the Visual F# Tools in VS 2015
- Confidentiality, Integrity, Availability: The three components of the CIA Triad
- ModSecurity for Nginx
- ModSecurity for Nginx
- Availability and description of the File Checksum Integrity Verifier utility
- High Availability for the HDFS Namenode(翻译)
- High Availability for the Hadoop Distributed File System (HDFS)
- ModSecurity Advanced Topic of the Week: Detecting Malware with Fuzzy Hashing
- Announcing Zuul: Edge Service in the Cloud
- Announcing Zuul: Edge Service in the Cloud
- Public availability of PSSCOR2
- Codeforces 55D Beautiful numbers 数位dp
- JAVA读取XML文件并利用该文件对数据库进行配置操作
- I2C之知(六)--s3c2440用I2C接口访问EEPROM
- 【DFS】 hdu1547 Bubble Shooter
- Multiple Vulnerabilities in Scrutinizer NetFlow & sFlow Analyzer
- Announcing the availability of ModSecurity extension for IIS
- JAVA中String类和StringBuffer类的区别
- CyanogenMod 10 (UNOFFICIAL) for Galaxy Tab 2 10.1 WiFi (P5110) ~ 0815
- Python基础教程——1基础知识
- Codeforces Round #130 (Div. 2)
- Beyond Apache: ModSecurity for IIS/Nginx is Coming
- 路漫漫其修远兮,吾将上下而求索——学习是一个过程
- 反思~这一年
- Android学习笔记(四)View和Layout