SlideShare uma empresa Scribd logo
1 de 31
ModSecurity and NGINX:
Tuning the OWASP Core
Rule Set
Faisal Memon
Product Marketing Manager, NGINX
Formerly:
• Sr. Technical Marketing Engineer,
Riverbed
• Technical Marketing Engineer, Cisco
• Software Engineer, Cisco
Who am I?
Previously on…
ModSecurity 3.0 and NGINX: Getting
Started
• How to install ModSecurity 3.0 with NGINX Plus
• How to compile and install ModSecurity 3.0 with NGINX Open
Source
• How to validate installation with a basic test rule
• Watch on demand:
nginx.com/webinars/modsecurity-3-0-
and-nginx-getting-started/
3
Agenda
• ModSecurity Overview
• OWASP Core Rule Set Overview
• OWASP Core Rule Set Installation
• OWASP Core Rule Set Tuning
• Demo
• Summary
Brief History of ModSecurity
● 2002: First open source release
● 2004: Commercialized as Thinking Stone
● 2006: Thinking Stone acquired by Breach Security
● 2006: ModSecurity 2.0 released
● 2009: Ivan Ristic, original author, leaves Breach
Security
● 2010: Breach Security acquired by TrustWave
● 2017: ModSecurity 3.0 released
“... I realized that producing secure web applications is virtually impossible. As a result, I
started to fantasize about a tool that would sit in front of web applications and control the
flow of data in and out.”
- Ivan Ristic, ModSecurity creator
What is ModSecurity?
• Layer 7 web application firewall (WAF)
• Dynamic module for NGINX
• Inspects all incoming requests for malicious patterns
• Requests that have malicious patterns are logged
and/or dropped
• ModSecurity is the WAF engine, the Core Rule Set
(CRS) defines the malicious patterns
6
ModSecurity 3.0 and NGINX Interface
• ModSecurity 3.0 is a complete rewrite of
ModSecurity that works natively with NGINX
• Core ModSecurity functionality moved to
standalone libModSecurity functionality
• NGINX Connector interfaces between
libModSecurity and NGINX
• Connector also available for Apache
7
“ModSecurity is not a high-
flying, cloud-enabled, machine-
learning mastermind. It is better
to think of ModSecurity as of a
mechanical watch.
- Christian Folini, co-lead OWASP CRS
ModSecurity 3.0 Caveats
• Rules that inspect the response body are not supported and are ignored if included in the configuration The NGINX sub_filter
directive can be used to inspect and rewrite response data In the OWASP Core Rule Set, these are the 95x rules.
• The OWASP Core Rule Set DDoS mitigation rules (REQUEST-912-DOS- PROTECTION.conf) are not supported. Use NGINX rate limiting instead.
• Inclusion of the request and response body in the audit log is not supported.
• Some directives are not implemented; you may get an error if you try to use them. The ModSecurity Reference Manual lists all the available
directives in ModSecurity and whether or not they are supported in libModSecurity.
9
OSS and NGINX Plus Options
ModSecurity OSS NGINX WAF
Obtaining the
module
Build from source, test and deploy Fully-tested builds direct from
NGINX
Updates Track GitHub, build and deploy
updates as necessary
NGINX tracks GitHub and pushes
out necessary updates
Support Community (GitHub,
StackOverflow)
Additional commercial support
from Trustwave
Commercial support from NGINX
and Trustwave
Financial Cost $0, self-supported Per-instance, NGINX supported
Agenda
• ModSecurity Overview
• OWASP Core Rule Set Overview
• OWASP Core Rule Set Installation
• OWASP Core Rule Set Tuning
• Demo
• Summary
CRS Overview
• First released in 2006 by Ofer Shezaf
• Version 3.0 released in November 2016
◦ Over 90% reduction in false positives
◦ Recommended for use with NGINX
• Community-maintained by a team of 10 developers, co-led by Dr. Christian
Folini
• Blocks SQLi, RCE, LFI, RFI, etc.
• Should be used for all ModSecurity deployments
• Available at: github.com/SpiderLabs/owasp-
modsecurity-crs
12
CRS Key Files and Directories
• crs-setup.conf – The main configuration file for the CRS
• rules/ – Directory containing the rules organized into different files, each of which
has a number assigned to it:
◦ 90x files – Exclusions to remedy false positives
◦ 91x files – Rules to detect malicious clients, such as scanners and bots
◦ 92x files – Rules to detect protocol violations
◦ 93x and 94x files – Rules to detect application attacks such as SQLi and RCE
◦ 95x files – Rules to detect outbound data leakage. Not supported by NGINX or
NGINX Plus
◦ .data files – Data used by the rules. For example crawlers-user-
agents.data contains a list of User-Agent values used by
scanners. This file is used by rule REQUEST-913-SCANNER-
DETECTION.conf to identify scanners and bots.
13
REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf
REQUEST-901-INITIALIZATION.conf
REQUEST-903.9001-DRUPAL-EXCLUSION-RULES.conf
REQUEST-903.9002-WORDPRESS-EXCLUSION-RULES.conf
REQUEST-905-COMMON-EXCEPTIONS.conf
REQUEST-910-IP-REPUTATION.conf
REQUEST-911-METHOD-ENFORCEMENT.conf
REQUEST-912-DOS-PROTECTION.conf
REQUEST-913-SCANNER-DETECTION.conf
REQUEST-920-PROTOCOL-ENFORCEMENT.conf
REQUEST-921-PROTOCOL-ATTACK.conf
REQUEST-930-APPLICATION-ATTACK-LFI.conf
REQUEST-931-APPLICATION-ATTACK-RFI.conf
REQUEST-932-APPLICATION-ATTACK-RCE.conf
REQUEST-933-APPLICATION-ATTACK-PHP.conf
REQUEST-941-APPLICATION-ATTACK-XSS.conf
REQUEST-942-APPLICATION-ATTACK-SQLI.conf
REQUEST-943-APPLICATION-ATTACK-SESSION-FIXATION.conf
REQUEST-949-BLOCKING-EVALUATION.conf
RESPONSE-950-DATA-LEAKAGES.conf
RESPONSE-951-DATA-LEAKAGES-SQL.conf
RESPONSE-952-DATA-LEAKAGES-JAVA.conf
RESPONSE-953-DATA-LEAKAGES-PHP.conf
RESPONSE-954-DATA-LEAKAGES-IIS.conf
RESPONSE-959-BLOCKING-EVALUATION.conf
RESPONSE-980-CORRELATION.conf
RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf
CRS Anomaly Scoring
• Configurable anomaly-scoring model
• Each rule that fires increases the anomaly score
• If score exceeds configured anomaly threshold then transaction is blocked
• The anomaly levels are as follows:
◦ Critical – Anomaly score of 5. Likely application attack. Mostly generated by 93x and 94x files
◦ Error – Anomaly score of 4. Likely data leakage. Generated mostly by 95x files. 95x files are not supported with NGINX or NGINX Plus
◦ Warning – Anomaly score of 3. Likely malicious client. Generated mostly by 91x files
◦ Notice – Anomaly score of 2. Likely protocol violations. Generated mostly by 92x files
• Default anomaly threshold is 5.
14
CRS Paranoia Modes
• The CRS has different paranoia levels that enable more rules
• More attacks blocked at higher paranoia levels but also more false positives
• Higher paranoia levels will require application modifications
• Paranoia levels:
◦ Paranoia Level 1 (default) – Basic security. Minimal amount of False Positives
◦ Paranoia Level 2 – Elevated security level. More rules, fair amount of false positives
◦ Paranoia Level 3 – Online banking level security. Specialized rules, more false positives
◦ Paranoia Level 4 - Nuclear power plant level security. Insane rules, lots of false positives
15
CRS Paranoia Modes
16
Agenda
• ModSecurity Overview
• OWASP Core Rule Set Overview
• OWASP Core Rule Set Installation
• OWASP Core Rule Set Tuning
• Demo
• Summary
Download and Install from GitHub
$ wget https://github.com/SpiderLabs/owasp-modsecurity-crs/archive/v3.0.2.tar.gz
$ tar -xzvf v3.0.2.tar.gz
$ sudo mv owasp-modsecurity-crs-3.0.2 /usr/local
$ cd /usr/local/owasp-modsecurity-crs-3.0.2
$ sudo cp crs-setup.conf.example crs-setup.conf
18
• Can use /usr/local/ as above or another location of your choice
• Version 3.1.0 of the CRS is currently in RC1
Modify Configuration
# Include the recommended configuration
Include /etc/nginx/modsec/modsecurity.conf
# OWASP CRS v3 rules
Include /usr/local/owasp-modsecurity-crs-3.0.2/crs-setup.conf
Include /usr/local/owasp-modsecurity-crs-3.0.2/rules/REQUEST-900-EXCLUSION-RULES-BEFORE-
CRS.conf
Include /usr/local/owasp-modsecurity-crs-3.0.2/rules/REQUEST-901-INITIALIZATION.conf
Include /usr/local/owasp-modsecurity-crs-3.0.2/rules/REQUEST-905-COMMON-EXCEPTIONS.conf
Include /usr/local/owasp-modsecurity-crs-3.0.2/rules/REQUEST-910-IP-REPUTATION.conf
Include /usr/local/owasp-modsecurity-crs-3.0.2/rules/REQUEST-911-METHOD-ENFORCEMENT.conf
...
19
Add the bolded text to existing /etc/nginx/modsec/main.conf:
Verify Installation
$ curl http://localhost/?exec=/bin/bash
<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.15.3</center>
</body>
</html>
20
• Will be detected by CRS as RCE attack
• Can try other attacks such as SQL Injection, XSS, etc.
Agenda
• ModSecurity Overview
• OWASP Core Rule Set Overview
• OWASP Core Rule Set Installation
• OWASP Core Rule Set Tuning
• Demo
• Summary
Tuning for False Positives
• Run ModSecurity in blocking mode (SecRuleEngine On).
◦ If you watched previous webinar or have been following instructions on our website then this is already the case.
• Ensure audit log is enabled (default behavior)
• Set a high anomaly threshold, > 1000. Uncomment below rule in crs-setup.conf and adjust threshold:
22
SecAction  "id:900110,
phase:1,
nolog,
pass,
t:none,
setvar:tx.inbound_anomaly_score_threshold=1000,
setvar:tx.outbound_anomaly_score_threshold=1000"
Tuning for False Positives
• Monitor audit log for false positives
• For any false positives, either modify application to remove strings triggering false positives or remove offending rule:
23
SecRemoveRuleByID rule-id
• Progressively lower anomaly threshold, to ideally back to the default of 5.
Performance Tuning
• Disable audit log - Great for visibility, bad for performance. Change value of SecAuditEngine in
/etc/nginx/modsec/modsecurity.conf:
24
2017/12/19 14:40:58 [warn] 1205#1205: *12 [client 127.0.0.1] ModSecurity:
Access denied with code 403 (phase 1). Matched "Operator 'Contains' with
parameter 'test' against variable 'ARGS:testparam' (Value: 'thisisatest' )
[file "/etc/nginx/modsec/ main.conf"] [line "202"] [id "1234"] [rev ""] [msg
""] [data ""] [severity "0"] [ver ""] [maturity "0"] [accuracy "0"]
[hostname "127.0.0.1"] [uri "/foo"] [unique_id "151369445814.452751"] [ref
"o7,4v19,11"], client: 127.0.0.1, server: , request: "GET /
foo?testparam=thisisatest HTTP/1.1", host: "localhost"
SecAuditEngine off
• NGINX error log contains information on blocked requests:
Performance Tuning
• Requests for static files don’t need to be inspected by ModSecurity. Use NGINX location blocks to separate out requests for static and
dynamic content:
25
server {
listen 80;
location / {
modsecurity on;
modsecurity_rules_file /etc/nginx/modsec/main.conf;
proxy_pass http://localhost:8085;
proxy_set_header Host $host;
}
location ~ .(gif|jpg|png|jpeg|svg)$ {
root /data/images;
}
}
Agenda
• ModSecurity Overview
• OWASP Core Rule Set Overview
• OWASP Core Rule Set Installation
• OWASP Core Rule Set Tuning
• Demo
• Summary
Agenda
• ModSecurity Overview
• OWASP Core Rule Set Overview
• OWASP Core Rule Set Installation
• OWASP Core Rule Set Tuning
• Demo
• Summary
Summary
• The OWASP Core Rule Set (CRS) is the standard rule set to be used with ModSecurity
• Open source and community-maintained
• Protects against many vulnerabilities: SQLi, RCE, RFI, etc.
• Designed for low-rate of false positives by default
• To tune, set a high anomaly threshold and progressively lower it
• Disabling audit log and not inspected static content will improve performance
Download our Free Ebook
29
• How ModSecurity 3.0 integrates with NGINX
• Installing ModSecurity with NGINX Plus
• Compiling and installing ModSecurity with NGINX Open Source
• Installing the Core Rule Set
• Installing Trustwave Commercial Rules
• Integrating with Project HoneyPot for IP reputation
• Tuning to minimize false positives
• Performance Tuning
Download now:
https://www.nginx.com/resources/library/mo
dsecurity-3-nginx-quick-start-guide/
Q & ATry NGINX Plus and NGINX WAF free for 30 days: nginx.com/free-trial-request

Mais conteúdo relacionado

Mais procurados

[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
OpenStack Korea Community
 

Mais procurados (20)

Database Firewall with Snort
Database Firewall with SnortDatabase Firewall with Snort
Database Firewall with Snort
 
Nginx A High Performance Load Balancer, Web Server & Reverse Proxy
Nginx A High Performance Load Balancer, Web Server & Reverse ProxyNginx A High Performance Load Balancer, Web Server & Reverse Proxy
Nginx A High Performance Load Balancer, Web Server & Reverse Proxy
 
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
 
Nginx Essential
Nginx EssentialNginx Essential
Nginx Essential
 
From Java 17 to 21- A Showcase of JDK Security Enhancements
From Java 17 to 21- A Showcase of JDK Security EnhancementsFrom Java 17 to 21- A Showcase of JDK Security Enhancements
From Java 17 to 21- A Showcase of JDK Security Enhancements
 
NGINX: Basics and Best Practices EMEA
NGINX: Basics and Best Practices EMEANGINX: Basics and Best Practices EMEA
NGINX: Basics and Best Practices EMEA
 
Learn nginx in 90mins
Learn nginx in 90minsLearn nginx in 90mins
Learn nginx in 90mins
 
Nginx
NginxNginx
Nginx
 
IPVS for Docker Containers
IPVS for Docker ContainersIPVS for Docker Containers
IPVS for Docker Containers
 
5 things you didn't know nginx could do
5 things you didn't know nginx could do5 things you didn't know nginx could do
5 things you didn't know nginx could do
 
An Introduction to Kubernetes
An Introduction to KubernetesAn Introduction to Kubernetes
An Introduction to Kubernetes
 
Learning postgresql
Learning postgresqlLearning postgresql
Learning postgresql
 
Docker Swarm 0.2.0
Docker Swarm 0.2.0Docker Swarm 0.2.0
Docker Swarm 0.2.0
 
Kubernetes Security
Kubernetes SecurityKubernetes Security
Kubernetes Security
 
High Availability Content Caching with NGINX
High Availability Content Caching with NGINXHigh Availability Content Caching with NGINX
High Availability Content Caching with NGINX
 
NGINX: Basics & Best Practices - EMEA Broadcast
NGINX: Basics & Best Practices - EMEA BroadcastNGINX: Basics & Best Practices - EMEA Broadcast
NGINX: Basics & Best Practices - EMEA Broadcast
 
Introduction to NGINX web server
Introduction to NGINX web serverIntroduction to NGINX web server
Introduction to NGINX web server
 
MySQL Monitoring using Prometheus & Grafana
MySQL Monitoring using Prometheus & GrafanaMySQL Monitoring using Prometheus & Grafana
MySQL Monitoring using Prometheus & Grafana
 
Docker Security Overview
Docker Security OverviewDocker Security Overview
Docker Security Overview
 
HAProxy
HAProxy HAProxy
HAProxy
 

Semelhante a ModSecurity and NGINX: Tuning the OWASP Core Rule Set

Apache Street Smarts Presentation (SANS 99)
Apache Street Smarts Presentation (SANS 99)Apache Street Smarts Presentation (SANS 99)
Apache Street Smarts Presentation (SANS 99)
Michael Dobe, Ph.D.
 

Semelhante a ModSecurity and NGINX: Tuning the OWASP Core Rule Set (20)

ModSecurity and NGINX: Tuning the OWASP Core Rule Set (Updated)
ModSecurity and NGINX: Tuning the OWASP Core Rule Set (Updated)ModSecurity and NGINX: Tuning the OWASP Core Rule Set (Updated)
ModSecurity and NGINX: Tuning the OWASP Core Rule Set (Updated)
 
ModSecurity and NGINX: Tuning the OWASP Core Rule Set - EMEA
ModSecurity and NGINX: Tuning the OWASP Core Rule Set - EMEAModSecurity and NGINX: Tuning the OWASP Core Rule Set - EMEA
ModSecurity and NGINX: Tuning the OWASP Core Rule Set - EMEA
 
ModSecurity and NGINX: Tuning the OWASP Core Rule Set - EMEA (Updated)
ModSecurity and NGINX: Tuning the OWASP Core Rule Set - EMEA (Updated)ModSecurity and NGINX: Tuning the OWASP Core Rule Set - EMEA (Updated)
ModSecurity and NGINX: Tuning the OWASP Core Rule Set - EMEA (Updated)
 
Optimizing ModSecurity on NGINX and NGINX Plus
Optimizing ModSecurity on NGINX and NGINX PlusOptimizing ModSecurity on NGINX and NGINX Plus
Optimizing ModSecurity on NGINX and NGINX Plus
 
Introducing the OWASP ModSecurity Core Rule Set
Introducing the OWASP ModSecurity Core Rule SetIntroducing the OWASP ModSecurity Core Rule Set
Introducing the OWASP ModSecurity Core Rule Set
 
ModSecurity 3.0 and NGINX: Getting Started
ModSecurity 3.0 and NGINX: Getting StartedModSecurity 3.0 and NGINX: Getting Started
ModSecurity 3.0 and NGINX: Getting Started
 
ModSecurity 3.0 and NGINX: Getting Started - EMEA
ModSecurity 3.0 and NGINX: Getting Started - EMEAModSecurity 3.0 and NGINX: Getting Started - EMEA
ModSecurity 3.0 and NGINX: Getting Started - EMEA
 
Container Security - Let's see Falco and Sysdig in Action by Stefan Trimborn
Container Security - Let's see Falco and Sysdig in Action by Stefan Trimborn Container Security - Let's see Falco and Sysdig in Action by Stefan Trimborn
Container Security - Let's see Falco and Sysdig in Action by Stefan Trimborn
 
Apache Street Smarts Presentation (SANS 99)
Apache Street Smarts Presentation (SANS 99)Apache Street Smarts Presentation (SANS 99)
Apache Street Smarts Presentation (SANS 99)
 
How to secure your web applications with NGINX
How to secure your web applications with NGINXHow to secure your web applications with NGINX
How to secure your web applications with NGINX
 
MongoDB MUG Delhi NCR - December 19 2020 (Cloud Security)
MongoDB MUG Delhi NCR - December 19 2020 (Cloud Security)MongoDB MUG Delhi NCR - December 19 2020 (Cloud Security)
MongoDB MUG Delhi NCR - December 19 2020 (Cloud Security)
 
5 Ways to Secure Your Containers for Docker and Beyond
5 Ways to Secure Your Containers for Docker and Beyond5 Ways to Secure Your Containers for Docker and Beyond
5 Ways to Secure Your Containers for Docker and Beyond
 
Securing virtual workload and cloud
Securing virtual workload and cloudSecuring virtual workload and cloud
Securing virtual workload and cloud
 
Automating cloud security - Jonny Griffin
Automating cloud security - Jonny GriffinAutomating cloud security - Jonny Griffin
Automating cloud security - Jonny Griffin
 
Best Practices for Deploying Enterprise Applications on UNIX
Best Practices for Deploying Enterprise Applications on UNIXBest Practices for Deploying Enterprise Applications on UNIX
Best Practices for Deploying Enterprise Applications on UNIX
 
OTRS
OTRSOTRS
OTRS
 
What HPC can learn from DevOps?
What HPC can learn from DevOps?What HPC can learn from DevOps?
What HPC can learn from DevOps?
 
Security for cloud native workloads
Security for cloud native workloadsSecurity for cloud native workloads
Security for cloud native workloads
 
Room 1 - 6 - Trần Quốc Sang - Autoscaling for multi cloud platform based on S...
Room 1 - 6 - Trần Quốc Sang - Autoscaling for multi cloud platform based on S...Room 1 - 6 - Trần Quốc Sang - Autoscaling for multi cloud platform based on S...
Room 1 - 6 - Trần Quốc Sang - Autoscaling for multi cloud platform based on S...
 
Outpost24 webinar - How to secure cloud services in the DevOps fast lane
Outpost24 webinar - How to secure cloud services in the DevOps fast laneOutpost24 webinar - How to secure cloud services in the DevOps fast lane
Outpost24 webinar - How to secure cloud services in the DevOps fast lane
 

Mais de NGINX, Inc.

How to Avoid the Top 5 NGINX Configuration Mistakes.pptx
How to Avoid the Top 5 NGINX Configuration Mistakes.pptxHow to Avoid the Top 5 NGINX Configuration Mistakes.pptx
How to Avoid the Top 5 NGINX Configuration Mistakes.pptx
NGINX, Inc.
 

Mais de NGINX, Inc. (20)

【NGINXセミナー】 Ingressを使ってマイクロサービスの運用を楽にする方法
【NGINXセミナー】 Ingressを使ってマイクロサービスの運用を楽にする方法【NGINXセミナー】 Ingressを使ってマイクロサービスの運用を楽にする方法
【NGINXセミナー】 Ingressを使ってマイクロサービスの運用を楽にする方法
 
【NGINXセミナー】 NGINXのWAFとは?その使い方と設定方法 解説セミナー
【NGINXセミナー】 NGINXのWAFとは?その使い方と設定方法 解説セミナー【NGINXセミナー】 NGINXのWAFとは?その使い方と設定方法 解説セミナー
【NGINXセミナー】 NGINXのWAFとは?その使い方と設定方法 解説セミナー
 
【NGINXセミナー】API ゲートウェイとしてのNGINX Plus活用方法
【NGINXセミナー】API ゲートウェイとしてのNGINX Plus活用方法【NGINXセミナー】API ゲートウェイとしてのNGINX Plus活用方法
【NGINXセミナー】API ゲートウェイとしてのNGINX Plus活用方法
 
Get Hands-On with NGINX and QUIC+HTTP/3
Get Hands-On with NGINX and QUIC+HTTP/3Get Hands-On with NGINX and QUIC+HTTP/3
Get Hands-On with NGINX and QUIC+HTTP/3
 
Managing Kubernetes Cost and Performance with NGINX & Kubecost
Managing Kubernetes Cost and Performance with NGINX & KubecostManaging Kubernetes Cost and Performance with NGINX & Kubecost
Managing Kubernetes Cost and Performance with NGINX & Kubecost
 
Manage Microservices Chaos and Complexity with Observability
Manage Microservices Chaos and Complexity with ObservabilityManage Microservices Chaos and Complexity with Observability
Manage Microservices Chaos and Complexity with Observability
 
Accelerate Microservices Deployments with Automation
Accelerate Microservices Deployments with AutomationAccelerate Microservices Deployments with Automation
Accelerate Microservices Deployments with Automation
 
Unit 2: Microservices Secrets Management 101
Unit 2: Microservices Secrets Management 101Unit 2: Microservices Secrets Management 101
Unit 2: Microservices Secrets Management 101
 
Unit 1: Apply the Twelve-Factor App to Microservices Architectures
Unit 1: Apply the Twelve-Factor App to Microservices ArchitecturesUnit 1: Apply the Twelve-Factor App to Microservices Architectures
Unit 1: Apply the Twelve-Factor App to Microservices Architectures
 
NGINX基本セミナー(セキュリティ編)~NGINXでセキュアなプラットフォームを実現する方法!
NGINX基本セミナー(セキュリティ編)~NGINXでセキュアなプラットフォームを実現する方法!NGINX基本セミナー(セキュリティ編)~NGINXでセキュアなプラットフォームを実現する方法!
NGINX基本セミナー(セキュリティ編)~NGINXでセキュアなプラットフォームを実現する方法!
 
Easily View, Manage, and Scale Your App Security with F5 NGINX
Easily View, Manage, and Scale Your App Security with F5 NGINXEasily View, Manage, and Scale Your App Security with F5 NGINX
Easily View, Manage, and Scale Your App Security with F5 NGINX
 
NGINXセミナー(基本編)~いまさら聞けないNGINXコンフィグなど基本がわかる!
NGINXセミナー(基本編)~いまさら聞けないNGINXコンフィグなど基本がわかる!NGINXセミナー(基本編)~いまさら聞けないNGINXコンフィグなど基本がわかる!
NGINXセミナー(基本編)~いまさら聞けないNGINXコンフィグなど基本がわかる!
 
Keep Ahead of Evolving Cyberattacks with OPSWAT and F5 NGINX
Keep Ahead of Evolving Cyberattacks with OPSWAT and F5 NGINXKeep Ahead of Evolving Cyberattacks with OPSWAT and F5 NGINX
Keep Ahead of Evolving Cyberattacks with OPSWAT and F5 NGINX
 
Install and Configure NGINX Unit, the Universal Application, Web, and Proxy S...
Install and Configure NGINX Unit, the Universal Application, Web, and Proxy S...Install and Configure NGINX Unit, the Universal Application, Web, and Proxy S...
Install and Configure NGINX Unit, the Universal Application, Web, and Proxy S...
 
Protecting Apps from Hacks in Kubernetes with NGINX
Protecting Apps from Hacks in Kubernetes with NGINXProtecting Apps from Hacks in Kubernetes with NGINX
Protecting Apps from Hacks in Kubernetes with NGINX
 
NGINX Kubernetes API
NGINX Kubernetes APINGINX Kubernetes API
NGINX Kubernetes API
 
Successfully Implement Your API Strategy with NGINX
Successfully Implement Your API Strategy with NGINXSuccessfully Implement Your API Strategy with NGINX
Successfully Implement Your API Strategy with NGINX
 
Installing and Configuring NGINX Open Source
Installing and Configuring NGINX Open SourceInstalling and Configuring NGINX Open Source
Installing and Configuring NGINX Open Source
 
Shift Left for More Secure Apps with F5 NGINX
Shift Left for More Secure Apps with F5 NGINXShift Left for More Secure Apps with F5 NGINX
Shift Left for More Secure Apps with F5 NGINX
 
How to Avoid the Top 5 NGINX Configuration Mistakes.pptx
How to Avoid the Top 5 NGINX Configuration Mistakes.pptxHow to Avoid the Top 5 NGINX Configuration Mistakes.pptx
How to Avoid the Top 5 NGINX Configuration Mistakes.pptx
 

Último

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Último (20)

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 

ModSecurity and NGINX: Tuning the OWASP Core Rule Set

  • 1. ModSecurity and NGINX: Tuning the OWASP Core Rule Set
  • 2. Faisal Memon Product Marketing Manager, NGINX Formerly: • Sr. Technical Marketing Engineer, Riverbed • Technical Marketing Engineer, Cisco • Software Engineer, Cisco Who am I?
  • 3. Previously on… ModSecurity 3.0 and NGINX: Getting Started • How to install ModSecurity 3.0 with NGINX Plus • How to compile and install ModSecurity 3.0 with NGINX Open Source • How to validate installation with a basic test rule • Watch on demand: nginx.com/webinars/modsecurity-3-0- and-nginx-getting-started/ 3
  • 4. Agenda • ModSecurity Overview • OWASP Core Rule Set Overview • OWASP Core Rule Set Installation • OWASP Core Rule Set Tuning • Demo • Summary
  • 5. Brief History of ModSecurity ● 2002: First open source release ● 2004: Commercialized as Thinking Stone ● 2006: Thinking Stone acquired by Breach Security ● 2006: ModSecurity 2.0 released ● 2009: Ivan Ristic, original author, leaves Breach Security ● 2010: Breach Security acquired by TrustWave ● 2017: ModSecurity 3.0 released “... I realized that producing secure web applications is virtually impossible. As a result, I started to fantasize about a tool that would sit in front of web applications and control the flow of data in and out.” - Ivan Ristic, ModSecurity creator
  • 6. What is ModSecurity? • Layer 7 web application firewall (WAF) • Dynamic module for NGINX • Inspects all incoming requests for malicious patterns • Requests that have malicious patterns are logged and/or dropped • ModSecurity is the WAF engine, the Core Rule Set (CRS) defines the malicious patterns 6
  • 7. ModSecurity 3.0 and NGINX Interface • ModSecurity 3.0 is a complete rewrite of ModSecurity that works natively with NGINX • Core ModSecurity functionality moved to standalone libModSecurity functionality • NGINX Connector interfaces between libModSecurity and NGINX • Connector also available for Apache 7
  • 8. “ModSecurity is not a high- flying, cloud-enabled, machine- learning mastermind. It is better to think of ModSecurity as of a mechanical watch. - Christian Folini, co-lead OWASP CRS
  • 9. ModSecurity 3.0 Caveats • Rules that inspect the response body are not supported and are ignored if included in the configuration The NGINX sub_filter directive can be used to inspect and rewrite response data In the OWASP Core Rule Set, these are the 95x rules. • The OWASP Core Rule Set DDoS mitigation rules (REQUEST-912-DOS- PROTECTION.conf) are not supported. Use NGINX rate limiting instead. • Inclusion of the request and response body in the audit log is not supported. • Some directives are not implemented; you may get an error if you try to use them. The ModSecurity Reference Manual lists all the available directives in ModSecurity and whether or not they are supported in libModSecurity. 9
  • 10. OSS and NGINX Plus Options ModSecurity OSS NGINX WAF Obtaining the module Build from source, test and deploy Fully-tested builds direct from NGINX Updates Track GitHub, build and deploy updates as necessary NGINX tracks GitHub and pushes out necessary updates Support Community (GitHub, StackOverflow) Additional commercial support from Trustwave Commercial support from NGINX and Trustwave Financial Cost $0, self-supported Per-instance, NGINX supported
  • 11. Agenda • ModSecurity Overview • OWASP Core Rule Set Overview • OWASP Core Rule Set Installation • OWASP Core Rule Set Tuning • Demo • Summary
  • 12. CRS Overview • First released in 2006 by Ofer Shezaf • Version 3.0 released in November 2016 ◦ Over 90% reduction in false positives ◦ Recommended for use with NGINX • Community-maintained by a team of 10 developers, co-led by Dr. Christian Folini • Blocks SQLi, RCE, LFI, RFI, etc. • Should be used for all ModSecurity deployments • Available at: github.com/SpiderLabs/owasp- modsecurity-crs 12
  • 13. CRS Key Files and Directories • crs-setup.conf – The main configuration file for the CRS • rules/ – Directory containing the rules organized into different files, each of which has a number assigned to it: ◦ 90x files – Exclusions to remedy false positives ◦ 91x files – Rules to detect malicious clients, such as scanners and bots ◦ 92x files – Rules to detect protocol violations ◦ 93x and 94x files – Rules to detect application attacks such as SQLi and RCE ◦ 95x files – Rules to detect outbound data leakage. Not supported by NGINX or NGINX Plus ◦ .data files – Data used by the rules. For example crawlers-user- agents.data contains a list of User-Agent values used by scanners. This file is used by rule REQUEST-913-SCANNER- DETECTION.conf to identify scanners and bots. 13 REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf REQUEST-901-INITIALIZATION.conf REQUEST-903.9001-DRUPAL-EXCLUSION-RULES.conf REQUEST-903.9002-WORDPRESS-EXCLUSION-RULES.conf REQUEST-905-COMMON-EXCEPTIONS.conf REQUEST-910-IP-REPUTATION.conf REQUEST-911-METHOD-ENFORCEMENT.conf REQUEST-912-DOS-PROTECTION.conf REQUEST-913-SCANNER-DETECTION.conf REQUEST-920-PROTOCOL-ENFORCEMENT.conf REQUEST-921-PROTOCOL-ATTACK.conf REQUEST-930-APPLICATION-ATTACK-LFI.conf REQUEST-931-APPLICATION-ATTACK-RFI.conf REQUEST-932-APPLICATION-ATTACK-RCE.conf REQUEST-933-APPLICATION-ATTACK-PHP.conf REQUEST-941-APPLICATION-ATTACK-XSS.conf REQUEST-942-APPLICATION-ATTACK-SQLI.conf REQUEST-943-APPLICATION-ATTACK-SESSION-FIXATION.conf REQUEST-949-BLOCKING-EVALUATION.conf RESPONSE-950-DATA-LEAKAGES.conf RESPONSE-951-DATA-LEAKAGES-SQL.conf RESPONSE-952-DATA-LEAKAGES-JAVA.conf RESPONSE-953-DATA-LEAKAGES-PHP.conf RESPONSE-954-DATA-LEAKAGES-IIS.conf RESPONSE-959-BLOCKING-EVALUATION.conf RESPONSE-980-CORRELATION.conf RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf
  • 14. CRS Anomaly Scoring • Configurable anomaly-scoring model • Each rule that fires increases the anomaly score • If score exceeds configured anomaly threshold then transaction is blocked • The anomaly levels are as follows: ◦ Critical – Anomaly score of 5. Likely application attack. Mostly generated by 93x and 94x files ◦ Error – Anomaly score of 4. Likely data leakage. Generated mostly by 95x files. 95x files are not supported with NGINX or NGINX Plus ◦ Warning – Anomaly score of 3. Likely malicious client. Generated mostly by 91x files ◦ Notice – Anomaly score of 2. Likely protocol violations. Generated mostly by 92x files • Default anomaly threshold is 5. 14
  • 15. CRS Paranoia Modes • The CRS has different paranoia levels that enable more rules • More attacks blocked at higher paranoia levels but also more false positives • Higher paranoia levels will require application modifications • Paranoia levels: ◦ Paranoia Level 1 (default) – Basic security. Minimal amount of False Positives ◦ Paranoia Level 2 – Elevated security level. More rules, fair amount of false positives ◦ Paranoia Level 3 – Online banking level security. Specialized rules, more false positives ◦ Paranoia Level 4 - Nuclear power plant level security. Insane rules, lots of false positives 15
  • 17. Agenda • ModSecurity Overview • OWASP Core Rule Set Overview • OWASP Core Rule Set Installation • OWASP Core Rule Set Tuning • Demo • Summary
  • 18. Download and Install from GitHub $ wget https://github.com/SpiderLabs/owasp-modsecurity-crs/archive/v3.0.2.tar.gz $ tar -xzvf v3.0.2.tar.gz $ sudo mv owasp-modsecurity-crs-3.0.2 /usr/local $ cd /usr/local/owasp-modsecurity-crs-3.0.2 $ sudo cp crs-setup.conf.example crs-setup.conf 18 • Can use /usr/local/ as above or another location of your choice • Version 3.1.0 of the CRS is currently in RC1
  • 19. Modify Configuration # Include the recommended configuration Include /etc/nginx/modsec/modsecurity.conf # OWASP CRS v3 rules Include /usr/local/owasp-modsecurity-crs-3.0.2/crs-setup.conf Include /usr/local/owasp-modsecurity-crs-3.0.2/rules/REQUEST-900-EXCLUSION-RULES-BEFORE- CRS.conf Include /usr/local/owasp-modsecurity-crs-3.0.2/rules/REQUEST-901-INITIALIZATION.conf Include /usr/local/owasp-modsecurity-crs-3.0.2/rules/REQUEST-905-COMMON-EXCEPTIONS.conf Include /usr/local/owasp-modsecurity-crs-3.0.2/rules/REQUEST-910-IP-REPUTATION.conf Include /usr/local/owasp-modsecurity-crs-3.0.2/rules/REQUEST-911-METHOD-ENFORCEMENT.conf ... 19 Add the bolded text to existing /etc/nginx/modsec/main.conf:
  • 20. Verify Installation $ curl http://localhost/?exec=/bin/bash <html> <head><title>403 Forbidden</title></head> <body bgcolor="white"> <center><h1>403 Forbidden</h1></center> <hr><center>nginx/1.15.3</center> </body> </html> 20 • Will be detected by CRS as RCE attack • Can try other attacks such as SQL Injection, XSS, etc.
  • 21. Agenda • ModSecurity Overview • OWASP Core Rule Set Overview • OWASP Core Rule Set Installation • OWASP Core Rule Set Tuning • Demo • Summary
  • 22. Tuning for False Positives • Run ModSecurity in blocking mode (SecRuleEngine On). ◦ If you watched previous webinar or have been following instructions on our website then this is already the case. • Ensure audit log is enabled (default behavior) • Set a high anomaly threshold, > 1000. Uncomment below rule in crs-setup.conf and adjust threshold: 22 SecAction "id:900110, phase:1, nolog, pass, t:none, setvar:tx.inbound_anomaly_score_threshold=1000, setvar:tx.outbound_anomaly_score_threshold=1000"
  • 23. Tuning for False Positives • Monitor audit log for false positives • For any false positives, either modify application to remove strings triggering false positives or remove offending rule: 23 SecRemoveRuleByID rule-id • Progressively lower anomaly threshold, to ideally back to the default of 5.
  • 24. Performance Tuning • Disable audit log - Great for visibility, bad for performance. Change value of SecAuditEngine in /etc/nginx/modsec/modsecurity.conf: 24 2017/12/19 14:40:58 [warn] 1205#1205: *12 [client 127.0.0.1] ModSecurity: Access denied with code 403 (phase 1). Matched "Operator 'Contains' with parameter 'test' against variable 'ARGS:testparam' (Value: 'thisisatest' ) [file "/etc/nginx/modsec/ main.conf"] [line "202"] [id "1234"] [rev ""] [msg ""] [data ""] [severity "0"] [ver ""] [maturity "0"] [accuracy "0"] [hostname "127.0.0.1"] [uri "/foo"] [unique_id "151369445814.452751"] [ref "o7,4v19,11"], client: 127.0.0.1, server: , request: "GET / foo?testparam=thisisatest HTTP/1.1", host: "localhost" SecAuditEngine off • NGINX error log contains information on blocked requests:
  • 25. Performance Tuning • Requests for static files don’t need to be inspected by ModSecurity. Use NGINX location blocks to separate out requests for static and dynamic content: 25 server { listen 80; location / { modsecurity on; modsecurity_rules_file /etc/nginx/modsec/main.conf; proxy_pass http://localhost:8085; proxy_set_header Host $host; } location ~ .(gif|jpg|png|jpeg|svg)$ { root /data/images; } }
  • 26. Agenda • ModSecurity Overview • OWASP Core Rule Set Overview • OWASP Core Rule Set Installation • OWASP Core Rule Set Tuning • Demo • Summary
  • 27. Agenda • ModSecurity Overview • OWASP Core Rule Set Overview • OWASP Core Rule Set Installation • OWASP Core Rule Set Tuning • Demo • Summary
  • 28. Summary • The OWASP Core Rule Set (CRS) is the standard rule set to be used with ModSecurity • Open source and community-maintained • Protects against many vulnerabilities: SQLi, RCE, RFI, etc. • Designed for low-rate of false positives by default • To tune, set a high anomaly threshold and progressively lower it • Disabling audit log and not inspected static content will improve performance
  • 29. Download our Free Ebook 29 • How ModSecurity 3.0 integrates with NGINX • Installing ModSecurity with NGINX Plus • Compiling and installing ModSecurity with NGINX Open Source • Installing the Core Rule Set • Installing Trustwave Commercial Rules • Integrating with Project HoneyPot for IP reputation • Tuning to minimize false positives • Performance Tuning Download now: https://www.nginx.com/resources/library/mo dsecurity-3-nginx-quick-start-guide/
  • 30.
  • 31. Q & ATry NGINX Plus and NGINX WAF free for 30 days: nginx.com/free-trial-request

Notas do Editor

  1. - We will
  2. - We will