57
Joonas Lehtinen IT Mill - CEO RIA Security - Broken By Design Tuesday, January 26, 2010

RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Joonas LehtinenIT Mill - CEO

RIA Security - Broken By Design

Tuesday, January 26, 2010

Page 2: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

a system is secure if it is

designed to be secure and there

are no bugs

Tuesday, January 26, 2010

Page 3: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

no system should be designed to be insecure

Tuesday, January 26, 2010

Page 4: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

not all bugs are security holes

Tuesday, January 26, 2010

Page 5: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

not all security holes are found and exploited

Tuesday, January 26, 2010

Page 6: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

security broken by design?

Tuesday, January 26, 2010

Page 7: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

advertises security holes andmakes avoiding them harder

Tuesday, January 26, 2010

Page 8: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

RIAGWTVaadin

Security • Architecture • Complexity • Attack surface

Breaking in • PayMate • Attacks

1. 2. 3.

Tuesday, January 26, 2010

Page 9: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Rich Internet

Application

Tuesday, January 26, 2010

Page 10: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

User InterfaceComplexity

webpages

businesssoftware

3Dgames

webplatform

Tuesday, January 26, 2010

Page 11: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

WebSites

PHP

JSP

JSF

Wicket

Tapestry

Seam

AjaxSugar

JQuery

MooTools

Scriptaculous

Dojo

FullRIA

Client SideServer Driven

ExtJSGWT

ICEFaces

Flex

JavaFX

Plugin JavaScript

SilverlightSmartClient

ZK

Tuesday, January 26, 2010

Page 12: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Client Side

Server Driven

UI logic runs in browser(as JavaScript or in plugin)

UI logic runs in server(framework updates UI in browser)

Tuesday, January 26, 2010

Page 13: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

GoogleWeb

Toolkit

Tuesday, January 26, 2010

Page 14: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Apache -licensed

User InterfaceFrameworkfor building RIA in Java

Tuesday, January 26, 2010

Page 15: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Java toJavaScriptCompiler

Subset of

java.lang, java.util

Widgetset

Your Application UI

IE6

IE7

Firefox

Safari

Web Browser

Web Server

Your Application

Logic

DB

HostedMode

Browser

Tuesday, January 26, 2010

Page 16: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Vaadin

Tuesday, January 26, 2010

Page 17: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Apache -licensed

User InterfaceFramework

for building RIA in 100% Java

Tuesday, January 26, 2010

Page 18: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Java Server or Portal

Servlet

Web Browser

Google Web Toolkit

VaadinWidgets(Rendering)

YourCustomWidgets(optional)

YourCustomTheme(optional)

VaadinWidgets(vaadin.jar)

Your User Interface

Your Business Logic

Servlet /Portlet / JSF / JSP / ...(optional)

architecture

Tuesday, January 26, 2010

Page 19: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Security

Tuesday, January 26, 2010

Page 20: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

“Web 1.0”

DOM

Client Server

ViewHTML Page

over HttpResponse

Controller

Model

Parameters overHttpRequest

DB2

3

4

5

1

Parameterparsing andvalidation

Authentication

SQL injection

Visible datafiltering by

access

Tuesday, January 26, 2010

Page 21: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Client Side RIA

DOM

Client Server

View

Controller

Model

DB2

3

4

5

1

Requested datato view as

XML / JSON

Changes to modelencoded as parameters

Parameterparsing andre-validation

Authentication

SQL injection

Visible datafiltering by

access

Client (and thus view and

controller) can not be trusted

All view and controller code is sent to all

clients

Tuesday, January 26, 2010

Page 22: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Rule #1Never trust the

browser

Tuesday, January 26, 2010

Page 23: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Server Driven RIA

DOM

Client Server

ViewHTML Pageover HttpResponse

Controller

Model

Parameters overHttpRequest

DB4

5

6

2

Term

inalAdapter

Term

inalAdapter

Automated bythe RIA framework

3

7

1

9

8

Tuesday, January 26, 2010

Page 24: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Server Driven RIA

DOM

Client Server

ViewHTML Pageover HttpResponse

Controller

Model

Parameters overHttpRequest

DB4

5

6

2

Term

inalAdapter

Term

inalAdapter

Automated bythe RIA framework

3

7

1

9

8 SQL injection

Visible datafiltering by

access

Handled by the framework

Tuesday, January 26, 2010

Page 25: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Rule #2Complexity is a hiding-place for security-flaws

Tuesday, January 26, 2010

Page 26: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

complexityAspect Server Driven Client Side

No access to server resources - XWeb-service API design - XCommunication design - XClient-side validation - XServer-side validation X XUntrusted runtime - XExposed runtime - XHighly dynamic language - X

Tuesday, January 26, 2010

Page 27: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Rule #3Large surface: easy to attack, hard to defend

Tuesday, January 26, 2010

Page 28: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Attack Surface: Web 1.0

• Web page HTML (presentation)

• Form parameters

• Parameter parsing

• Parameter validation

• Cross-site scripting (XSS)

Tuesday, January 26, 2010

Page 29: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Attack Surface: Client-side RIA

• Web page DOM (presentation)

• Form parameters (for hybrid solutions)

• Parameter parsing

• Parameter validation

• Cross-site scripting (XSS)

• UI logic can be

• Evaluated: Black-box changes to white-box!

• Changed

• Web services - a lot of API is exposed and can be called directly

sam

e as

web

1.0

Tuesday, January 26, 2010

Page 30: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Attack Surface: Server Driven RIA

• Web page DOM (presentation)

• Form parameters (for hybrid solutions)

• Parameter parsing

• Parameter validation

• Cross-site scripting (XSS)

• UI logic can be

• Evaluated: Black-box changes to white-box!

• Changed

• Web services - a lot of API is exposed and can be called directly

Tuesday, January 26, 2010

Page 31: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Breaking In

Tuesday, January 26, 2010

Page 32: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

[ no relation to paymate.com.au or paypal.com ]

Local demo http://localhost:8280/paymate/

Online demo http://vaadin.com/web/joonas/wiki/-/wiki/Main/RIA%20Security

Tuesday, January 26, 2010

Page 33: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Web Service API Impl

Web Service API

User Inteface

Web Service API Async

User Inteface

Server-side RIA version[ IT Mill Toolkit ]

Client-side RIA version[ Google Web Toolkit ]

[ C

ust

om

code ]

Runnin

g o

n C

lient

[ C

ust

om

code ]

Runnin

g o

n S

erv

er

DB

Business Logic

GWT versionClient Side RIA

Vaadin versionServer Driven RIA

Tuesday, January 26, 2010

Page 34: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Case #1Injection

Tuesday, January 26, 2010

Page 35: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Tuesday, January 26, 2010

Page 36: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Tuesday, January 26, 2010

Page 37: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

SELECT NAME,ID FROM ACCOUNT WHERE NAME='

' OR TRUE OR ''='' AND PASSWORD=''

Tuesday, January 26, 2010

Page 38: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

SQL injectionattack

Tuesday, January 26, 2010

Page 39: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Injection

• Cures:

• Isolation: Keep data and execution separate

• Validation: Reject suspicious data

• Escaping: Modify the data to keep it from affecting the execution

vulnerable

Server Driven RIAClient Side RIA

vulnerable

Tuesday, January 26, 2010

Page 40: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Case #2Double validation

Tuesday, January 26, 2010

Page 41: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Missing double validation

• It is often convenient to do data some validation in the user interface logic

• Attacker can always bypass any validation done in the browser

• Thus everything must be validated (again) in the server!

• Lack of double validation is almost impossible to notice in testing or normal use

Tuesday, January 26, 2010

Page 42: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

rewriting client-side logic

attack

Tuesday, January 26, 2010

Page 43: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

forging http transport

attack

Tuesday, January 26, 2010

Page 44: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

4ï¿¿0ï¿¿7ï¿¿http://localhost:8080/paymate/client-side/com.paymate.gwt.PayMateApplication/ï¿¿29F4EA1240F157649C12466F01F46F60ï¿¿com.paymate.gwt.client.PayMateServiceï¿¿sendMoneyï¿¿Dï¿¿java.lang.Stringï¿¿[email protected]ï¿¿1ï¿¿2ï¿¿3ï¿¿4ï¿¿2ï¿¿5ï¿¿6ï¿¿999999ï¿¿7ï¿¿

POST Data

-99999

Tuesday, January 26, 2010

Page 45: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

var xhr = document.body.childNodes[5].contentWindow.XMLHttpRequest;Override the original XMLHttpRequest implementation

xhr.prototype.originalSend = xhr.prototype.send;xhr.prototype.send = function(a) {

! Create UI for our hack tool

var panel = document.createElement("DIV");! panel.innerHTML = "<textarea id='postdata' cols=80 rows=20> "+ "</textarea><br/><button id='postbutton'>Post</button>";! document.body.appendChild(panel);! document.getElementById('postdata').value=a;

Do the sending when the button is pressed

! var t = this; document.getElementById('postbutton'). addEventListener("click",function() {! ! t.originalSend(document.getElementById('postdata').value);! ! document.body.removeChild(panel);! }, true);};

Tuesday, January 26, 2010

Page 46: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Double validation

• Cures:

• Never skip server-side validation

• Code review is a must - testing does not help

• Never think server-validation could be seen as “extra work” that will be added later in the project

vulnerable

Server Driven RIAClient Side RIA

not vulnerable

Tuesday, January 26, 2010

Page 47: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Case #3Forging references

Tuesday, January 26, 2010

Page 48: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Object AObject List Object B

Business Logic Process

Web Service API

ref ref

Client

1. Client asks for service

2. Service request is delegated to business logic

3. List of accessible object is requested

Data

Model

Tuesday, January 26, 2010

Page 49: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Object AObject List Object B

Web Service API

Client

1. Client asks for list of objects,references are returned

4. Info about wrong object isretrieved. Data model trusts the

reference!2. List of accessible object is requested

Data

Model

3. More info about object is requested, with forged reference

ref

Web Service API

ref

ref

Tuesday, January 26, 2010

Page 50: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

requesting data with forged ids

attack

Tuesday, January 26, 2010

Page 51: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Forging references

• Cures:

• Never pass any data-model level references to the client

• Do all the access checks for each call from client

vulnerable

Server Driven RIAClient Side RIA

not vulnerable

Tuesday, January 26, 2010

Page 52: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

These bugs are just plain stupid![our team is smart enough to avoid them]

Tuesday, January 26, 2010

Page 53: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

really?I can assure that Yes No

I would newer do mistakes like these

Not even under pressure, late at night, on deadline

And neither would the rest of the team, no-one

Or the guys working for our off-shore contractor

And we rigorously double review all of our code

And trust we would spot 100% of these

And we review all legacy code too

We will newer have any “black boxes” in our system

Tuesday, January 26, 2010

Page 54: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Rule #4There will be

bugs

Tuesday, January 26, 2010

Page 55: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

summary

Tuesday, January 26, 2010

Page 56: RIA Security - Broken By Design - Jfokus · RIA Security - Broken By Design Tuesday, January 26, 2010. a system is secure if it is designed to be secure and there are no bugs Tuesday,

Rule #1Never trust the browserRule #2More complexity - less securityRule #3Large surface is hard to defendRule #4There will be bugs

Tuesday, January 26, 2010