SlideShare a Scribd company logo
Secure Web Messaging in
HTML5
Krishna Chaitanya T
Microsoft MVP, Internet Explorer

@novogeek



                                   MUGH Developer
                                       Day
                                     29th Jan, 2012
Agenda



Web 2.0                     Communicatio            HTML5                           Security
A quick overview of         n                       How the new Web                 Solved problems &
new needs of Web 2.0                                Messaging API helps             new concerns
                            Traditional data
era
Case study of few Mashups
                            exchange & drawbacks
                             Quick overview:        Why there is a need for a new   Reduced scope for XSS
                            JavaScript, Ajax,       specification for web based     Improved trust model
Understanding their         Browser Sandbox, SOP,   messaging,
technical limitations       Frames, Navigation                                      Newer security concerns
                            policies, Fragment                                      Counter measures
                            Identifier
A mashup with widgets




               PageFlakes.com
An interactive mashup




                 HousingMaps.com
Embedding Remote JS

 Assumption - script is from trusted source

 No isolation of origins

 Runs in the context of window
                                               “A mashup is a self-inflicted XSS
 Has complete access to DOM                   attack”

                                               -Douglas Crockford,
 Can read & export your data
                                               Inventor of JSON

 No user involvement needed
Same Origin Policy

 Browser has to isolate different origins

 Origin = protocol://host:port
     Ex: http://bing.com, http://localhost:81/, https://icicibank.com

 Privileges within origin
     Full network access
     Read/Write access to DOM
     Storage

 Embedded scripts have privileges of imported page, NOT source server

 AJAX calls to cross domains fail due to SOP.
Demo
Same Origin Policy in action!
Isolation with Frames
 Different security contexts for different origins

 Brings modularity but less interactive than embedding JS

 No standard communication mechanism

 Comply with SOP - Run remote code safely



 <!-- This is allowed -->
 <iframe src="sameDomainPage.html"> </iframe>
 alert(frames[0].contentDocument.body); //works fine

 <!-- This is **NOT** allowed -->
 <iframe src="http://crossDomain.com"> </iframe>
 alert(frames[0].contentDocument.body); //throws error
Frame Navigation
 Beware! Frames can be navigated to different origins!

 Frame-Frame relationships
     Can script in Frame A modify DOM of Frame B?
     Can Script in Frame A “navigate” or change the origin of Frame B?

 Frame navigation is NOT the same as SOP - often mistaken!


  <iframe src=“http://crossDomain.com"> </iframe>

  <!-- This is **NOT** allowed -->
  alert(frames[0].src); //throws error – SOP restriction

  <!-- This is allowed -->
  alert(frames[0].src=“http://bing.com”); //works fine - frame navigation
Cross-Window Attack!




                                                                awglogin




    window.open("https://attacker.com/", "awglogin");



                          Courtesy: Stanford Web Security Lab
Same-Window attack!

           top.frames[1].location = "http://www.attacker.com/...";
           top.frames[2].location = "http://www.attacker.com/...";
                                    ...




                 Courtesy: Stanford Web Security Lab
Frame Navigation Policies

Permissive



Window



Descendant



Child
Frame
Communication
Fragment Identifier Messaging
 Work around before HTML5

 Limited data, no acknowledgements.

 Navigation doesn’t reload page

 Not a secure channel.

  //Sender.html
  function send(){
    iframe.src=“http://localhost/receiver.html#data”;
  }
  //Receiver.html
  window.onload=function(){
    data=window.location.hash;
  }
HTML5 Post Message API




 Cross-origin client side communication

 Network-like channel between frames

 Securely abstracts multiple principals

 Frames can now integrate widgets with improved trust
HTML5 Post Message API
 Syntax: otherwindow.postMessage(message, targetOrigin);

 targetOrigin can be a trusted source or wild card *“*”+


 //Posting message to a cross domain partner.
 frames[0].postMessage(“Hello Partner!”, "http://localhost:81/");

 //Retrieving message from the sender
 window.onmessage = function (e) {
     if (e.origin == 'http://localhost') {
        //sanitize and accept data
     }
 };
Few security considerations
 Do not configure target origin to “*”.
       Sensitive data can be leaked to unknown widgets

 Always check for sender’s origin
       Client side DoS attacks can be launched

 Always validate data before use.
     Do not consume data directly with eval() or innerHTML
     Follow best practices of DOM based XSS prevention

 Eavesdropping with framing attacks!
     In spite of above checks, data can still be lost
       Ex: Recursive Mashup attack
     Follow frame busting techniques
Demo
 Playing with HTML5 Post Message API

 Bonus (if time permits) – Recursive Mashup Attack!
References & Reading
 “Secure Frame Communication in Browsers”-Adam Barth, Collin
  Jackson, John Mitchell-Stanford Web Security Research Lab

 W3C HTML5 Web Messaging Specification -
  http://dev.w3.org/html5/postmsg/#authors

 Dive into HTML5 – http://diveintohtml5.info

 IE9 Guide for Developers - http://msdn.microsoft.com/en-
  us/ie/hh410106.aspx
Thank You!


http://novogeek.com | @novogeek


        http://mugh.net
Ad

Recommended

JSFoo Chennai 2012
JSFoo Chennai 2012
Krishna T
 
Browser Internals-Same Origin Policy
Browser Internals-Same Origin Policy
Krishna T
 
Html5 security
Html5 security
Krishna T
 
Clickjacking DevCon2011
Clickjacking DevCon2011
Krishna T
 
Html5 for Security Folks
Html5 for Security Folks
n|u - The Open Security Community
 
Attacking Web Proxies
Attacking Web Proxies
InMobi Technology
 
Dom based xss
Dom based xss
Lê Giáp
 
Browser Security
Browser Security
Roberto Suggi Liverani
 
New Insights into Clickjacking
New Insights into Clickjacking
Marco Balduzzi
 
Owasp Top 10 A3: Cross Site Scripting (XSS)
Owasp Top 10 A3: Cross Site Scripting (XSS)
Michael Hendrickx
 
Html5 localstorage attack vectors
Html5 localstorage attack vectors
Shreeraj Shah
 
Top Ten Web Hacking Techniques – 2008
Top Ten Web Hacking Techniques – 2008
Jeremiah Grossman
 
Top Ten Web Hacking Techniques of 2012
Top Ten Web Hacking Techniques of 2012
Jeremiah Grossman
 
When Ajax Attacks! Web application security fundamentals
When Ajax Attacks! Web application security fundamentals
Simon Willison
 
BsidesDelhi 2018: DomGoat - the DOM Security Playground
BsidesDelhi 2018: DomGoat - the DOM Security Playground
BSides Delhi
 
Rich Web App Security - Keeping your application safe
Rich Web App Security - Keeping your application safe
Jeremiah Grossman
 
Browser Security 101
Browser Security 101
Stormpath
 
Java script, security and you - Tri-Cities Javascript Developers Group
Java script, security and you - Tri-Cities Javascript Developers Group
Adam Caudill
 
Web browser privacy and security
Web browser privacy and security
amiable_indian
 
Starwest 2008
Starwest 2008
Caleb Sima
 
Top Ten Web Hacking Techniques (2008)
Top Ten Web Hacking Techniques (2008)
Jeremiah Grossman
 
Sandboxed platform using IFrames, postMessage and localStorage
Sandboxed platform using IFrames, postMessage and localStorage
tomasperezv
 
Top Ten Web Hacking Techniques (2010)
Top Ten Web Hacking Techniques (2010)
Jeremiah Grossman
 
Xss is more than a simple threat
Xss is more than a simple threat
Avădănei Andrei
 
Browser Security by pratimesh Pathak ( Buldhana)
Browser Security by pratimesh Pathak ( Buldhana)
Pratimesh Pathak
 
XXE Exposed: SQLi, XSS, XXE and XEE against Web Services
XXE Exposed: SQLi, XSS, XXE and XEE against Web Services
Abraham Aranguren
 
MITM Attacks on HTTPS: Another Perspective
MITM Attacks on HTTPS: Another Perspective
GreenD0g
 
VSA: The Virtual Scripted Attacker, Brucon 2012
VSA: The Virtual Scripted Attacker, Brucon 2012
Abraham Aranguren
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realities
Brad Hill
 
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...
Divyanshu
 

More Related Content

What's hot (20)

New Insights into Clickjacking
New Insights into Clickjacking
Marco Balduzzi
 
Owasp Top 10 A3: Cross Site Scripting (XSS)
Owasp Top 10 A3: Cross Site Scripting (XSS)
Michael Hendrickx
 
Html5 localstorage attack vectors
Html5 localstorage attack vectors
Shreeraj Shah
 
Top Ten Web Hacking Techniques – 2008
Top Ten Web Hacking Techniques – 2008
Jeremiah Grossman
 
Top Ten Web Hacking Techniques of 2012
Top Ten Web Hacking Techniques of 2012
Jeremiah Grossman
 
When Ajax Attacks! Web application security fundamentals
When Ajax Attacks! Web application security fundamentals
Simon Willison
 
BsidesDelhi 2018: DomGoat - the DOM Security Playground
BsidesDelhi 2018: DomGoat - the DOM Security Playground
BSides Delhi
 
Rich Web App Security - Keeping your application safe
Rich Web App Security - Keeping your application safe
Jeremiah Grossman
 
Browser Security 101
Browser Security 101
Stormpath
 
Java script, security and you - Tri-Cities Javascript Developers Group
Java script, security and you - Tri-Cities Javascript Developers Group
Adam Caudill
 
Web browser privacy and security
Web browser privacy and security
amiable_indian
 
Starwest 2008
Starwest 2008
Caleb Sima
 
Top Ten Web Hacking Techniques (2008)
Top Ten Web Hacking Techniques (2008)
Jeremiah Grossman
 
Sandboxed platform using IFrames, postMessage and localStorage
Sandboxed platform using IFrames, postMessage and localStorage
tomasperezv
 
Top Ten Web Hacking Techniques (2010)
Top Ten Web Hacking Techniques (2010)
Jeremiah Grossman
 
Xss is more than a simple threat
Xss is more than a simple threat
Avădănei Andrei
 
Browser Security by pratimesh Pathak ( Buldhana)
Browser Security by pratimesh Pathak ( Buldhana)
Pratimesh Pathak
 
XXE Exposed: SQLi, XSS, XXE and XEE against Web Services
XXE Exposed: SQLi, XSS, XXE and XEE against Web Services
Abraham Aranguren
 
MITM Attacks on HTTPS: Another Perspective
MITM Attacks on HTTPS: Another Perspective
GreenD0g
 
VSA: The Virtual Scripted Attacker, Brucon 2012
VSA: The Virtual Scripted Attacker, Brucon 2012
Abraham Aranguren
 
New Insights into Clickjacking
New Insights into Clickjacking
Marco Balduzzi
 
Owasp Top 10 A3: Cross Site Scripting (XSS)
Owasp Top 10 A3: Cross Site Scripting (XSS)
Michael Hendrickx
 
Html5 localstorage attack vectors
Html5 localstorage attack vectors
Shreeraj Shah
 
Top Ten Web Hacking Techniques – 2008
Top Ten Web Hacking Techniques – 2008
Jeremiah Grossman
 
Top Ten Web Hacking Techniques of 2012
Top Ten Web Hacking Techniques of 2012
Jeremiah Grossman
 
When Ajax Attacks! Web application security fundamentals
When Ajax Attacks! Web application security fundamentals
Simon Willison
 
BsidesDelhi 2018: DomGoat - the DOM Security Playground
BsidesDelhi 2018: DomGoat - the DOM Security Playground
BSides Delhi
 
Rich Web App Security - Keeping your application safe
Rich Web App Security - Keeping your application safe
Jeremiah Grossman
 
Browser Security 101
Browser Security 101
Stormpath
 
Java script, security and you - Tri-Cities Javascript Developers Group
Java script, security and you - Tri-Cities Javascript Developers Group
Adam Caudill
 
Web browser privacy and security
Web browser privacy and security
amiable_indian
 
Top Ten Web Hacking Techniques (2008)
Top Ten Web Hacking Techniques (2008)
Jeremiah Grossman
 
Sandboxed platform using IFrames, postMessage and localStorage
Sandboxed platform using IFrames, postMessage and localStorage
tomasperezv
 
Top Ten Web Hacking Techniques (2010)
Top Ten Web Hacking Techniques (2010)
Jeremiah Grossman
 
Xss is more than a simple threat
Xss is more than a simple threat
Avădănei Andrei
 
Browser Security by pratimesh Pathak ( Buldhana)
Browser Security by pratimesh Pathak ( Buldhana)
Pratimesh Pathak
 
XXE Exposed: SQLi, XSS, XXE and XEE against Web Services
XXE Exposed: SQLi, XSS, XXE and XEE against Web Services
Abraham Aranguren
 
MITM Attacks on HTTPS: Another Perspective
MITM Attacks on HTTPS: Another Perspective
GreenD0g
 
VSA: The Virtual Scripted Attacker, Brucon 2012
VSA: The Virtual Scripted Attacker, Brucon 2012
Abraham Aranguren
 

Similar to Secure web messaging in HTML5 (20)

W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realities
Brad Hill
 
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...
Divyanshu
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realities
Brad Hill
 
XCS110_All_Slides.pdf
XCS110_All_Slides.pdf
ssuser01066a
 
Website hacking and prevention (All Tools,Topics & Technique )
Website hacking and prevention (All Tools,Topics & Technique )
Jay Nagar
 
Locking the Throne Room - How ES5+ might change views on XSS and Client Side ...
Locking the Throne Room - How ES5+ might change views on XSS and Client Side ...
Mario Heiderich
 
Will Web 2.0 applications break the cloud?
Will Web 2.0 applications break the cloud?
Flaskdata.io
 
Warning Ahead: SecurityStorms are Brewing in Your JavaScript
Warning Ahead: SecurityStorms are Brewing in Your JavaScript
Cyber Security Alliance
 
Detection of webshells in compromised perimeter assets using ML algorithms
Detection of webshells in compromised perimeter assets using ML algorithms
Rod Soto
 
Caja "Ka-ha" Introduction
Caja "Ka-ha" Introduction
yiming he
 
Top 10 Web Hacks 2012
Top 10 Web Hacks 2012
Matt Johansen
 
AJAX: How to Divert Threats
AJAX: How to Divert Threats
Cenzic
 
HTML5 Real-Time and Connectivity
HTML5 Real-Time and Connectivity
Peter Lubbers
 
Locking the Throneroom 2.0
Locking the Throneroom 2.0
Mario Heiderich
 
Cross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning Center
Michael Coates
 
Cross Site Scripting Defense Presentation
Cross Site Scripting Defense Presentation
Ikhade Maro Igbape
 
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
CODE BLUE
 
Secure Mashups
Secure Mashups
kriszyp
 
04. xss and encoding
04. xss and encoding
Eoin Keary
 
Owasp Top 10 - Owasp Pune Chapter - January 2008
Owasp Top 10 - Owasp Pune Chapter - January 2008
abhijitapatil
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realities
Brad Hill
 
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...
Divyanshu
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realities
Brad Hill
 
XCS110_All_Slides.pdf
XCS110_All_Slides.pdf
ssuser01066a
 
Website hacking and prevention (All Tools,Topics & Technique )
Website hacking and prevention (All Tools,Topics & Technique )
Jay Nagar
 
Locking the Throne Room - How ES5+ might change views on XSS and Client Side ...
Locking the Throne Room - How ES5+ might change views on XSS and Client Side ...
Mario Heiderich
 
Will Web 2.0 applications break the cloud?
Will Web 2.0 applications break the cloud?
Flaskdata.io
 
Warning Ahead: SecurityStorms are Brewing in Your JavaScript
Warning Ahead: SecurityStorms are Brewing in Your JavaScript
Cyber Security Alliance
 
Detection of webshells in compromised perimeter assets using ML algorithms
Detection of webshells in compromised perimeter assets using ML algorithms
Rod Soto
 
Caja "Ka-ha" Introduction
Caja "Ka-ha" Introduction
yiming he
 
Top 10 Web Hacks 2012
Top 10 Web Hacks 2012
Matt Johansen
 
AJAX: How to Divert Threats
AJAX: How to Divert Threats
Cenzic
 
HTML5 Real-Time and Connectivity
HTML5 Real-Time and Connectivity
Peter Lubbers
 
Locking the Throneroom 2.0
Locking the Throneroom 2.0
Mario Heiderich
 
Cross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning Center
Michael Coates
 
Cross Site Scripting Defense Presentation
Cross Site Scripting Defense Presentation
Ikhade Maro Igbape
 
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
CODE BLUE
 
Secure Mashups
Secure Mashups
kriszyp
 
04. xss and encoding
04. xss and encoding
Eoin Keary
 
Owasp Top 10 - Owasp Pune Chapter - January 2008
Owasp Top 10 - Owasp Pune Chapter - January 2008
abhijitapatil
 
Ad

Recently uploaded (20)

Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Ravi Tamada
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
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
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
Mastering AI Workflows with FME by Mark Döring
Mastering AI Workflows with FME by Mark Döring
Safe Software
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
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
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
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
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
"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
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
The Future of Product Management in AI ERA.pdf
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Ravi Tamada
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
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
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
Mastering AI Workflows with FME by Mark Döring
Mastering AI Workflows with FME by Mark Döring
Safe Software
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
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
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
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
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
"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
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
The Future of Product Management in AI ERA.pdf
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
Ad

Secure web messaging in HTML5

  • 1. Secure Web Messaging in HTML5 Krishna Chaitanya T Microsoft MVP, Internet Explorer @novogeek MUGH Developer Day 29th Jan, 2012
  • 2. Agenda Web 2.0 Communicatio HTML5 Security A quick overview of n How the new Web Solved problems & new needs of Web 2.0 Messaging API helps new concerns Traditional data era Case study of few Mashups exchange & drawbacks Quick overview: Why there is a need for a new Reduced scope for XSS JavaScript, Ajax, specification for web based Improved trust model Understanding their Browser Sandbox, SOP, messaging, technical limitations Frames, Navigation Newer security concerns policies, Fragment Counter measures Identifier
  • 3. A mashup with widgets PageFlakes.com
  • 4. An interactive mashup HousingMaps.com
  • 5. Embedding Remote JS  Assumption - script is from trusted source  No isolation of origins  Runs in the context of window “A mashup is a self-inflicted XSS  Has complete access to DOM attack” -Douglas Crockford,  Can read & export your data Inventor of JSON  No user involvement needed
  • 6. Same Origin Policy  Browser has to isolate different origins  Origin = protocol://host:port  Ex: http://bing.com, http://localhost:81/, https://icicibank.com  Privileges within origin  Full network access  Read/Write access to DOM  Storage  Embedded scripts have privileges of imported page, NOT source server  AJAX calls to cross domains fail due to SOP.
  • 8. Isolation with Frames  Different security contexts for different origins  Brings modularity but less interactive than embedding JS  No standard communication mechanism  Comply with SOP - Run remote code safely <!-- This is allowed --> <iframe src="sameDomainPage.html"> </iframe> alert(frames[0].contentDocument.body); //works fine <!-- This is **NOT** allowed --> <iframe src="http://crossDomain.com"> </iframe> alert(frames[0].contentDocument.body); //throws error
  • 9. Frame Navigation  Beware! Frames can be navigated to different origins!  Frame-Frame relationships  Can script in Frame A modify DOM of Frame B?  Can Script in Frame A “navigate” or change the origin of Frame B?  Frame navigation is NOT the same as SOP - often mistaken! <iframe src=“http://crossDomain.com"> </iframe> <!-- This is **NOT** allowed --> alert(frames[0].src); //throws error – SOP restriction <!-- This is allowed --> alert(frames[0].src=“http://bing.com”); //works fine - frame navigation
  • 10. Cross-Window Attack! awglogin window.open("https://attacker.com/", "awglogin"); Courtesy: Stanford Web Security Lab
  • 11. Same-Window attack! top.frames[1].location = "http://www.attacker.com/..."; top.frames[2].location = "http://www.attacker.com/..."; ... Courtesy: Stanford Web Security Lab
  • 14. Fragment Identifier Messaging  Work around before HTML5  Limited data, no acknowledgements.  Navigation doesn’t reload page  Not a secure channel. //Sender.html function send(){ iframe.src=“http://localhost/receiver.html#data”; } //Receiver.html window.onload=function(){ data=window.location.hash; }
  • 15. HTML5 Post Message API  Cross-origin client side communication  Network-like channel between frames  Securely abstracts multiple principals  Frames can now integrate widgets with improved trust
  • 16. HTML5 Post Message API Syntax: otherwindow.postMessage(message, targetOrigin);  targetOrigin can be a trusted source or wild card *“*”+ //Posting message to a cross domain partner. frames[0].postMessage(“Hello Partner!”, "http://localhost:81/"); //Retrieving message from the sender window.onmessage = function (e) { if (e.origin == 'http://localhost') { //sanitize and accept data } };
  • 17. Few security considerations  Do not configure target origin to “*”.  Sensitive data can be leaked to unknown widgets  Always check for sender’s origin  Client side DoS attacks can be launched  Always validate data before use.  Do not consume data directly with eval() or innerHTML  Follow best practices of DOM based XSS prevention  Eavesdropping with framing attacks!  In spite of above checks, data can still be lost  Ex: Recursive Mashup attack  Follow frame busting techniques
  • 18. Demo  Playing with HTML5 Post Message API  Bonus (if time permits) – Recursive Mashup Attack!
  • 19. References & Reading  “Secure Frame Communication in Browsers”-Adam Barth, Collin Jackson, John Mitchell-Stanford Web Security Research Lab  W3C HTML5 Web Messaging Specification - http://dev.w3.org/html5/postmsg/#authors  Dive into HTML5 – http://diveintohtml5.info  IE9 Guide for Developers - http://msdn.microsoft.com/en- us/ie/hh410106.aspx
  • 20. Thank You! http://novogeek.com | @novogeek http://mugh.net