Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA...

34
Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Transcript of Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA...

Page 1: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Testing and Fuzzing FLEX: More fun with RIA

Christophe De La Fuente

Page 2: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

Outline

1. What is Flex? 2. Connecting to back-end 3. Remote Object & AMF 4. What about Security? 5. Testing Flex

Page 3: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

What is Flex?

Page 4: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

Flex?

Page 5: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

… or maybe?

Page 6: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

Flex framework

Free & open source

Rich Internet Application

Browser (Adobe Flash Player)

Standalone (Adobe AIR®)

MXML (XML-based language)

ActionScript® (OO language)

Page 7: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

MXML

<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*"

layout="horizontal" creationComplete="srv.getProducts()">

<mx:RemoteObject id="srv” destination="product"/>

<mx:Panel title="Catalog” width="100%" height="100%">

<mx:DataGrid id="list” dataProvider="{srv.getProducts.lastResult}” width="100%" height="100%"/>

</mx:Panel>

<ProductForm product="{Product(list.selectedItem)}"/>

</mx:Application>

Page 8: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

ActionScript

package events{ import flash.events.Event;

public class ShowPreview extends Event { public var employeeInfo:Object; public var message:String;

public function ShowPreview(type:String, employeeInfo:Object, message:String)

{ super(type); this.employeeInfo = employeeInfo; this.message = message; }

override public function clone() : Event { return new ShowPreview(type, employeeInfo, message); } }}

Page 9: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

Compilation

Flash Builder (Eclipse plug-in)

Command line •  mxmlc (MXML) SWF •  compc (ActionScript component compiler) SWC

ABC (ActionScript Bytecode)

Executed in a Virtual Machine (AVM2)

Easy decompilation

Page 10: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

Flex 4

UI improvements •  new skinning & component

architecture (Spark) •  2D & 3D improvements •  support for FXG (vector-

based graphics) •  effects and transitions

Requires Flash Player 10 support

Page 11: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Connecting to back-end

Page 12: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

Communication

URL Loader

ActionScript Binary Socket

XML Socket

Remote Object •  invoke server objects •  serialization

HTTP Service •  any HTTP method

Web Service

Page 13: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

Servers

BlazeDS •  remoting and web messaging •  connect to back-end

LiveCycle Data Services ES2 •  infrastructure for enterprise Flex and AIR applications

Page 14: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

BlazeDS

Remoting •  RPC calls •  call ColdFusion or Java classes •  mapping of Value Object types

Messaging •  publish/subscribe •  asynchronous communication •  producers and consumers •  clients servers

Page 15: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

Destination •  server-side class •  message topic •  proxy

Channel •  communication protocol (amf, amf-secure, http,…) •  multiple channels per service

Service Adapters •  integrate with the back-end •  many provided •  customizable

BlazeDS - Components

Page 16: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

Summarizing…

h"p://flex.org/what-­‐is-­‐flex  

Page 17: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Remote Object & AMF

Page 18: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

AMF

AMF0/3

Open source

Compact binary format

Object serialization

One byte marker

Object by value or by Reference

Implementations (ruby, python, java,...)

Page 19: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

Remoting with BlazeDS

DEMO

Page 20: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

What about Security?

Page 21: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

What about security?

Large attack surface •  Channels •  Adapters •  Back-end components

All public method accessible by default

Page 22: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

Same-Domain Policy

Enforced by Flash Player from version 7

Access resources from the domain it was loaded from

Granting access •  Security.allowDomain() method •  URL/socket policy file (crossdomain.xml)

 <?xml  version="1.0"?>  <!DOCTYPE  cross-­‐domain-­‐policy  SYSTEM  "hEp://www.macromedia.com/xml/dtds/cross-­‐domain-­‐policy.dtd">            <cross-­‐domain-­‐policy>                        <allow-­‐access-­‐from  domain="*.trustwave.com"  to-­‐ports="507,516"/>            </cross-­‐domain-­‐policy>    

Page 23: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

Sanboxing

Assets put in the same security sandbox

Different rules for: •  loading content (images, HTML, SWF,…) •  accessing data (accessible only to code)

Remote Sandbox •  cannot load any local files or resources

Local Sandbox •  local-with-filesystem •  local-with-networking •  local-trusted •  AIR application sandbox

Page 24: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

Permission Controls

Administrator  (User  InsUtuUon)  

seWngs  

User  seWngs  

Website  seWngs  

Author  seWngs  

The  mms.cfg  file  The  Global  Flash  Player  Trust  directory  

SeWngs  UI  /  Manager  User  Flash  Player  Trust  directory  

Policy  file  (crossdomain.xml)  

Security.allowDomain("www.example.com")  

Page 25: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

Other Security Features

Disk space constrained (100k)

Outbound port filter •  commonly reserved ports is blocked (21, 22,…)

BlazeDS Security •  authentication (custom/built-in) •  authorization (role-based) on destinations and methods

Page 26: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Testing Flex

Page 27: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

Cross Domains Attacks

SWF(A)  Domain  A  

Domain  B  

crossdomain.xml  allow  access  from  Domain  A  

SWF(AEacker)  makes  illegal  call  to  Domain  B’s  resources  through  SWF(B)  

SWF(A)  makes  call  to  Domain  B’s  resources  

AEacker  

Page 28: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

Cross-scripting

“Code defined in one file can examine and modify variables, objects, properties, methods, and so on in the other, and vice versa”

Domain restriction •  permission granted with Security.allowDomain()

Version restriction •  Not supported between AVM1 SWF files & AVM2 SWF files

HTML-to-SWF •  Scripting can occur with callbacks established through the

ExternalInterface.addCallback() method

Page 29: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

Cross-scripting

DEMO

Page 30: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

Tools

Decompilers •  swfdump (SWFTools) •  Sothink

Debuggers •  fdb •  Flash Player debug build

Web Proxy •  BurpSuite •  Charles Proxy

Eclipse (Flash Builder plug-in)

Page 31: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

Fuzzer / Bruteforce

Standard vulnerabilities •  SQL injection •  XSS (when using ExternalInterface.addCallback() ) •  Password brute forcing •  etc…

Tool to call remote objects via AMF •  Deblaze (Jon Rose) •  Integration with Burp Suite and interactivity needed…

…  I  wrote  mine  

Page 32: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

Flexible Fuzzer

Ruby

RocketAMF (AMF serializer/deserializer)

Burp Suite integration thanks to Buby (Eric Monti)

Will be added to the OWASP Web Testing Environment (WTE)

Page 33: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Copyright Trustwave 2010 Confidential

Flexible Fuzzer

DEMO

Page 34: Testing and Fuzzing FLEX: More fun with RIA€¦ · Testing and Fuzzing FLEX: More fun with RIA Christophe De La Fuente

Thanks! Questions?