SlideShare a Scribd company logo
Easily Deploying and
Optimizing Open
Source Web
Application Firewalls
In 20 minutes or less
What is a WAF
● Assuming you’re here you probably already know
● What it does
○ Sits in front of web applications and filters HTTP based on some
set of criteria
● What it doesn’t do
○ Solve all “OWASP Top 10” issues
● The most common Open Source WAF is ModSecurity
○ Most commonly used with OWASP CRS
Core Rule Set v3.0
● The last major release of CRS was in 2013 (2.2)
● In November 2016 we released 3.0
Features
● 3.0 Additions
○ Paranoia levels
○ Improved rule quality
● 3.1 Adds
○ Rewritten SQL Injection Rules
○ Java Protections
○ More pretuned application support
○ Better testing
Deploying
● Both ModSecurity and Core Rule Set can be installed using package
managers
○ Only really recent versions of ubuntu (18.04) have CRS 3.0.2 and modsec 2.9.2
○ Generally you are better off installing at minimum CRS from source
Apt-get install modsecurity-crs libapache2-modsecurity
Dnf install mod_security mod_security_crs
CI: Docker for ModSecurity
We have Docker images available on GitHub and Dockerhub
https://github.com/CRS-support/modsecurity-docker
https://hub.docker.com/r/owasp/modsecurity/
We use Docker as part of testing so we support a number of different variants
We use a multistage builds which keeps size down
ModSecv2 on Ubuntu with Nginx ModSecv2 on Ubuntu with Apache
ModSecv2 on Alpine with Apache ModSecv3 on Ubuntu with Apache
CI: Ansible
We also have ansible support -
https://github.com/CRS-support/modsecurity-ansible-role
Ansible requires a few prereqs to run obviously.
Install ModSec: ansible-playbook modsecurity.yaml --tags "modsec_install"
Install CRS: ansible-playbook modsecurity.yaml --tags "crs_install"
CI: ModSecurity + Core Rule Set
The Core Rule Set provides a Docker image that builds on the ModSecurity
image.
It is available in the CRS repo (/utils) and on DockerHub
● https://hub.docker.com/r/owasp/modsecurity-crs/
The Ansible playbook also has the capability to provide CRS.
Optimizations
Save Processing
● Biggest gains come from reducing work
○ Restrict processing on content types you don’t care about.
■ SecResponseBodyMimeType
■ X
● Place the WAF where it doesn’t need to recreate the wheel
○ At or after the TLS termination proxy is a good place.
● Remove processors you don’t need or use (JSON/XML)
SecRule REQUEST_BASENAME ".*?(.[a-z0-9]{1,10})?$" "id:123, t:lowercase,
capture.setvar:tx.extension=/%{TX.1}/, chain,nolog, allow"
SecRule TX:EXTENSION "!@within %{tx.static_extensions}" "t:none"
Hide the bodies
● Storing request or response bodies can be arbitrarily expensive.
○ Determine what the max size of request/response bodies on
your site (SecResponseBodyLimit and SecResponseBodyLimitAction)
● Use CTL: to skip to after rules that process request body when we
don’t care.
● Use CTL: to shut off response body access when it’s not needed
SecRule REQUEST_FILENAME "@beginsWith /admin"
"id:2,pass,nolog,ctl:requestBodyAccess=Off"
SecRule REQUEST_FILENAME "@beginsWith /admin"
"id:3,pass,nolog,ctl:responseBodyAccess=Off"
Stop with the noise!
● If you are using audit logs, don’t use error logs (and vice versa)
● Logging is expensive, only log what you need.
○ Serial versus concurrent audit logging.
○ Nolog and noauditlog are critical to this process
○ Also refine which audit parts you want stored
SecRule ARGS "<script>"
"id:3,nolog,block,ctl:auditLogParts=+ABCDFGH"
Using the Correct Rules
● Minimize the amount of rules that are running
● Minimize the types of rules you’re running
○ Booting up the PCRE engine on every rule is hard work for the engine
● Remember the engine itself has some overhead.
○ Allocating memory to store Req/Resp data (blocking)
○ Running comparisons (blocking)
○ Generating logs (non-blocking of the transaction)
Questions

More Related Content

PPT
Intro to Node.js
PDF
Webinar Slides: Become a MongoDB DBA (if you’re really a MySQL user)
PDF
Webinar slides: Become a MongoDB DBA - What to Monitor (if you’re really a My...
PDF
Nginx+ Naxsi
PPTX
Memcached and PHP
PDF
Grsecurity - Theoretical and Practical Application
PPT
4 exercises for part 1
PDF
Scalable Socket Server by Aryo
Intro to Node.js
Webinar Slides: Become a MongoDB DBA (if you’re really a MySQL user)
Webinar slides: Become a MongoDB DBA - What to Monitor (if you’re really a My...
Nginx+ Naxsi
Memcached and PHP
Grsecurity - Theoretical and Practical Application
4 exercises for part 1
Scalable Socket Server by Aryo

What's hot (20)

PPTX
Redis fundamental
PDF
15th Athens Big Data Meetup - 1st Talk - Running Spark On Mesos
PDF
Don't Build "Death Star" Security - O'Reilly Software Architecture Conference...
PDF
Meteor Meets Mallory
PPTX
Vault w/ config injection kubernetes canada
PDF
Metasploit: Pwnage and Ponies
PDF
Mobile Programming - 3 UDP
PDF
Nginx cheat sheet
PPT
Azure ServiceBus Queues and Topics
PDF
JSConfBR - Securing Node.js App, by the community and for the community
PDF
Mobile Programming - Network Universitas Budi Luhur
PDF
Using IPS for Web Protection
PDF
PDF
Insecurity-In-Security version.1 (2010)
PDF
KSDG-iSlide App 開發心得分享
PDF
Insecurity-In-Security version.2 (2011)
DOCX
Sophos XG FIREWALL SSL VPN Configuration
PDF
Mise en place d'un client VPN l2tp IPsec sous docker
PDF
using Virtualbox NAT and shared folder
PPT
Squid Server
Redis fundamental
15th Athens Big Data Meetup - 1st Talk - Running Spark On Mesos
Don't Build "Death Star" Security - O'Reilly Software Architecture Conference...
Meteor Meets Mallory
Vault w/ config injection kubernetes canada
Metasploit: Pwnage and Ponies
Mobile Programming - 3 UDP
Nginx cheat sheet
Azure ServiceBus Queues and Topics
JSConfBR - Securing Node.js App, by the community and for the community
Mobile Programming - Network Universitas Budi Luhur
Using IPS for Web Protection
Insecurity-In-Security version.1 (2010)
KSDG-iSlide App 開發心得分享
Insecurity-In-Security version.2 (2011)
Sophos XG FIREWALL SSL VPN Configuration
Mise en place d'un client VPN l2tp IPsec sous docker
using Virtualbox NAT and shared folder
Squid Server
Ad

Similar to BSides Rochester 2018: Chaim Sanders: Easily Deploying and Optimizing Open Source Web Application Firewalls (20)

PPTX
Python And The MySQL X DevAPI - PyCaribbean 2019
PDF
Hawkular overview
PDF
Hawkular overview
PDF
Crikeycon 2019 Velociraptor Workshop
PDF
GDG Cloud Iasi - Docker For The Busy Developer.pdf
PPTX
Deploying OpenStack with Ansible
PDF
Scaling symfony apps
PPTX
Reusable, composable, battle-tested Terraform modules
PDF
Best Practices for Developing & Deploying Java Applications with Docker
PDF
Prometheus and Docker (Docker Galway, November 2015)
PPTX
VMworld 2016: vSphere 6.x Host Resource Deep Dive
DOCX
2nodesoracle12craconyourlaptopvirtualboxstepbystepguide1 0-130627143310-phpapp02
DOCX
PDF
Nodejs vatsal shah
PDF
Ippevent : openshift Introduction
PPTX
MongoDB – Sharded cluster tutorial - Percona Europe 2017
PPTX
Sharded cluster tutorial
PPTX
MongoDB - Sharded Cluster Tutorial
PPTX
Docker Swarm secrets for creating great FIWARE platforms
PDF
Oracle 11g R2 RAC setup on rhel 5.0
Python And The MySQL X DevAPI - PyCaribbean 2019
Hawkular overview
Hawkular overview
Crikeycon 2019 Velociraptor Workshop
GDG Cloud Iasi - Docker For The Busy Developer.pdf
Deploying OpenStack with Ansible
Scaling symfony apps
Reusable, composable, battle-tested Terraform modules
Best Practices for Developing & Deploying Java Applications with Docker
Prometheus and Docker (Docker Galway, November 2015)
VMworld 2016: vSphere 6.x Host Resource Deep Dive
2nodesoracle12craconyourlaptopvirtualboxstepbystepguide1 0-130627143310-phpapp02
Nodejs vatsal shah
Ippevent : openshift Introduction
MongoDB – Sharded cluster tutorial - Percona Europe 2017
Sharded cluster tutorial
MongoDB - Sharded Cluster Tutorial
Docker Swarm secrets for creating great FIWARE platforms
Oracle 11g R2 RAC setup on rhel 5.0
Ad

More from JosephTesta9 (12)

PDF
BSides Rochester 2018: Chaim Sanders: How the Cookie Crumbles: Modern HTTP St...
PPTX
BSides Rochester 2018: Justin Moore: Automated HTTP Request Repeating With Bu...
PDF
BSides Rochester 2018: Dave Kukfa: BinDbg: Easy Windows Debugging for Binary ...
PDF
BSides Rochester 2018: Timothy Duffy: Civic and Humanitarian Open Source
PPTX
BSides Rochester 2018: Michael West: Sentry, Or: How I Learned To Stop Worryi...
PPTX
BSides Rochester 2018: Lee Kagan: Red and Blue Ping Pong
PPTX
BSides Rochester 2018: Jonathan Myers: IoT Malware Detection with Machine Lea...
PDF
BSides Rochester 2018: Issa Hafiri & Christian Halbert: IOT Devices (And Why ...
PDF
BSides Rochester 2018: Esteban Rodriguez: Ducky In The Middle: Injecting keys...
PPTX
BSides Rochester 2018: Drew Kirkpatrick: Open Source SAST and DAST Tools for ...
ODP
BSides Rochester 2018: Chris Partridge: Turning Domain Data Into Domain Intel...
PPTX
BSides Rochester 2018: Anthony DiDonato: Virtualization Based Security
BSides Rochester 2018: Chaim Sanders: How the Cookie Crumbles: Modern HTTP St...
BSides Rochester 2018: Justin Moore: Automated HTTP Request Repeating With Bu...
BSides Rochester 2018: Dave Kukfa: BinDbg: Easy Windows Debugging for Binary ...
BSides Rochester 2018: Timothy Duffy: Civic and Humanitarian Open Source
BSides Rochester 2018: Michael West: Sentry, Or: How I Learned To Stop Worryi...
BSides Rochester 2018: Lee Kagan: Red and Blue Ping Pong
BSides Rochester 2018: Jonathan Myers: IoT Malware Detection with Machine Lea...
BSides Rochester 2018: Issa Hafiri & Christian Halbert: IOT Devices (And Why ...
BSides Rochester 2018: Esteban Rodriguez: Ducky In The Middle: Injecting keys...
BSides Rochester 2018: Drew Kirkpatrick: Open Source SAST and DAST Tools for ...
BSides Rochester 2018: Chris Partridge: Turning Domain Data Into Domain Intel...
BSides Rochester 2018: Anthony DiDonato: Virtualization Based Security

Recently uploaded (20)

PDF
A comparative analysis of optical character recognition models for extracting...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
MIND Revenue Release Quarter 2 2025 Press Release
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Cloud computing and distributed systems.
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Spectroscopy.pptx food analysis technology
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
cuic standard and advanced reporting.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PPT
Teaching material agriculture food technology
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
A comparative analysis of optical character recognition models for extracting...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Reach Out and Touch Someone: Haptics and Empathic Computing
MIND Revenue Release Quarter 2 2025 Press Release
The AUB Centre for AI in Media Proposal.docx
Cloud computing and distributed systems.
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Spectroscopy.pptx food analysis technology
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
“AI and Expert System Decision Support & Business Intelligence Systems”
Programs and apps: productivity, graphics, security and other tools
Per capita expenditure prediction using model stacking based on satellite ima...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
cuic standard and advanced reporting.pdf
Spectral efficient network and resource selection model in 5G networks
Teaching material agriculture food technology
Network Security Unit 5.pdf for BCA BBA.
Agricultural_Statistics_at_a_Glance_2022_0.pdf

BSides Rochester 2018: Chaim Sanders: Easily Deploying and Optimizing Open Source Web Application Firewalls

  • 1. Easily Deploying and Optimizing Open Source Web Application Firewalls In 20 minutes or less
  • 2. What is a WAF ● Assuming you’re here you probably already know ● What it does ○ Sits in front of web applications and filters HTTP based on some set of criteria ● What it doesn’t do ○ Solve all “OWASP Top 10” issues ● The most common Open Source WAF is ModSecurity ○ Most commonly used with OWASP CRS
  • 3. Core Rule Set v3.0 ● The last major release of CRS was in 2013 (2.2) ● In November 2016 we released 3.0 Features ● 3.0 Additions ○ Paranoia levels ○ Improved rule quality ● 3.1 Adds ○ Rewritten SQL Injection Rules ○ Java Protections ○ More pretuned application support ○ Better testing
  • 4. Deploying ● Both ModSecurity and Core Rule Set can be installed using package managers ○ Only really recent versions of ubuntu (18.04) have CRS 3.0.2 and modsec 2.9.2 ○ Generally you are better off installing at minimum CRS from source Apt-get install modsecurity-crs libapache2-modsecurity Dnf install mod_security mod_security_crs
  • 5. CI: Docker for ModSecurity We have Docker images available on GitHub and Dockerhub https://github.com/CRS-support/modsecurity-docker https://hub.docker.com/r/owasp/modsecurity/ We use Docker as part of testing so we support a number of different variants We use a multistage builds which keeps size down ModSecv2 on Ubuntu with Nginx ModSecv2 on Ubuntu with Apache ModSecv2 on Alpine with Apache ModSecv3 on Ubuntu with Apache
  • 6. CI: Ansible We also have ansible support - https://github.com/CRS-support/modsecurity-ansible-role Ansible requires a few prereqs to run obviously. Install ModSec: ansible-playbook modsecurity.yaml --tags "modsec_install" Install CRS: ansible-playbook modsecurity.yaml --tags "crs_install"
  • 7. CI: ModSecurity + Core Rule Set The Core Rule Set provides a Docker image that builds on the ModSecurity image. It is available in the CRS repo (/utils) and on DockerHub ● https://hub.docker.com/r/owasp/modsecurity-crs/ The Ansible playbook also has the capability to provide CRS.
  • 9. Save Processing ● Biggest gains come from reducing work ○ Restrict processing on content types you don’t care about. ■ SecResponseBodyMimeType ■ X ● Place the WAF where it doesn’t need to recreate the wheel ○ At or after the TLS termination proxy is a good place. ● Remove processors you don’t need or use (JSON/XML) SecRule REQUEST_BASENAME ".*?(.[a-z0-9]{1,10})?$" "id:123, t:lowercase, capture.setvar:tx.extension=/%{TX.1}/, chain,nolog, allow" SecRule TX:EXTENSION "!@within %{tx.static_extensions}" "t:none"
  • 10. Hide the bodies ● Storing request or response bodies can be arbitrarily expensive. ○ Determine what the max size of request/response bodies on your site (SecResponseBodyLimit and SecResponseBodyLimitAction) ● Use CTL: to skip to after rules that process request body when we don’t care. ● Use CTL: to shut off response body access when it’s not needed SecRule REQUEST_FILENAME "@beginsWith /admin" "id:2,pass,nolog,ctl:requestBodyAccess=Off" SecRule REQUEST_FILENAME "@beginsWith /admin" "id:3,pass,nolog,ctl:responseBodyAccess=Off"
  • 11. Stop with the noise! ● If you are using audit logs, don’t use error logs (and vice versa) ● Logging is expensive, only log what you need. ○ Serial versus concurrent audit logging. ○ Nolog and noauditlog are critical to this process ○ Also refine which audit parts you want stored SecRule ARGS "<script>" "id:3,nolog,block,ctl:auditLogParts=+ABCDFGH"
  • 12. Using the Correct Rules ● Minimize the amount of rules that are running ● Minimize the types of rules you’re running ○ Booting up the PCRE engine on every rule is hard work for the engine ● Remember the engine itself has some overhead. ○ Allocating memory to store Req/Resp data (blocking) ○ Running comparisons (blocking) ○ Generating logs (non-blocking of the transaction)