microsoft powerpoint - soa-202.ppt [compatibility mode]

57
Web 2.0 Security Chess: Combat Strategies and Defense Tactics Shreeraj Shah Shreeraj Shah Blueinfy Solutions Pvt. Ltd. 04/09/08 | Session Code: SOA-002

Upload: sampetruda

Post on 19-Jan-2015

802 views

Category:

Documents


3 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

Web 2.0 Security Chess: Combat Strategies and Defense Tacticsg

Shreeraj ShahShreeraj ShahBlueinfy Solutions Pvt. Ltd.04/09/08 | Session Code: SOA-002

Page 2: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

W b 2 0 S it Ch E O i CWeb 2.0 Security Chess – Eye Opening Case

• Web 2 0 Portal – Buy / SellWeb 2.0 Portal Buy / Sell • Technologies & Components – Dojo, Ajax, XML

Services, Blog, Widgetsg g• Scan with tools/products failedfailed• Security issues and hacks

– SQL injection over XML– Ajax driven XSS– Several XSS with Blog componentSeveral XSS with Blog component– Several information leaks through JSON fuzzing– CSRF on both XML and JS-Array

HACKED»HACKED»DEFENSE

Page 3: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

A dAgenda

• Web 2.0 – Know the • Vulnerabilities and ScanWeb 2.0 Know the battle field– Where are we moving?

Architecture

Vulnerabilities and Scan– Scan for XSS– One/Two Way CSRF

– Architecture– Strategic Changes– Enemies

– RSS, Widget, Mashup, Blog hacks

– Web Services Attacks • Moves from Black

– MethodologiesFi i ti

and Combats• Moves from White

Code scanning defense– Fingerprinting– Discovery– Enumeration and

– Code scanning defense– Firewall Web 2.0 attacks

and streams

3Crawling

Page 4: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

AgendaWeb 2.0 Battle Field (Resource)

Footprinting & DiscoveryConfig Scanning

( )

Enumeration & Crawling

Attacks and Scanning

Config Scanning

Code Scanning

Attacks and Scanning

Secure Coding

Black Moves White Moves

Web 2.0 Firewall

Secure Coding

DefenseS i

Secure Web 2.0Strategies

Page 5: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

Web 2.0 – Know the battle fieldWhere are we moving?– Where are we moving?

– Architecture– Strategic Changes– Enemies

Page 6: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

Wh i ?Where are we moving?

Page 7: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

Wh i ?Where are we moving?• 80% of companies are

investing in Web Services asinvesting in Web Services as part of their Web 2.0 initiative (McKinsey 2007 Global Survey)

• By the end of 2007, 30 percent of large companies have some kind of Web 2.0-based business initiative up andbusiness initiative up and running (Gartner)

• 2008. Web Services or Service-Oriented ArchitectureService Oriented Architecture (SOA) would surge ahead. (Gartner) 20%

WaitingWaiting

Page 8: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

ArchitectureArchitecture

Page 9: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

Architecture - LayersArchitecture Layers

Services

Browser Protocols

Ajax Flash / RIAJSON-RPC

Structures Server-Side

Widget DOMHTML/CSS JavaScript

SOAPXML-RPCJSON

XML

Open APIsSaaS

ServicesREST

Ajax Flash / RIA

HTTP(S)

Page 10: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

St t i ChStrategic Changes• Application Infrastructure

Vector Web 1.0 Web 2.0Protocols HTTP & HTTPS SOAP, XML-RPC, REST etc. overProtocols , ,

HTTP & HTTPS

Information structures HTML transfer XML, JSON, JS Objects etc.

Communication methods Synchronous Asynchronous & Cross-domainsCommunication methods SynchronousPostbackRefresh and Redirect

Asynchronous & Cross domains(proxy)

Information sharing Single place information (Nourge for integration)

Multiple sources (Urge for integratedinformation platform)g g ) p )

Page 11: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

St t i ChStrategic Changes

• Security ThreatsSecurity Threats

Vector Web 1.0 Web 2.0

Entry points Structured Scattered and multiple

Dependencies Limited • Multiple technologies• Information sources• Protocols• Protocols

Vulnerabilities Server side [Typical injections] • Web services [Payloads]• Client side [XSS & XSRF]

Exploitation Server side exploitation Both server and client side exploitation

Page 12: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

St t i ChStrategic Changes• Methodology

Vector Web 1.0 Web 2.0

Footprinting Typical with "Host" and DNS Empowered with search

Discovery Simple Difficult with hidden calls

Enumeration Structured Several streams

S i St t d d i l Diffi lt ith t i AjScanning Structured and simple Difficult with extensive Ajax

Automated attacks Easy after discovery Difficult with Ajax and web services

Reverse engineering On the server-side [Difficult] Client-side with Ajax & Flash

Code reviews Focus on server-side only Client-side analysis needed

Page 13: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

St t i ChStrategic Changes

• Countermeasure

Vector Web 1.0 Web 2.0

Owner of information Single place Multiple places [Mashups & RSS]

Browser security Simple DOM usage Complex DOM usage

Validations Server side Client side [incoming content]

Logic shift Only on server Client side shiftLogic shift Only on server Client side shift

Secure coding Structured and single place Multiple places and scattered

Page 14: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

E i Att k & CEnemies, Attacks & Cause

• Complex architecture and confusion with• Complex architecture and confusion with technologies

• Web 2 0 worms and viruses – SammyWeb 2.0 worms and viruses Sammy, Yammaner & Spaceflash

• Ajax and JavaScripts – Client side attacks areAjax and JavaScripts Client side attacks are on the rise (XSS/CSRF)

• Web Services attacks and exploitationp• Flash clients are running with risks

Page 15: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

R l Lif CReal Life Cases

Source: The Web Hacking Incidents Database Sou ce e eb ac g c de ts atabase[http://webappsec.org/projects/whid/]

Page 16: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

Moves from Black– Methodologies– Methodologies– Fingerprinting– Discovery– Enumeration and Crawling

Page 17: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

M th d l iMethodologies

• Fingerprinting Application and Framework• Fingerprinting – Application and Framework• Discovery – Discovering structures like JSON or

XMLXML• Crawling 2.0 – Application crawling with DOM

contextcontext• Scanning strategies – Fuzz and Scan• Defense – Secure Coding and FirewallDefense Secure Coding and Firewall

Page 18: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

Fi i ti DFingerprinting

• Application fingerprinting identifying web and

Demo

• Application fingerprinting – identifying web and application servers

• Ajax and RIA framework fingerprintsAjax and RIA framework fingerprints• Getting hold on to technologies – WebLogic or

Tomcat, Atlas or DojoTomcat, Atlas or Dojo• Helps in assessment and mapping publicly

known vulnerabilities

Page 19: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

Aj /RIA llAjax/RIA call

• Asynchronous JavaScript and XML• Asynchronous JavaScript and XML

HTML / CSS / Flash

JS / DOM

Database / Resource

XML / Middleware / Text

XMLHttpRequest (XHR) Web Server

Asynchronous over HTTP(S)

Page 20: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

Di DDiscovery

• Ajax running with various different structures

Demo

Ajax running with various different structures• Developers are adding various different calls

and methods for it– JSON, Array, JS-Object etc.

• JavaScript can talk with back-end sources• Mashups application talking with various

sources• It has significant security impact• It has significant security impact• Identifying and Discovery of structures

Page 21: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

C li & E ti f W b 2 0 DemoCrawling & Enumeration for Web 2.0

• Dynamic page creation through JavaScript using

Demo

• Dynamic page creation through JavaScript using Ajax

• DOM events are managing the application layerDOM events are managing the application layer• DOM is having clear context• Protocol driven crawling is not possible without• Protocol driven crawling is not possible without

loading page in the browser

Page 22: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

Vulnerabilities and ScanScan for XSS– Scan for XSS

– One/Two Way CSRF– RSS, Widget, Mashup, Blog hacksg p g– Web Services Attacks and Combats

Page 23: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

C Sit S i ti (XSS) 2 0 St lCross Site Scripting (XSS) – 2.0 Style

• What is different?• What is different?– Ajax calls get the stream

Inject into current DOM using eval() or any– Inject into current DOM using eval() or any other meansMay rewrite content using document write or– May rewrite content using document.write or innerHTML calls

– Source of stream can be un-trustedSource of stream can be un trusted– Cross Domain calls are very common

Page 24: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

Add i C D i C ll DemoAddressing Cross Domain Calls

• Cross Domain calls are very important for Web

Demo

Cross Domain calls are very important for Web 2.0 applications.– Proxy to talk with cross domainy– Callback implementation to fetch them– Flash via crossdomain.xml

• These are types of bypass and can have it i li tisecurity implications

• Source of the information – key!

Page 25: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

S iScenario

JSON V l bl t iBlog

Posting to the site

JSONfeed

Vulnerable stream coming through proxy

DBattacker Web app

proxy

8008

g[Malicious code]

WebWeb app8008

ServerHijack

WebClient

JSON

eval()eval()

XSS

Page 26: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

XSS ith RIAXSS with RIA

• Applications running with Flash components• Applications running with Flash components• getURL – injection is possible• SWFIntruder• SWFIntruder• Flasm/Flare(http://www nowrap de/)(http://www.nowrap.de/)

Page 27: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

S i f XSS DemoScanning for XSS

Scanning Aja components

Demo

• Scanning Ajax components• Retrieving all JS include files

Part of <SCRIPT SRC= >– Part of <SCRIPT SRC=….>

• Identifying XHR calls• Grabbing function• Grabbing function• Mapping function to DOM event

S i d f XSS l k f l() d• Scanning code for XSS – look for eval() and document.write()

Page 28: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

Aj i li ti iAjax serialization issues• Ajax processing various information coming from

d thi d t XSSserver and third party sources. – XSS opportunities

message = {JS – Object

from : "[email protected]",to : "[email protected]",subject : "I am fine",body : "Long message here",showsubject :

function(){document.write(this.subject)}};

JSON issues

{"bookmarks":[{"Link":"www.example.com","Desc":"Interesting link"}]}

new Array(“Laptop”, “Thinkpad”, “T60”, “ d” “900$” “ i d h“Used”, “900$”, “It is great and I have used it for 2 years”)

JS – Array manipulation

Page 29: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

C tCountermeasures

• Client side code audit is required• Client side code audit is required• XHR calls and DOM utilization needs to be

analyzedanalyzed• Content from un-trusted information sources

should be filtered out at proxy layershould be filtered out at proxy layer• Cross Domain Callback – careful• Browser side content validation beforeBrowser side content validation before

consuming into DOM

Page 30: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

C Sit R t F (CSRF)Cross Site Request Forgery (CSRF)

• Generic CSRF is with GET / POSTGeneric CSRF is with GET / POST• Forcefully sending request to the target

application with cookie replaypp p y• Leveraging tags like

– IMG– SCRIPT– IFRAME

• Not abide by SOP or Cross Domain is possible

Page 31: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

C Sit R t F (CSRF) DemoCross Site Request Forgery (CSRF)

• What is different with Web 2 0

Demo

• What is different with Web 2.0– Is it possible to do CSRF to XML stream

How?– How?– It will be POST hitting the XML processing

resources like Web Servicesresources like Web Services– JSON CSRF is also possible

Interesting check to make against application– Interesting check to make against application and Web 2.0 resources

Page 32: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

O W CSRF S iOne Way CSRF Scenario

Page 33: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

O W CSRF S iOne Way CSRF Scenario

Page 34: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

O W CSRF S iOne Way CSRF Scenario

Page 35: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

O W CSRF S i DOne Way CSRF Scenario Demo

Page 36: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

O W CSRFOne-Way CSRF<html><body><FORM NAME="buy" ENCTYPE="text/plain"

action="http://trade.example.com/xmlrpc/trade.rem" METHOD="POST"><input type="hidden" name='<?xml version'p yp

value='"1.0"?><methodCall><methodName>stocks.buy</methodName><params><param><value><string>MSFT</string></value></param><param><value><double>26</double></value></param></params></methodCall>'>

</FORM><script>document.buy.submit();</script></body></html>

• Splitting XML stream in the form• Possible through XForms as well

Similar techniques is applicable to JSON as well• Similar techniques is applicable to JSON as well

Page 37: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

T W CSRFTwo-Way CSRF

• One Way Just making forceful request• One-Way – Just making forceful request.• Two-Way

– Reading the data coming from the targetReading the data coming from the target– May be getting hold onto important information – profile,

statements, numbers etc.– Is it possible with JSON/XML

Page 38: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

T W CSRF DTwo-Way CSRF Demo

Page 39: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

T W CSRFTwo-Way CSRF

• Application is serving various streams like• Application is serving various streams like –JSON, JS-Object, Array etc.

• Attacker page can make cross domain request p g qusing SCRIPT (firefox)

• Following code can overload the array stream.g yfunction Array() { var obj = this; var index = 0; for(j=0;j<4;j++){ obj[index++] setter = spoof; } } function spoof(x){ send(x.toString()); }

Page 40: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

C tCountermeasure

• Server Side Checks• Server Side Checks– Check for client’s content-type

XHR calls xml/application– XHR calls – xml/application– Native calls – text/html

Filt i i ibl it– Filtering is possible on it• Client Side Checks

St b t t d d t i t d b /*– Stream can be started and terminated by /* or any predefined charactersCli t th b f i j ti t– Client can remove them before injecting to DOM

Page 41: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

W b 2 0 C tWeb 2.0 Components

• There are various other components for Web 2 0• There are various other components for Web 2.0 Applications– RSS feedsRSS feeds– Mashups

Widgets– Widgets– Blogs

Flash based components– Flash based components

Page 42: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

RSS f d DRSS feeds

• RSS feeds coming into application from various

Demo

RSS feeds coming into application from various un-trusted sources

• Feed readers are part of 2.0 Applications.p pp• Vulnerable to XSS• Malicious code can be executed on the browser.• Several vulnerabilities reported

Page 43: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

M hMashups

• API exposure for Mashup supplier applicationAPI exposure for Mashup supplier application• Cross Domain access by callback may cause a

security breachy• Confidential information sharing with Mashup

application handling needs to be checked –t i d d di it (SSL)storing password and sending it across (SSL)

• Mashup application can be man in the middle so can’t trust or must be trusted onecan t trust or must be trusted one

Page 44: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

Wid t /G d tWidgets/Gadgets

• DOM sharing model can cause many security g y yissues

• One widget can change information on another id iblwidget – possible

• CSRF injection through widget codeE t hij ki i ibl C DOM• Event hijacking is possible – Common DOM

• IFrame – for widget is a MUST

Page 45: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

BlBlogs

• Blogs are common to Web 2 0 applicationsBlogs are common to Web 2.0 applications• Many applications are plugging third party blogs• One needs to check these blogs – XSS isOne needs to check these blogs XSS is

common with blogging applications• Exceptions and Search are common XSS points

Page 46: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

SOA St kSOA Stack

Presentation StackXML,JSON,JS-* HTML / JS / DOM

RIA (Flash)

Ajax

Discovery Stack

Security StackWS-Security

Access StackWSDL,SOAP,XML-RPC,REST

yUDDI, DISCO

Transport StackHTTP, HTTPS

, , ,

Page 47: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

P i Di DPrimary Discovery

• Crawling the application and mapping file

Demo

• Crawling the application and mapping file extensions and directory structures, like “.asmx”

• Page scrubbing – scanning for paths andPage scrubbing scanning for paths and resources in the pages, like atlas back end call to Web Services

• Recording traffic while browsing and spidering, look for XML based traffic – leads to XML-RPC, REST, SOAP, JSON calls

Page 48: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

S d Di DSecondary Discovery

• Searching UDDI server for Web Services

Demo

• Searching UDDI server for Web Services running on particular domain– Three tactics for it – business services orThree tactics for it business, services or

tModel• Running queries against search engines likeRunning queries against search engines like

Google or MSN with extra directives like “inurl” or “filetype”– Look for “asmx”

• wsScanner – Discovery!

Page 49: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

E ti d P fili DEnumerating and Profiling • Fingerprinting .Net framework and Client side

Demo

technologies – Dojo or Atlas …• Scanning WSDL

– Looking for Methods– Collecting In/Out parameters– Security implementations– Binding pointsg p– Method signature mapping

Page 50: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

Scanning strategies DScanning strategies• Manual invocation and response analysis• Dynamic proxy creation and scanning

Demo

• Dynamic proxy creation and scanning• Auto auditing for various vectors

F i W b S i t XML JSON• Fuzzing Web Services streams – XML or JSON• Response analysis is the key

L k f f l d d– Look for fault code nodes– Enumerating fault strings– Dissecting XML message and finding bits– Hidden error messages in JSON

Page 51: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

Di i V l biliti DDiscovering Vulnerabilities

• Web Services methods are consuming

Demo

• Web Services methods are consuming parameters coming from end users

• It is possible to inject malicious characters intoIt is possible to inject malicious characters into the stream

• It can break Web Services code and sendIt can break Web Services code and send faultsting back to an attacker

• Various injections possible – SQL and XPATHj p Q• File system access• Remote command injectionRemote command injection• Information leakage

Page 52: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

• Moves from WhiteCode scanning defense– Code scanning defense

– Firewall Web 2.0 attacks and streams

Page 53: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

C d A l i f W b 2 0 DCode Analysis for Web 2.0

• Scanning the code base

Demo

• Scanning the code base• Identifying linkages• Method signatures and inputs• Method signatures and inputs• Looking for various patterns for SQL, LDAP,

XPATH File access etcXPATH, File access etc.• Checking validation on them• Code walking and tracing the base Key• Code walking and tracing the base - Key

Page 54: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

C t t filt i ith 2 0

• Regular firewall will not work

Content filtering with 2.0

• Regular firewall will not work• Content filtering on HTTP will not work either

since it is SOAP/JSON over HTTP/HTTPSsince it is SOAP/JSON over HTTP/HTTPS• SOAP/JOSN level filtering and monitoring would

requirerequire• ISAPI level filtering is essential• SOAP/JSON content filtering throughSOAP/JSON content filtering through

IHTTPModule

Page 55: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

HTTP Stack for Net (IIS6/7) DHTTP Stack for .Net (IIS6/7)HttpRuntime

Demo

HttpApplicationFactory Web Application Firewall

HttpApplicationFirewall & IDS

IHttpModule

HttpHandlerFactory

Handler

148

Page 56: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

C l iConclusion

• Web 2 0 bringing new challengesWeb 2.0 bringing new challenges• Needs to adopt new methodologies for scanning• Attacks and entry points are scattered andAttacks and entry points are scattered and

multiple• Ajax and SOA are key components• WAF and Code review are important aspects for

Web 2.0 defense

Page 57: Microsoft PowerPoint - SOA-202.ppt [Compatibility Mode]

Questions?

Shreeraj ShahShreeraj ShahBlueinfy Solutions Pvt. [email protected]+987902701891+9879027018

Tools : http://www.blueinfy.com/tools.html