High voltage protection for your webapps

Author

Edward Fjellskål & Kacper Wysocki

Date

Hack.lu, October 23, 2012

Who R US?

img/frying.jpg

Who R US?

Storytime

Varnish got prod ready.

Swiss army katana

img/invaders.gif

B.L

I fear not the man
who has practiced 10,000 kicks
once,
but I fear the man who has
practiced one kick
10,000 times.

Varnish can haz

LOLBUNNY

img/lolbunny.jpg

There are no silver bullets

Usually we use varnish to:

There are no silver bullets!

img/notbutter.jpg

Aaaand then!

we were under siege!

img/fight-club-soap.jpg

Solved it!

if(req.http.attack ~ "pattern"){
   set resp.http.Cache-Control =
                "max-age=3312315123166";
}

The app stack

Mod_security

Other WAFs?

Instead

Instead

Instead

Instead

Rules

Rulez

Rulez

Rulez

The Approach

img/shipping.jpg

The Approach

Thwarting attacks

img/truck.jpg

Thwarting attacks

what we do today:

Cloaking

Cloud

diff -u mod_sec VCL

mod_security

SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|
REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/*
"http:\/\/[\w\.]+?\/.*?\.pdf\b[^\x0d\x0a]*#" \
  "phase:2,rev:'2',ver:'OWASP_CRS/2.2.6',maturity:'9',
  accuracy:'9',capture,t:none,t:htmlEntityDecode,
  t:compressWhiteSpace,t:lowercase, ctl:auditLogParts=+E,block,
  id:'950018', setvar:'tx.msg=%{rule.msg}',
  setvar:tx.anomaly_score=+%{tx.critical_anomaly_score},
  setvar:tx.%{rule.id}-OWASP_CRS/WEB_ATTACK/UPDF_XSS-%{matched_var_name}=%{tx.0}"

VFW

if (req.url ~ "(?i)(S|%[57]3)(\s|%20|\t|%09|\+)*(C|%[46]3)
     (\s|%20|\t|%09|\+)*(R|%[57]2)(\s|%20|\t|%09|\+)*
     (I|%[46]9)(\s|%20|\t|%09|\+)*(P|%[57]0)(\s|%20|\t|%09|\+)*
     (T|%[57]4)(\s|%20|\t|%09|\+)*(>|%3E)") {
   set req.http.X-VFW-Threat = "Cross-site Scripting";
   set req.http.X-VFW-RuleID = "xss.xss-2";
   call vfw_main;
}

$@%^&*(!

completely unreadable

  • and these are the short ones!

VFW

if (req.url ~ "(SHOW|DROP|CREATE) (DATABASES|TABLES|PROCESSLIST)") {
  set req.http.X-SEC-RuleName = "SQL Injection";
  set req.http.X-SEC-RuleId = "sql-15"
  call sec_sql_sev1;
}

Varnish Security FireWall

img/pat.jpg

Security handlers

Security handlers

img/bike.jpg

Weaknesses

A note on patterns

All fixed set patterns
are incapable
of adaptability or pliability.
The truth is outside of
all fixed patterns.

  -- Bruce, again.

Future work

Future

img/energy.jpg

Questions?

http://github.com/comotion/VSF

edwardfjellskaal@gmail.com kwy@redpill-linpro.com

References: