ModSecurity and Logging

A presentation at DevOpsDays Poznan in May 2019 in Poznań, Poland by Philipp Krenn

Slide 1

Slide 1

ModSecurity and Logging Philipp Krenn @xeraa @xeraa

Slide 2

Slide 2

Let’s talk about security… @xeraa

Slide 3

Slide 3

@xeraa

Slide 4

Slide 4

@xeraa

Slide 5

Slide 5

A1:2017-Injection https://www.owasp.org/index.php/ Top_10-2017_Top_10 @xeraa

Slide 6

Slide 6

Hello World of SQL Injection $sql = “SELECT * FROM employees WHERE id = ” . trim($_GET[“id”]); error_log(“SQL query [read.php]: ” . $sql . “\n”, 3, “/var/log/app.log”); mysqli_multi_query($link, $sql); if($result = mysqli_use_result($link)){ $row = mysqli_fetch_array($result, MYSQLI_ASSOC); @xeraa

Slide 7

Slide 7

sqlmap —url “https://test.com/bad.php?id=1” @xeraa

Slide 8

Slide 8

@xeraa

Slide 9

Slide 9

Open source Cross-platform web application firewall (WAF) Visibility into HTTP(S) traffic Rules to implement protections @xeraa

Slide 10

Slide 10

Custom Rule SecRule REQUEST_FILENAME “form.php” “id:’400001’,chain,deny,log,msg:’Spam detected’” SecRule REQUEST_METHOD “POST” chain SecRule REQUEST_BODY “@rx (?i:(pills|insurance|rolex))” @xeraa

Slide 11

Slide 11

A10:2017-Insufficient Logging & Monitoring https://www.owasp.org/index.php/ Top_10-2017_Top_10 @xeraa

Slide 12

Slide 12

Slide 13

Slide 13

Log to JSON SecAuditLogFormat JSON https://www.cryptobells.com/mod_security-json-audit-logs-revisited/ @xeraa

Slide 14

Slide 14

Slide 15

Slide 15

@xeraa

Slide 16

Slide 16

Examples https://github.com/xeraa/mod_security-log @xeraa

Slide 17

Slide 17

ModSecurity Logging @xeraa