Top Banner
Leveling the Playing Field Aaron Bedra Chief Security Officer, Eligible @abedra keybase.io/abedra
127

Leveling the playing field

Jan 18, 2017

Download

Technology

Aaron Bedra
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Leveling the playing field

Leveling the Playing Field

Aaron Bedra Chief Security Officer, Eligible @abedra keybase.io/abedra

Page 2: Leveling the playing field

Right now, your web applications are being

attacked

Page 3: Leveling the playing field

And it will happen again, and again, and again

Page 4: Leveling the playing field

As you grow so will the target on you

Page 5: Leveling the playing field

Keeping up with security is difficult

Page 6: Leveling the playing field

Actually, it’s unfair

Page 7: Leveling the playing field

Things you have to get right Things the attacker has to get right

Page 8: Leveling the playing field

Time the attacker has to focus on you Time you have to focus on the attacker

Page 9: Leveling the playing field

It’s asymmetric warfare

Page 10: Leveling the playing field
Page 11: Leveling the playing field

There’s no way to manually keep up

Page 12: Leveling the playing field

ManualAutomated

Intelligent

Page 13: Leveling the playing field

Scaling your defenses means strategic

automation

Page 14: Leveling the playing field
Page 15: Leveling the playing field

STOP!

Page 16: Leveling the playing field

Let’s talk about the problem we are solving

for a minute

Page 17: Leveling the playing field

Problems

• We don’t know what people are doing

• We don’t know how often they are doing it

• We don’t know how effective we are

• We are don’t have enough resources to keep up

Page 18: Leveling the playing field

Goals• Reduce noise

• Generate better signal

• Reduce operational overhead

• Build better business cases

• Spend energy on the really important stuff

Page 19: Leveling the playing field

Reducing Noise

Page 20: Leveling the playing field

It starts with really simple stuff

Page 21: Leveling the playing field

Tie up the loose ends with static configuration

Page 22: Leveling the playing field

Static configuration checklistAt least a B+ rating on SSL Labs*

Reject extensions that you don’t want to accept

Reject known bad user agents

Reject specific known bad actors

Custom error pages that fit your application

Basic secure headers

Page 23: Leveling the playing field

You’ll be surprised how well this works

Page 24: Leveling the playing field

It has a fringe benefit of creating better

awareness

Page 25: Leveling the playing field

You can feed this back to your intelligence

Page 26: Leveling the playing field

Reducing Operational Overhead

Page 27: Leveling the playing field

Dealing with malicious actors has to be easy

Page 28: Leveling the playing field

It shouldn’t require deploys, reloads, or any potential forward impact

Page 29: Leveling the playing field

Let’s talk about how to create something that will

help

Page 30: Leveling the playing field

Step 1Put everything in one place!

Page 31: Leveling the playing field

Centralization of events is critical

Page 32: Leveling the playing field

If you can’t see it, it didn’t happen

Page 33: Leveling the playing field

There are options

Page 34: Leveling the playing field

Log aggregation and a query engine

Page 35: Leveling the playing field

The query engine can serve as your discovery

agent

Page 36: Leveling the playing field

A nice first step

Page 37: Leveling the playing field

But it will eventually fall over

Page 38: Leveling the playing field

That’s when you reach for a messaging system

Page 39: Leveling the playing field

Log to topics in a queue

Page 40: Leveling the playing field

Create processors to understand events

Page 41: Leveling the playing field

Step 2Process Events

Page 42: Leveling the playing field

For every event type you will need to understand

how to process it

Page 43: Leveling the playing field

Structured logging can help, but it doesn’t fit

everywhere

Page 44: Leveling the playing field

The goal is to accept an event and return

consumable details

Page 45: Leveling the playing field

type logEntry struct { Address string Method string Uri string ResponseCode string }

func processEntry(entry string) logEntry { parts := strings.Split(entry, " ") event := logEntry{ Address: parts[0], Method: strings.Replace(parts[5], "\"", "", 1), Uri: parts[6], ResponseCode: parts[8], } return event; }

Page 46: Leveling the playing field

You will likely have multiple processors

Page 47: Leveling the playing field

Split topics by event type or application

Page 48: Leveling the playing field

Once you have the data accessible, figure out

what happened

Page 49: Leveling the playing field

Track everything!

• HTTP Method

• Time since last request/average requests per sec

• Failed responses

• Failure of intended action (e.g. login, add credit card, edit, etc)

• Anything noteworthy

Page 50: Leveling the playing field

type Actor struct { Methods map[string]int FailedLogins int FailedResponses map[string]int }

func updateEvents(event logEntry, counts *map[string]Actor) { counts[event.Address].Methods[event.Method] += 1 if event.ResponseCode != "200" || event.ResponseCode != "302" { counts[event.Address].FailedResponses[ResponseCode] += 1 } if event.Method == "POST" && event.ResponseCode == "200" { counts[event.Address].FailedLogins += 1 } }

Page 51: Leveling the playing field

Once you have things in one place, it’s all about counting

Page 52: Leveling the playing field

Simple counts with thresholds go a long way

Page 53: Leveling the playing field

Step 3Thresholds, Patterns, and Deviations

Page 54: Leveling the playing field

Exceeding a count is a signal that something

needs to be done

Page 55: Leveling the playing field

There are a lot of signals that could be malicious

Page 56: Leveling the playing field

You can start with simple thresholds

• Too many failed logins

• Too many bad response codes (4xx, 5xx)

• Request volume too high

Page 57: Leveling the playing field

These provide a lot of signal

Page 58: Leveling the playing field

But they don’t get you all the way there

Page 59: Leveling the playing field

There are patterns of behavior that signal

malicious intent

Page 60: Leveling the playing field

Example

Page 61: Leveling the playing field

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"

Page 62: Leveling the playing field

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"

Page 63: Leveling the playing field

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"

Page 64: Leveling the playing field

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"

Page 65: Leveling the playing field

That was a carding attack

Page 66: Leveling the playing field

As you dig in, you will find many patterns like

these

Page 67: Leveling the playing field

But again it doesn’t cover everything

Page 68: Leveling the playing field

There will also be interesting deviations

Page 69: Leveling the playing field

5%5%4%

27% 59%

GET POST HEAD PUT DELETE

Page 70: Leveling the playing field

Deviations in normal flow are interesting but not necessarily malicious

Page 71: Leveling the playing field

You will have to build more intelligent processing to

understand them

Page 72: Leveling the playing field

Example

Page 73: Leveling the playing field

A password reset request comes from a new

location

Page 74: Leveling the playing field

Is it a harmless request or an account takeover?

Page 75: Leveling the playing field

Your processors will have to make complicated choices based on lots of information

Page 76: Leveling the playing field

Nailing deviation requires the largest amount of

effort

Page 77: Leveling the playing field

Step 4Act

Page 78: Leveling the playing field

Once you have enough information to make a decision, you must act

Page 79: Leveling the playing field

There are multiple ways to act

• Blacklist

• Whitelist

• Mark

• Do nothing

Page 80: Leveling the playing field

Blacklist and whitelist are pretty straight forward

Page 81: Leveling the playing field

Blacklist when thresholds are exceeded or

patterns/deviation fit

Page 82: Leveling the playing field

Whiltelist things you never want to be

blacklisted

Page 83: Leveling the playing field

Marking is more interesting

Page 84: Leveling the playing field

Marking allows you to tag actors as potentially

malicious

Page 85: Leveling the playing field

This allows you to dynamically modify your

responses

Page 86: Leveling the playing field

And choose how you react

Page 87: Leveling the playing field

“Of course machines can't think as people do. A machine is different from a person. Hence, they think differently.”

-- Alan Turing, The Imitation Game

Page 88: Leveling the playing field

You can often render bots useless with small

changes

Page 89: Leveling the playing field

Which exposes them as bots

Page 90: Leveling the playing field

And gives you the confidence you need to

blacklist them

Page 91: Leveling the playing field

Marking also helps you lower the rate of false

positives

Page 92: Leveling the playing field

Step 5Visualize

Page 93: Leveling the playing field
Page 94: Leveling the playing field

Visualization is incredibly helpful

Page 95: Leveling the playing field

You need a window into your automation

Page 96: Leveling the playing field

Spending a few minutes a day looking at what

happened is vital

Page 97: Leveling the playing field

You can pretty easily catch bugs this way

Page 98: Leveling the playing field

Architecture & Peformance

Page 99: Leveling the playing field
Page 100: Leveling the playing field

There are three main ideas

• The thing that acts on actors

• The shared cache

• The event processors

Page 101: Leveling the playing field

Acting on actors should be fast

Page 102: Leveling the playing field

Fast in a web request is single digit milliseconds

Page 103: Leveling the playing field

You can choose to embed this in your applications

or your web servers

Page 104: Leveling the playing field

Data locality is important

Page 105: Leveling the playing field

It usually involves replicating the global cache

to each decision point

Page 106: Leveling the playing field
Page 107: Leveling the playing field

The cache should hold everything needed to act

on actors

Page 108: Leveling the playing field

The web server asks the cache what to do

Page 109: Leveling the playing field

The event processors work out of band

Page 110: Leveling the playing field

Their sole purpose is to populate the cache

Page 111: Leveling the playing field

Processors tend to be more custom

Page 112: Leveling the playing field

But the cache and the acting logic is common

Page 113: Leveling the playing field

github.com/repsheet

Page 114: Leveling the playing field

Pitfalls

Page 115: Leveling the playing field

Things to consider• False positives

• Decision latency

• Incorrect modeling

• Bad data

• Monitoring

Page 116: Leveling the playing field

There’s a good chance you will block incorrectly

Page 117: Leveling the playing field

Make use of whitelisting

Page 118: Leveling the playing field

Mobile carriers will be a problem

Page 119: Leveling the playing field

So will NATed IP addresses

Page 120: Leveling the playing field

Time to decision should be monitored

Page 121: Leveling the playing field

Create a solid regression suite

Page 122: Leveling the playing field

Run all your models through it when you make

even a single change

Page 123: Leveling the playing field

Understand where bad data can impact you

Page 124: Leveling the playing field

Build tolerance of bad data so you don’t make

incorrect decisions

Page 125: Leveling the playing field

Monitor everything!

Page 126: Leveling the playing field

This type of automation deserves every monitor and metric you can get

Page 127: Leveling the playing field

Questions?