Top Banner
Into the RabbitholeEvolved Web Application Security Testing Rafal M. Los - Security Evangelist, HP Application Security [email protected] - @Wh1t3Rabbit
42

Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Oct 05, 2020

Download

Documents

dariahiddleston
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: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Into the Rabbithole—Evolved Web Application

Security TestingRafal M. Los - Security Evangelist, HP Application Security

[email protected] - @Wh1t3Rabbit

Page 2: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

When I first came here, this was all swamp. Everyone said I was daft to build a castle on a swamp, but I built in all the same, just to show them.It sank into the swamp.So I built a second one. That sank into the swamp. So I built a third. That burned down, fell over, then sank into the swamp.But the fourth one stayed up. And that's what you're going to get, Lad, the strongest castle in all of England.

Monty Python & the Holy Grail (King of Swamp Castle)

Page 3: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Let’s descend down the

rabbit-hole

4

OR

Better testing through evolved

automation

Page 4: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Automation: Love & Hate

5

Web App Sec has a

LOVE|HATE

relationship with automation

HATE Attack surface coverage unclear*

Confuse automation’s purpose

LOVE Automation speeds defect identification

Scanning is fast, quickly producing results

*More on the coverage problem shortly…

Page 5: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

6 HP Confidential

Page 6: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Understanding Automation

7

Battle lines (the classic arguments)

– Humans offer intelligence

– Automation offers limited scope

Benefits of automation

– Scalability: Analysis speed, coverage, processing

– Complexity: Applications are increasingly process-driven

Page 7: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

So What?

8

We’ve reached a tipping point

Page 8: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Why Did My Scanner Miss X?

9

Two real reasons

• X required a specific sequence, or FLOW

• X required DATA to get there

Data + Flow no excuses

• IF tools have data + logic… the result is

―smarter‖ automation

• No more ―crawl n’ hope‖?

Page 9: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

STOP point n’ scan web application security testing

ENLIGHTENED METHODOLOGY

• Application functional mapping w/data

• Layered automation-infused testing

• Concrete metrics & KPIs

―Radical‖ Testing Methodology

10

Page 10: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

11

Do what you do…

only smarter

Page 11: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

©2010 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice

Application Functional Mapping with Data

12

Page 12: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

©2010 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice

Defect vs. VulnerabilityHow many of you have ever performed functional testing ?

13

Page 13: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Functional vs. Security Testing

14

QA TEAM INFOSECURITY TEAM

Functions known Functions unknown

Application understood Application unknown

Rely on functional specifications

Rely on crawlers + experience + luck

Coverage known Coverage unknown

Highlight key business logic

Highlight ―found‖ functionality

Page 14: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Hard Lessons Learned

Security analysts, tools [today]

aren’t equipped to properly

test highly complex

applications…

15

MISSING PIECES

• Understanding of application

• Functional mapping of application

• Application execution flow

• Valid test data

Page 15: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Bridging the Gaps

16

Is the kitchen-sink attack working?

Hint: It used to…not anymore

YOU ARE HERE THEY ARE THEREIDEAL

Page 16: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

As All This Is Happening—

Technology Drives Forward…

17

Page 17: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Application State Is Changing

HTTP State• Session/Cookie State

• Server State

Client State• JavaScript State

• Silverlight/Flash State

Impossible to decouple HTTP from Client State

You can’t just crawl/guess your way through a modern,

complex application

18

Page 18: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Proposed Approach

Combine functional + security testing, compensating

for technology

• Address technology complexities• Session states

• Code-complexity

• Address functional complexities• Mapping application function as execution flows

• Mapping data for driving execution flows

19

Page 19: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Incoming New Automation Technology!

20

Page 20: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Standards & Specifications

EFD

Execution Flow Diagram – Functional paths through the

application logic

ADM

Application Data Mapping – Mapping data requirements

against functional paths

21

Page 21: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Improving the Testing Process

Functional SpecificationApplication functional

mapping [EFD]

Application data mapping [ADM]

Function-based automated testing

Manual result & coverage validation

+=

Page 22: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Basics of the EFD & ADM

23

Page 23: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Basic EFD Concepts

Graph(s) of flows through the application

- Nodes represent application states

- Edges represent different actions

- Paths between nodes represent state changes

- A set of paths is a flow

24

Page 24: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Execution Flow Action Types

What is an action?• Something that causes a change in state

• A human, server or browser-driven event

Three types of actions• Direct

• Supplemental

• Indirect

25

Page 25: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Actions which change the browser’s document context

• Causes an entirely new browser page

Examples-

• Following hyperlink

• Click login button

Direct Flow Actions

26

HTTP States(Pages)

Direct Flow Action

P1 P2GET /?step2

Page 26: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Actions that change the state of the current document

• Client-side action, maintaining browser page

Examples:

– JavaScript menu

– Flash client event

Supplemental Flow Actions

27

P1 P1.1.1

Supplementary Flows

DOM States

onLoad onMouseOver

P1.1

Page 27: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Actions automatically triggered by document context

• Usually for supporting data, modifying document state

Examples:

– Site analytics (js)

– Stock ticker

– XMLHTTPrequest

Indirect Flow Actions

28

Indirect Flow

PagesDirect Flow

Dojo Library

<script src=dojo.js />

Page 28: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Basic ADM Concepts

An Application Data Map [ADM] defines flows with the

context of data

WHY?

• Flows mean nothing without DATA*

• Data should be interchangeable• Monitoring requests make this impossible – no context

• Data can be direct or indirect

*Where not specifically defined within an action (at the

edge) the data values are assumed to be arbitrary29

Page 29: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

ADM + EFD Visually

Retrieve something from a safe:

1. Map the action

2. Add data (context) necessary to execute

3. Execute action using data

30

Combination:R23, L12, R31, L9

I need something

from that safe

ACTION (open safe)

Page 30: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

ADM & EFD

Another example: Web site registration

31

START

forkLanding Page

Login

RegistrationPage

UserData

Confirm Account

Page 31: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Drives

Putting It All Together (1)

32

Technical Level

Functional Level

LoginCompose

EmailSend

Page 32: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Drive

s

Putting It All Together (2)

33

EFD

1 2 3

4

5

7

6

JS DOM HTTP

a GET /

b GET /?Login

c GET /?Compose

d onKeyPressed

(160 times)

e DIV.onMouseOver

f LI.onChange

g FORM.submit() GET /?Send

a b

c

d

e

f

8g

Page 33: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Putting It All Together (3)

34

JS DOM HTTP Data

a GET / N/A

b GET /?Login User,Pass,Captcha

c GET /?Compose N/A

d onKeyPressed

(160 times)

Email_Text

e DIV.onMouseOver N/A

f LI.onChange Send_To_Address

g BTN.onClick GET /?Send N/A

Drive

s

Page 34: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Applications of Execution Flow Diagrams

35

Page 35: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Flow Based Threat Analysis

36

Checkout with Credit Card

Viewing Items

• Markup flow with Threat Information• Prioritize testing• Prioritize verified vulnerabilities

• Detect dangerous information flows

Partners Only

Page 36: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Coverage Analysis

Flows defined by functional specification can be compared to

security testing to determine gaps!

Q: ―How much of the application was tested?‖

A: ―The scanner was able to test 8 of the 12 flows, we need

to find out why/where it broke down‖ EFD can be referenced to determined where

ADM can be referenced to determine why

37

Page 37: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Demonstrate exactly how to reproduce a defect…

Demonstrate where application failed

• Steps executed

• Data used

38

START

forkLanding Page

DATA<script>…

RegistrationPage

1

2 3

4

Flow-Based Reproduction

Page 38: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Dysfunctional Use of EFD

Vulnerabilities happen

when using the

application in an

unintended way.

If we know the right

logic paths…

39

1 2 3

4

5

7

6

a b

c

d

e

f

8g

Page 39: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Next Generation Automation

Automation of execution flows

• Build maps from user-driven functional scripts

• Recording/Playback

• Record HTTP requests

• Record JavaScript events

• Recording Client UI events

• Attacking

• [Re]Play Flows

• Auditing HTTP Parameters and HTML Inputs

40

Page 40: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Next: Automatic Exploration

• Similar paths can be easily enumerated

• JS Static Analysis to find other entry points to paths

41

Select Flight 2

Select Flight 1

Automatically Found

Page 41: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

For Next Time…

Layered automation-infused testing

Testing must be layered to fully

understand the attack surface of

the application, including

multiple levels of authentication,

business logic, data sets.

Concrete metrics & KPIs

In order to concretely prove

functional coverage, application

surface area coverage, defect

remediation and ultimately risk

reduction business-oriented

metrics and KPIs must be

gathered.

42

Page 42: Into the Rabbithole - Security BSidesthe+Rabbithole+v2.01.pdf · Putting It All Together (3) 34 JS DOM HTTP Data a GET / N/A b GET /?Login User,Pass,Captcha c GET /?Compose N/A d

Get to it.

43

Insert cheesy cliché here…

…or you could just go do it.

Rafal LosEmail: [email protected]: @Wh1t3RabbitVoice: (765) 247-2325Blog: http://www.hp.com/go/white-rabbit