140
Repsheet A Behavior Based Approach to Web Application Security Aaron Bedra Application Security Lead Braintree Payments Wednesday, July 10, 13

Repsheet: A Behavior Based Approach to Web Application Security

Embed Size (px)

DESCRIPTION

This is a presentation on how to approach analyzing web application security.

Citation preview

Page 1: Repsheet: A Behavior Based Approach to Web Application Security

RepsheetA Behavior Based Approach to Web Application

Security

Aaron BedraApplication Security LeadBraintree Payments

Wednesday, July 10, 13

Page 2: Repsheet: A Behavior Based Approach to Web Application Security

Right now, your web applications are being

attacked

Wednesday, July 10, 13

Page 3: Repsheet: A Behavior Based Approach to Web Application Security

And it will happen again, and again, and

again

Wednesday, July 10, 13

Page 4: Repsheet: A Behavior Based Approach to Web Application Security

But not always in the way you think

Wednesday, July 10, 13

Page 5: Repsheet: A Behavior Based Approach to Web Application Security

Let’s take a look at typical application security measures

Wednesday, July 10, 13

Page 6: Repsheet: A Behavior Based Approach to Web Application Security

User Requests

Web Server

Application Environment

Wednesday, July 10, 13

Page 7: Repsheet: A Behavior Based Approach to Web Application Security

Wednesday, July 10, 13

Page 8: Repsheet: A Behavior Based Approach to Web Application Security

roland : 12345

Wednesday, July 10, 13

Page 9: Repsheet: A Behavior Based Approach to Web Application Security

roland : 12345

Wednesday, July 10, 13

Page 10: Repsheet: A Behavior Based Approach to Web Application Security

And we go on with our day

Wednesday, July 10, 13

Page 11: Repsheet: A Behavior Based Approach to Web Application Security

How many of you stop there?

Wednesday, July 10, 13

Page 12: Repsheet: A Behavior Based Approach to Web Application Security

It’s time to start asking more questions

Wednesday, July 10, 13

Page 13: Repsheet: A Behavior Based Approach to Web Application Security

But remember…

Wednesday, July 10, 13

Page 14: Repsheet: A Behavior Based Approach to Web Application Security

Don’t impact user experience!

Wednesday, July 10, 13

Page 15: Repsheet: A Behavior Based Approach to Web Application Security

???

Wednesday, July 10, 13

Page 16: Repsheet: A Behavior Based Approach to Web Application Security

• Signature based detection

• Anomaly detection

• Reputational intelligence

• Action

• Repsheet

Wednesday, July 10, 13

Page 17: Repsheet: A Behavior Based Approach to Web Application Security

Signatures

Wednesday, July 10, 13

Page 18: Repsheet: A Behavior Based Approach to Web Application Security

Mod Security

Wednesday, July 10, 13

Page 19: Repsheet: A Behavior Based Approach to Web Application Security

Web Application Firewall

Wednesday, July 10, 13

Page 20: Repsheet: A Behavior Based Approach to Web Application Security

Rule based detection

Wednesday, July 10, 13

Page 21: Repsheet: A Behavior Based Approach to Web Application Security

Allows you to block or alert if traffic matches a

signature

Wednesday, July 10, 13

Page 22: Repsheet: A Behavior Based Approach to Web Application Security

Improved by the OWASP Core Rule Set

Wednesday, July 10, 13

Page 23: Repsheet: A Behavior Based Approach to Web Application Security

A great tool to add to your stack

Wednesday, July 10, 13

Page 24: Repsheet: A Behavior Based Approach to Web Application Security

Works with Apache, nginx, and IIS

Wednesday, July 10, 13

Page 25: Repsheet: A Behavior Based Approach to Web Application Security

Works well with Apache

Wednesday, July 10, 13

Page 26: Repsheet: A Behavior Based Approach to Web Application Security

Like most signature based tools it requires

tuning

Wednesday, July 10, 13

Page 27: Repsheet: A Behavior Based Approach to Web Application Security

And has a high possibility of false

positives

Wednesday, July 10, 13

Page 28: Repsheet: A Behavior Based Approach to Web Application Security

Great for helping with 0-day attacks

Wednesday, July 10, 13

Page 29: Repsheet: A Behavior Based Approach to Web Application Security

Favor alerting over blocking in most

scenarios

Wednesday, July 10, 13

Page 30: Repsheet: A Behavior Based Approach to Web Application Security

User Requests

Web Server

ModSecurity

Application Environment

Wednesday, July 10, 13

Page 31: Repsheet: A Behavior Based Approach to Web Application Security

Anomalies

Wednesday, July 10, 13

Page 32: Repsheet: A Behavior Based Approach to Web Application Security

10.20.253.8 - - [23/Apr/2013:14:20:21 +0000] "POST /login HTTP/1.1" 200 267"-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0" "77.77.165.233"

Wednesday, July 10, 13

Page 33: Repsheet: A Behavior Based Approach to Web Application Security

10.20.253.8 - - [23/Apr/2013:14:20:22 +0000] "POST /users/king-roland/credit_cards HTTP/1.1" 302 2085 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0" "77.77.165.233"

Wednesday, July 10, 13

Page 34: Repsheet: A Behavior Based Approach to Web Application Security

10.20.253.8 - - [23/Apr/2013:14:20:23 +0000] "POST /users/king-roland/credit_cards HTTP/1.1" 302 2083 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0" "77.77.165.233"

Wednesday, July 10, 13

Page 35: Repsheet: A Behavior Based Approach to Web Application Security

10.20.253.8 - - [23/Apr/2013:14:20:24 +0000] "POST /users/king-roland/credit_cards HTTP/1.1" 302 2085 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0" "77.77.165.233"

Wednesday, July 10, 13

Page 36: Repsheet: A Behavior Based Approach to Web Application Security

What do you see?

Wednesday, July 10, 13

Page 37: Repsheet: A Behavior Based Approach to Web Application Security

I see a website getting carded

Wednesday, July 10, 13

Page 38: Repsheet: A Behavior Based Approach to Web Application Security

???

Wednesday, July 10, 13

Page 39: Repsheet: A Behavior Based Approach to Web Application Security

Play by play

Wednesday, July 10, 13

Page 40: Repsheet: A Behavior Based Approach to Web Application Security

10.20.253.8 - - [23/Apr/2013:14:20:21 +0000] "POST /login HTTP/1.1" 200 267"-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0" "77.77.165.233"

Login Request

Wednesday, July 10, 13

Page 41: Repsheet: A Behavior Based Approach to Web Application Security

10.20.253.8 - - [23/Apr/2013:14:20:22 +0000] "POST /users/king-roland/credit_cards HTTP/1.1" 302 2085 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0" "77.77.165.233"

Add credit card to account #11 sec delay

Wednesday, July 10, 13

Page 42: Repsheet: A Behavior Based Approach to Web Application Security

10.20.253.8 - - [23/Apr/2013:14:20:23 +0000] "POST /users/king-roland/credit_cards HTTP/1.1" 302 2083 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0" "77.77.165.233"

1 sec delayAdd credit card to account #2

FF 8 on Windows 7 or Bot?

Wednesday, July 10, 13

Page 43: Repsheet: A Behavior Based Approach to Web Application Security

10.20.253.8 - - [23/Apr/2013:14:20:24 +0000] "POST /users/king-roland/credit_cards HTTP/1.1" 302 2085 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0" "77.77.165.233"

1 sec delayAdd credit card to account #3

FF 8 on Windows 7 or Bot?

Plovdiv Bulgaria

Wednesday, July 10, 13

Page 44: Repsheet: A Behavior Based Approach to Web Application Security

And this continues…

Wednesday, July 10, 13

Page 45: Repsheet: A Behavior Based Approach to Web Application Security

10,000 more times

Wednesday, July 10, 13

Page 46: Repsheet: A Behavior Based Approach to Web Application Security

Those were the only requests that IP address

made

Wednesday, July 10, 13

Page 47: Repsheet: A Behavior Based Approach to Web Application Security

Aside from the number of requests what else

gave it away?

Wednesday, July 10, 13

Page 48: Repsheet: A Behavior Based Approach to Web Application Security

5%5%4%

27% 59%

GET POST HEAD PUT DELETE

Wednesday, July 10, 13

Page 49: Repsheet: A Behavior Based Approach to Web Application Security

HTTP method distribution is

important

Wednesday, July 10, 13

Page 50: Repsheet: A Behavior Based Approach to Web Application Security

When an actor deviates significantly, there must

be a reason!

Wednesday, July 10, 13

Page 51: Repsheet: A Behavior Based Approach to Web Application Security

Let’s talk GeoIP

Wednesday, July 10, 13

Page 52: Repsheet: A Behavior Based Approach to Web Application Security

Adding GeoIP information is

generically useful

Wednesday, July 10, 13

Page 53: Repsheet: A Behavior Based Approach to Web Application Security

But it also helps in the face of an attack

Wednesday, July 10, 13

Page 54: Repsheet: A Behavior Based Approach to Web Application Security

It can help protect you and your users

Wednesday, July 10, 13

Page 55: Repsheet: A Behavior Based Approach to Web Application Security

Scenario

Wednesday, July 10, 13

Page 56: Repsheet: A Behavior Based Approach to Web Application Security

King Roland gets his GMail account hacked

Wednesday, July 10, 13

Page 57: Repsheet: A Behavior Based Approach to Web Application Security

Hacker sends a password reset request

to your server

Wednesday, July 10, 13

Page 58: Repsheet: A Behavior Based Approach to Web Application Security

Normally, you would email the reset

Wednesday, July 10, 13

Page 59: Repsheet: A Behavior Based Approach to Web Application Security

Unless...

Wednesday, July 10, 13

Page 60: Repsheet: A Behavior Based Approach to Web Application Security

You realize that King Roland always logs in

from Druidia

Wednesday, July 10, 13

Page 61: Repsheet: A Behavior Based Approach to Web Application Security

But the hacker is requesting the reset from Spaceball City

Wednesday, July 10, 13

Page 62: Repsheet: A Behavior Based Approach to Web Application Security

Instead of sending the reset, you now ask

some questions

Wednesday, July 10, 13

Page 63: Repsheet: A Behavior Based Approach to Web Application Security

And hopefully protect King Roland from

further bad actions

Wednesday, July 10, 13

Page 64: Repsheet: A Behavior Based Approach to Web Application Security

GeoIP detection also helps you block traffic

from unwanted countries

Wednesday, July 10, 13

Page 65: Repsheet: A Behavior Based Approach to Web Application Security

User Requests

Web Server

ModSecurity

Application Environment

GeoIP

Wednesday, July 10, 13

Page 66: Repsheet: A Behavior Based Approach to Web Application Security

Other Anomalies

• Request Rate

• TCP Fingerprint vs. User Agent

• Account Create/Delete/Subscribe

• Anything you can imagine

Wednesday, July 10, 13

Page 67: Repsheet: A Behavior Based Approach to Web Application Security

What do they have in common?

Wednesday, July 10, 13

Page 68: Repsheet: A Behavior Based Approach to Web Application Security

Does the behavior fit an equation?

Wednesday, July 10, 13

Page 69: Repsheet: A Behavior Based Approach to Web Application Security

If so, your detection is simple

Wednesday, July 10, 13

Page 70: Repsheet: A Behavior Based Approach to Web Application Security

Request rate > Threshold

Wednesday, July 10, 13

Page 71: Repsheet: A Behavior Based Approach to Web Application Security

TCP fingerprint != User Agent

Wednesday, July 10, 13

Page 72: Repsheet: A Behavior Based Approach to Web Application Security

But the HTTP method deviation is harder

Wednesday, July 10, 13

Page 73: Repsheet: A Behavior Based Approach to Web Application Security

100% GET requests with a known UA (e.g.

Google) is ok

Wednesday, July 10, 13

Page 74: Repsheet: A Behavior Based Approach to Web Application Security

100% POST requests is not

Wednesday, July 10, 13

Page 75: Repsheet: A Behavior Based Approach to Web Application Security

But it’s not always that simple

Wednesday, July 10, 13

Page 76: Repsheet: A Behavior Based Approach to Web Application Security

Scenario

Wednesday, July 10, 13

Page 77: Repsheet: A Behavior Based Approach to Web Application Security

A high rate of account create requests are coming from a single

address

Wednesday, July 10, 13

Page 78: Repsheet: A Behavior Based Approach to Web Application Security

Is it a NATted IP or a fraud/spam bot?

Wednesday, July 10, 13

Page 79: Repsheet: A Behavior Based Approach to Web Application Security

We have patterns and data…

Wednesday, July 10, 13

Page 80: Repsheet: A Behavior Based Approach to Web Application Security

What’s the next step?

Wednesday, July 10, 13

Page 81: Repsheet: A Behavior Based Approach to Web Application Security

Quantitative Analysis

Wednesday, July 10, 13

Page 82: Repsheet: A Behavior Based Approach to Web Application Security

Quantitative Analysis

Wednesday, July 10, 13

Page 83: Repsheet: A Behavior Based Approach to Web Application Security

Quantitative AnalysisSecurity as a Data Science Probelm

Wednesday, July 10, 13

Page 84: Repsheet: A Behavior Based Approach to Web Application Security

We can apply some machine learning to the data in an attempt to

classify it

Wednesday, July 10, 13

Page 85: Repsheet: A Behavior Based Approach to Web Application Security

Classifier

???

User Requests

Web Server

ModSecurity

Application Environment

GeoIP

Wednesday, July 10, 13

Page 86: Repsheet: A Behavior Based Approach to Web Application Security

This is where a lot of the value comes from

Wednesday, July 10, 13

Page 87: Repsheet: A Behavior Based Approach to Web Application Security

And combined with signature detection

helps correlate attack events

Wednesday, July 10, 13

Page 88: Repsheet: A Behavior Based Approach to Web Application Security

But you still need a way to keep track of it all

Wednesday, July 10, 13

Page 89: Repsheet: A Behavior Based Approach to Web Application Security

Reputational Intelligence

Wednesday, July 10, 13

Page 90: Repsheet: A Behavior Based Approach to Web Application Security

Who’s naughty and who’s really naughty

Wednesday, July 10, 13

Page 91: Repsheet: A Behavior Based Approach to Web Application Security

Built up from the tools/techniques mentioned

previously

Wednesday, July 10, 13

Page 92: Repsheet: A Behavior Based Approach to Web Application Security

Provides local reputation

Wednesday, July 10, 13

Page 93: Repsheet: A Behavior Based Approach to Web Application Security

You can also purchase external reputation

feeds

Wednesday, July 10, 13

Page 94: Repsheet: A Behavior Based Approach to Web Application Security

The combination gives you solid awareness of

bad actors

Wednesday, July 10, 13

Page 95: Repsheet: A Behavior Based Approach to Web Application Security

Reputational Intelligence

External Reputation

Classifier

???

User Requests

Web Server

ModSecurity

Application Environment

GeoIP???

Wednesday, July 10, 13

Page 96: Repsheet: A Behavior Based Approach to Web Application Security

Action

Wednesday, July 10, 13

Page 97: Repsheet: A Behavior Based Approach to Web Application Security

So now you have a ton of new information

Wednesday, July 10, 13

Page 98: Repsheet: A Behavior Based Approach to Web Application Security

What do you do with it?

Wednesday, July 10, 13

Page 99: Repsheet: A Behavior Based Approach to Web Application Security

Options• Block the traffic

• Honeypot the attacker

• Modify your response

• Attack back

• Contact the authorities

Wednesday, July 10, 13

Page 100: Repsheet: A Behavior Based Approach to Web Application Security

Blocking the traffic is straight forward

Wednesday, July 10, 13

Page 101: Repsheet: A Behavior Based Approach to Web Application Security

Block at the web server level (403)

Wednesday, July 10, 13

Page 102: Repsheet: A Behavior Based Approach to Web Application Security

Block at the firewall level

Wednesday, July 10, 13

Page 103: Repsheet: A Behavior Based Approach to Web Application Security

Both have advantages/disadvantages

Wednesday, July 10, 13

Page 104: Repsheet: A Behavior Based Approach to Web Application Security

Honeypots are much more interesting

Wednesday, July 10, 13

Page 105: Repsheet: A Behavior Based Approach to Web Application Security

LB

LB LB

Engine

Fake Real

DB DBPartial Replication

Wednesday, July 10, 13

Page 106: Repsheet: A Behavior Based Approach to Web Application Security

When you honeypot, the attacker doesn’t know they’ve been

caught

Wednesday, July 10, 13

Page 107: Repsheet: A Behavior Based Approach to Web Application Security

And it allows you to study their behavior

Wednesday, July 10, 13

Page 108: Repsheet: A Behavior Based Approach to Web Application Security

And update your approach to preventing

attacks

Wednesday, July 10, 13

Page 109: Repsheet: A Behavior Based Approach to Web Application Security

But all of this requires a way to manage state

and act on bad behavior

Wednesday, July 10, 13

Page 110: Repsheet: A Behavior Based Approach to Web Application Security

Reputational Intelligence

External Reputation

Classifier

???

User Requests

Web Server

ModSecurity

Application Environment

GeoIP???

State

State

Where do you act?

Here?

Wednesday, July 10, 13

Page 111: Repsheet: A Behavior Based Approach to Web Application Security

Repsheet

Wednesday, July 10, 13

Page 112: Repsheet: A Behavior Based Approach to Web Application Security

Reputation Engine

Wednesday, July 10, 13

Page 113: Repsheet: A Behavior Based Approach to Web Application Security

Redis

Repsheet Backend

External Reputation

Feeds

User Requests

Web Server

ModSecurity

Application Environment

GeoIP

Repsheet

Wednesday, July 10, 13

Page 114: Repsheet: A Behavior Based Approach to Web Application Security

Redis

Repsheet Backend

External Reputation

Feeds

User Requests

Web Server

ModSecurity

Application Environment

GeoIP

Repsheet

Wednesday, July 10, 13

Page 115: Repsheet: A Behavior Based Approach to Web Application Security

Redis

Repsheet Backend

External Reputation

Feeds

User Requests

Web Server

ModSecurity

Application Environment

GeoIP

Repsheet

Recorder

Wednesday, July 10, 13

Page 116: Repsheet: A Behavior Based Approach to Web Application Security

Redis

Repsheet Backend

External Reputation

Feeds

User Requests

Web Server

ModSecurity

Application Environment

GeoIP

Repsheet

Managed State

Recorder

Wednesday, July 10, 13

Page 117: Repsheet: A Behavior Based Approach to Web Application Security

Redis

Repsheet Backend

External Reputation

Feeds

User Requests

Web Server

ModSecurity

Application Environment

GeoIP

Repsheet

Managed State

ActorRecorder

Wednesday, July 10, 13

Page 118: Repsheet: A Behavior Based Approach to Web Application Security

Redis

Repsheet Backend

External Reputation

Feeds

User Requests

Web Server

ModSecurity

Application Environment

GeoIP

Repsheet

Managed State

Classifier, Feed Integration,

Learning Models

ActorRecorder

Wednesday, July 10, 13

Page 119: Repsheet: A Behavior Based Approach to Web Application Security

Wednesday, July 10, 13

Page 120: Repsheet: A Behavior Based Approach to Web Application Security

Wednesday, July 10, 13

Page 121: Repsheet: A Behavior Based Approach to Web Application Security

Repsheet helps put everything together

Wednesday, July 10, 13

Page 122: Repsheet: A Behavior Based Approach to Web Application Security

Web server module records activity and

looks for offenders in the cache

Wednesday, July 10, 13

Page 123: Repsheet: A Behavior Based Approach to Web Application Security

It listens to ModSecurity and adds offending IPs to it’s list

Wednesday, July 10, 13

Page 124: Repsheet: A Behavior Based Approach to Web Application Security

It provides notification and/or blocking of

offenders

Wednesday, July 10, 13

Page 125: Repsheet: A Behavior Based Approach to Web Application Security

Blocking happens at the web server level

Wednesday, July 10, 13

Page 126: Repsheet: A Behavior Based Approach to Web Application Security

But you can send the Repsheet data to your firewall for TCP level

blocking

Wednesday, July 10, 13

Page 127: Repsheet: A Behavior Based Approach to Web Application Security

Notification sends headers to the

downstream application

Wednesday, July 10, 13

Page 128: Repsheet: A Behavior Based Approach to Web Application Security

Which allows each app to chose how it is going

to respond

Wednesday, July 10, 13

Page 129: Repsheet: A Behavior Based Approach to Web Application Security

For instance, show a captcha on signup if

Repsheet alerts

Wednesday, July 10, 13

Page 130: Repsheet: A Behavior Based Approach to Web Application Security

Back end looks at the recorded data for bad

behavior

Wednesday, July 10, 13

Page 131: Repsheet: A Behavior Based Approach to Web Application Security

And updates the cache when it finds offenders

Wednesday, July 10, 13

Page 132: Repsheet: A Behavior Based Approach to Web Application Security

You can supply your own learning models

for the data

Wednesday, July 10, 13

Page 133: Repsheet: A Behavior Based Approach to Web Application Security

github.com/repsheet/repsheet

Wednesday, July 10, 13

Page 134: Repsheet: A Behavior Based Approach to Web Application Security

Summary

Wednesday, July 10, 13

Page 135: Repsheet: A Behavior Based Approach to Web Application Security

There are lots of indicators of attack in

your traffic

Wednesday, July 10, 13

Page 136: Repsheet: A Behavior Based Approach to Web Application Security

Build up a system that can capture the data

and sort good from bad

Wednesday, July 10, 13

Page 137: Repsheet: A Behavior Based Approach to Web Application Security

Tools

• ModSecurity

• GeoIP

• Custom rules (velocity triggers, fingerprinting, device id, etc)

• Custom behavioral classification

• Repsheet

Wednesday, July 10, 13

Page 138: Repsheet: A Behavior Based Approach to Web Application Security

And Remember…

Wednesday, July 10, 13

Page 139: Repsheet: A Behavior Based Approach to Web Application Security

Wednesday, July 10, 13

Page 140: Repsheet: A Behavior Based Approach to Web Application Security

Questions?

Wednesday, July 10, 13