ModSecurity The Open Source Web Application Firewall



Similar documents
Web Application Firewalls: When Are They Useful? OWASP AppSec Europe May The OWASP Foundation

Web Intrusion Detection with ModSecurity. Ivan Ristic

Web Application Firewall Technology Insight OWASP 22/ The OWASP Foundation. Joakim Sandström Role: OWASP Prospect.

Implementation of Web Application Firewall

IronBee Open Source Web Application Firewall

ModSecurity as Universal Cross-platform Web Protection Tool

MODSECURITY HANDBOOK

Defending Against Web App A0acks Using ModSecurity. Jason Wood Principal Security Consultant Secure Ideas

Information Supplement: Requirement 6.6 Code Reviews and Application Firewalls Clarified

We protect you applications! No, you don t. Digicomp Hacking Day 2013 May 16 th 2013

How To Protect A Web Application From Attack From A Trusted Environment

3. Broken Account and Session Management. 4. Cross-Site Scripting (XSS) Flaws. Web browsers execute code sent from websites. Account Management

Nixu SNS Security White Paper May 2007 Version 1.2

Today s Topics. Protect - Detect - Respond A Security-First Strategy. HCCA Compliance Institute April 27, Concepts.

Protocol-Level Evasion of Web Application Firewalls

Out of the Fire - Adding Layers of Protection When Deploying Oracle EBS to the Internet

THE SMARTEST WAY TO PROTECT WEBSITES AND WEB APPS FROM ATTACKS

SysPatrol - Server Security Monitor

Table of Contents. Page 2/13

Firewalls. Securing Networks. Chapter 3 Part 1 of 4 CA M S Mehta, FCA

PROFESSIONAL SECURITY SYSTEMS

Protecting Your Organisation from Targeted Cyber Intrusion

Network Security Administrator

How to Make the Client IP Address Available to the Back-end Server

Installation and configuration guide

Chapter 9 Firewalls and Intrusion Prevention Systems

SAP WEB DISPATCHER Helps you to make decisions on Web Dispatcher implementation

Data Collection and Analysis: Get End-to-End Security with Cisco Connected Analytics for Network Deployment

Secure Web Application Coding Team Introductory Meeting December 1, :00 2:00PM Bits & Pieces Room, Sansom West Room 306 Agenda

Managing Latency in IPS Networks

Barracuda Load Balancer Online Demo Guide

Web Application Firewall

FortiWeb 5.0, Web Application Firewall Course #251

Lehrstuhl für Informatik 4 Kommunikation und verteilte Systeme. Firewall

STOPPING LAYER 7 ATTACKS with F5 ASM. Sven Müller Security Solution Architect

Repsheet. A Behavior Based Approach to Web Application Security. Aaron Bedra Application Security Lead Braintree Payments. tirsdag den 1.

Addressing Application Layer Attacks with Mod Security

The Weakest Link: Mitigating Web Application Vulnerabilities. webscurity White Paper. webscurity Inc. Minneapolis, Minnesota USA

Comodo Web Application Firewall Software Version 2.0

Advanced Web Security, Lab

Guidelines for Web applications protection with dedicated Web Application Firewall

Content Scanning for secure transactions using Radware s SecureFlow and AppXcel together with Aladdin s esafe Gateway

COUNTERSNIPE

End-user Security Analytics Strengthens Protection with ArcSight

OpenSAMM Software Assurance Maturity Model

Mingyu Web Application Firewall (DAS- WAF) All transparent deployment for Web application gateway

Web Application Firewall Policy File Specification

Firewalls. Firewalls. Idea: separate local network from the Internet 2/24/15. Intranet DMZ. Trusted hosts and networks. Firewall.

Intel Security Certified Product Specialist McAfee Network Security Platform (NSP)

Network Traffic Analysis

Network Segmentation

Installation and configuration guide

Comodo Web Application Firewall Software Version 2.11

Security Testing For RESTful Applications

HP A-IMC Firewall Manager

SANS Top 20 Critical Controls for Effective Cyber Defense

INTRUSION DECEPTION CZYLI BAW SIĘ W CIUCIUBABKĘ Z NAMI

Protect Your IT Infrastructure from Zero-Day Attacks and New Vulnerabilities

U06 IT Infrastructure Policy

Firewalls. Chapter 3

Threat Modelling for Web Application Deployment. Ivan Ristic (Thinking Stone)

HP IMC Firewall Manager

CHAPTER 3 : INCIDENT RESPONSE FIVE KEY RECOMMENDATIONS GLOBAL THREAT INTELLIGENCE REPORT 2015 :: COPYRIGHT 2015 NTT INNOVATION INSTITUTE 1 LLC

A Guide to New Features in Propalms OneGate 4.0

Firewall Introduction Several Types of Firewall. Cisco PIX Firewall

Forward proxy server vs reverse proxy server

THE ROLE OF IDS & ADS IN NETWORK SECURITY

ΕΠΛ 674: Εργαστήριο 5 Firewalls

Passing PCI Compliance How to Address the Application Security Mandates

Intrusion Defense Firewall

IBM. Vulnerability scanning and best practices

Setting Up B2B Data Exchange for High Availability in an Active/Active Configuration

Reverse Shells Enable Attackers To Operate From Your Network. Richard Hammer August 2006

We will give some overview of firewalls. Figure 1 explains the position of a firewall. Figure 1: A Firewall

May Palo Alto Networks 232 E. Java Drive Sunnyvale, CA

DEPLOYMENT GUIDE Version 1.1. Deploying F5 with Oracle Application Server 10g

Flexible Routing and Load Control on Back-End Servers. Controlling the Request Load and Quality of Service

CSCE 465 Computer & Network Security

Locking down a Hitachi ID Suite server

Radware s Smart IDS Management. FireProof and Intrusion Detection Systems. Deployment and ROI. North America. International.

IONA Security Platform

Proxy Server, Network Address Translator, Firewall. Proxy Server

F-Secure Messaging Security Gateway. Deployment Guide

Web Application Security Roadmap

Virtual Appliance Setup Guide

Implementing a secure high visited web site by using of Open Source softwares. S.Dawood Sajjadi Maryam Tanha. University Putra Malaysia (UPM)

Security Controls for the Autodesk 360 Managed Services

Host Hardening. OS Vulnerability test. CERT Report on systems vulnerabilities. (March 21, 2011)

TNC is an open architecture for network access control. If you re not sure what NAC is, we ll cover that in a second. For now, the main point here is

Using Nessus In Web Application Vulnerability Assessments

Passive Logging. Intrusion Detection System (IDS): Software that automates this process

Smarter Security for Smarter Local Government. Craig Sargent, Solutions Specialist

Last Updated: July STATISTICA Enterprise Server Security

Lumeta IPsonar. Active Network Discovery, Mapping and Leak Detection for Large Distributed, Highly Complex & Sensitive Enterprise Networks

NSFOCUS Web Application Firewall White Paper

CS 356 Lecture 25 and 26 Operating System Security. Spring 2013

A Decision Maker s Guide to Securing an IT Infrastructure

Company Co. Inc. LLC. LAN Domain Network Security Best Practices. An integrated approach to securing Company Co. Inc.

Playing with Web Application Firewalls

Transcription:

OWASP AppSec NYC 2008 ModSecurity The Open Source Web Application Firewall Ivan Ristić Vice President, Security Research Breach Security 1/46

Introduction Ivan Ristić Web application security and web application firewall specialist. Author of Apache Security. Author of ModSecurity. OWASP London Chapter leader. Officer of the Web Application Security Consortium. Employed by Breach Security. 2/46

3/46 Part 1 What are Web Application Firewalls?

Problems with web applications How did it all start? 4/46 HTTP and browsers designed for document exchange. Web applications built using a number of loosely integrated technologies. No one thought about security at the time. Where are we today? Most web applications suffer from one type of problem or another. It is very difficult to develop a reasonably secure web application. Not possible to achieve 100% security.

How can we improve the situation? Education & good development practices. We have been working hard on this since 2000. Much better than it used to be, but still not good enough. Secure web programming too difficult and time consuming for your average programmer. Design & code reviews. Slow and expensive. Scanning & penetration testing. Not conclusive. Slow and expensive. 5/46

Why use web application firewalls? It's a cost-effective technology that works. It can be deployed straight away. Gives instant visibility of the systems it protects. Can provide instant protection. In some of its forms (reverse proxies) it is actually an essential building block of HTTP networks. Good example of defence-in-depth. 6/46

Network firewalls do not work Firewall Web Client Web Server Application Application Database Server HTTP Traffic Ports 80 & 443 Neither do IDS/IPS solutions. 7/46

WAF identity problem: Naming There is a long-standing WAF identity problem. With the name, first of all: Adaptive Firewall Adaptive Proxy Adaptive Gateway Application Firewall Application-level Firewall Application-layer Firewall Application-level Security Gateway Application Level Gateway Application Security Device Application Security Gateway Stateful Multilayer Inspection Firewall Web Adaptive Firewall Web Application Controller Web Application Firewall Web Application Security Device Web Application Proxy Web Application Shield Web Shield Web Security Firewall Web Security Gateway Web Security Proxy Web Intrusion Detection System Web Intrusion Prevention System 8/46

WAF identity problem: Purpose There are four main aspects to consider: 9/46 1. Auditing/monitoring device Attacks and client activity Passive defect/vulnerability discovery 2. Access control device 3. Layer 7 router/switch (reverse proxy) 4. Web application hardening tool The name (WAF) is overloaded. How about: Web Intrusion Detection System? HTTP Security Monitoring?

WAFEC Short for Web Application Firewall Evaluation Criteria. Project of the Web Application Security Consortium (webappsec.org). It's an open project. Virtually all WAF vendors on board (not enough users though). WAFEC v1.0 released in 2006. Version 2 coming... eventually. 10/46

11/46 Part 2 ModSecurity

What is ModSecurity? It is an open source web application firewall. Most widely deployed web application firewall according to Forrester Research. That s not surprising because it is: Free. Full-featured. Stable and reliable. Well documented. Does what it says on the box. Been around for years. 12/46

History of ModSecurity Project started in 2002: Wouldn t it be nice if I had something to monitor what s going on in my applications? Commercial support through Thinking Stone since 2004. Acquired by Breach Security in 2006. Breach Security pledges to support the open source nature of the project; adds resources. Still going strong. 13/46

Deployment architectures Embed into your existing web servers. Deploy as a network gateway combining Apache working as reverse proxy with ModSecurity. 14/46

ModSecurity philosophy Empower the users to do what they need. Don't do anything implicitly. Everything is in the configuration. Be passive (wherever possible). Errors raise flags, which need to be handled using rules. No surprises. Document everything and tell it like it is. 15/46

Request lifecycle (I) Run phase 1 as early as possible (REQUEST HEADERS). Reuse information available from Apache. Perform additional parsing as necessary. Buffer and parse the request body (optional). Look for protocol-level evasion. Run phase 2 (REQUEST BODY). Allow the request to be processed. 16/46

Request lifecycle (II) Run phase 3 before headers are sent (RESPONSE HEADERS). Buffer response body (optional). Depending on the response MIME type and custom instructions. Run phase 4 (RESPONSE BODY). Run phase 5 (LOGGING). Log transaction (optional). 17/46

Streaming Data Analysis v3.0 Streams One per data source (e.g. request body) Transformation pipeline Streaming operators Process as data arrives Support for traditional signatures: Fast (parallel matching) and crude Still useful (e.g. rule prequalification) 18/46

Transaction logging ModSecurity will log complete transaction data on demand. Using the rules you can: Choose whether to log a transaction. Choose which parts to log. Transactions are recorded in two formats: Serial single file; convenient but limited. Concurrent file per transaction; scalable but not suitable for manual handling. Mlogc picks up transactions as they are recorded and sends them to the central logging server. 19/46 It's fast, secure (SSL), reliable, and uses buffering.

ModSecurity Rule Language It's a simple event-based programming language, which lives within the Apache configuration syntax. Look at any part of the transaction. Transform data to counter evasion. Perform various actions. Combine rules to form complex logic. Common tasks are easy, complex tasks are possible. 20/46

Rules Generic syntax: SecRule TARGETS OPERATOR [ACTIONS] For example: SecRule ARGS REQUEST_HEADERS "<script" \ "id:1001,msg:'xss Attack', \ severity:error,deny,status:404" With rule chaining: SecRule ARGS:username "@streq admin" \ chain,deny SecRule REMOTE_ADDR "!@streq 192.168.1.1" 21/46

Target Variables Using variables you tell ModSecurity where to look. There are 78 variables in the latest version. For example:» ARGS» ARGS_COMBINED_SIZE» ARGS_NAMES» ARGS_GET» ARGS_POST 22/46»

Operators Operators tell ModSecurity how to process request data. There are 22 operators in the latest version. For example: Strings (rx, pm, beginswith, contains, endswith, streq, within). Numerical (eq, ge, gt, le, lt). XML (validatedtd, validateschema). Other (rbl, geolookup, inspectfile, verifycc). 23/46

Actions 24/46 Actions tell ModSecurity what to do when a match occurs. There are 42 actions in the latest version. Possible use of actions: Block transaction (block, drop, deny, proxy). Influence logging (log, auditlog, sanitisearg). Set/change/delete variables (setvar, setenv). Access persistent storage (initcol).

25/46 Part 3 Real-life Examples

Ignore static content In most cases you don't want to waste CPU cycles analysing requests for static resources. <Location /g/> SecRuleEngine Off </Location> You can also do this (works best in embedded mode): SecRule REQUEST_METHOD "^(GET HEAD)$" \ chain,allow,nolog SecRule REQUEST_BASENAME "\.(jpg gif png)$" chain SecRule &ARGS "@eq 0" 26/46

Virtual patching example Virtual patching example using the positive security approach: <Location /apps/script.php> SecRule &ARGS "!@eq 1" SecRule ARGS_NAMES "!^statid$" SecRule ARGS:statID "!^\d{1,3}$" </Location> 27/46

White-list IP address or IP range A frequent request is to create an exception to not process requests coming from an IP address: SecRule REMOTE_ADDR "@streq 192.168.254.1" \ allow,phase:1,nolog SecRule REMOTE_ADDR "@beginswith 192.168.254." \ allow,phase:1,nolog SecRule REMOTE_ADDR "@rx ^192\.168\.254\.(1 2 5)$" \ allow,phase:1,nolog In a future version we will probably introduce a new operator, @ipmatch, to make working with network segments easier. 28/46

Track activity per IP address Initialise IP address collection: SecAction \ phase:1,initcol:ip=%{remote_addr},nolog,pass Deny IP addresses whose scores are too high: SecRule IP:score "@gt 20" phase:1,log,deny Increment score on rule match: SecRule ARGS pattern phase:2,pass,setvar:ip.score=+1 29/46

Associate session with request ModSecurity has support for sessions, but you need to help it by extracting the session ID from request: SecRule REQUEST_COOKIES:PHPSESSID!^$ \ "chain,phase:2,nolog,pass, \ setsid:%{request_cookies.phpsessid}" Collection SESSION will be available from this moment on to store per-session data, persistent across requests. Transaction will be tagged with the session ID in the transaction log. 30/46

Sanitise data before logging If you know the sensitive parameter names in advance: SecAction "phase:5,nolog,pass, \ sanitisearg:password, \ sanitisearg:password_again, \ sanitisearg:oldpassword" For any parameter name that sounds like a password: SecAction ARGS_NAMES password \ phase:5,nolog,pass,sanitisematched Or based on content: SecRule ARGS "@verifycc CCREGEX" \ phase:5,nolog,pass,sanitisematched 31/46

Dealing with evasion Writing rules to deal with all possible combinations of evasion methods is not only time consuming, it's impossible. A few evasion examples: drop table drop\ntable DROP/*sdfjsdlkfj*/TABLE ModSecurity uses a concept of transformation functions to deal with this problem: SecRule ARGS "drop table" \ t:lowercase,t:replacecomments, \ t:compresswhitespace" 32/46

Decisions based on client location You can take the geographic location of the client into account when making decisions. First you configure the GeoIP database (download free from maxmind.com): SecGeoLookupDb /path/to/geo.db Then look the IP address up: SecRule REMOTE_ADDR @geolookup \ "phase:1,chain,drop,msg:'non-uk IP address'" SecRule GEO:COUNTRY_CODE "!@streq UK" 33/46

Capture and transform data Sometimes you need to transform input data before you can look at it. The HTTP Basic authentication, for example: Authorization: Basic bm9ib2r5onrlc3q= The following rules would do the trick: SecRule REQUEST_HEADERS:Authorization \ "^Basic ([a-za-z0-9]+=*)$" \ phase:1,capture,chain SecRule TX:1 ^(\w+): t:base64decode,capture,chain SecRule TX:1 ^(admin root backup)$ logdata:%{tx.1} 34/46

Write rule in Lua (experimental) As of 2.5 you can write rules in Lua: SecRuleScript /path/to/file.lua And the script: function main() m.log(1, "Hello world!"); local var1 = m.getvar("remote_addr"); local var2 = m.getvar("request_uri", "normalisepath"); local var3 = m.getvar("args.p", { "lowercase", "compresswhitespace" } ); end 35/46 return "Variable ARGS:p looks suspicious!";

36/46 Part 4 Related Projects

ModSecurity Core Rules Coherent set of rules designed to detect generic web application security attacks. 37/46 Bundled with ModSecurity, but with a separate release cycle. Design goals: Performance. Quality. Stability. Plug and Play. Automated updates supported since ModSecurity 2.5.

ModSecurity Community Console Self-contained application designed for alert aggregation, monitoring and reporting. Portable (Java). Embedded database. Free for up to 3 sensors. Not open source. 38/46

ModProfiler NEW Research project and open source tool that generates positive security models out of the traffic recorded by ModSecurity. Portable (Java). Current version: 0.2.0 Whitepaper: Enough With Default Allow in Web Applications! 39/46

REMO A project to build a graphical rule editor for ModSecurity with a positive / whitelist approach. REMO stands for Rule Editor for ModSecurity. Community project run by Christian Folini. 40/46

Distributed Open Proxy Honeypots A network of open proxy sensors, each deployed with ModSecurity configured to log to the central server. Goals: Observe what the bad guys are doing. Fine tune detection rules. WASC project (webappsec.org), run by Ryan Barnett. 41/46

Questions? Thank you! Ivan Ristić ivanr@webkreator.com 42/46

43/46 Appendix A Roadmap

Portability 44/46 Limited by being too close to Apache: Need to reload configuration without affecting the web server. Need freedom to expand rule syntax. Work embedded in any web server. Port to IIS and ISA. Help the community port to other web servers. Other deployment modes: Passive/sniffer. Command line / batch processing.

Learning Better support for positive security. We have good support for virtual patching but writing complex positive security rules is difficult. Create positive security models automatically using traffic profiling. Make it easier to interact with the contextual information. 45/46 Customise policy based on the target system.

Modularity Formal component boundaries to allow for a mix-and-match deployment of modules. For example: Deploy with a different persistence backend. Formats for data exchange. Handle complex requirements better: Write rules in C. Write rules in Lua (already in 2.5). 46/46