Side-Channels on the Web: Attacks and Defenses

Tom Van Goethem
Tom Van GoethemPhD researcher at KU Leuven
Side-Channels on the Web:
Attacks and Defenses
Tom Van Goethem
@tomvangoethem
https://cute-kittens.com
https://cute-kittens.com https://super-doggos.org
https://cute-kittens.com https://super-doggos.org https://evil-bunnies.net
https://cute-kittens.com https://super-doggos.org https://evil-bunnies.net
BUNNIES ATTACK!
ATTACK!!ATTACK!!
What can the bunnies (attackers) do?
7
Attacker model
• Cross-origin attack (evil-bunnies.net vs. cute-kittens.com)
• Subject to Same-Origin-Policy
• Can't extract information directly
• Attacker infers information based on state of victim at target site
• Logged in or not?
• Search query has results?
• Launch cross-site requests; can't access response directly
• Attack needs to exploit side-channel leaks
https://evil-bunnies.net
https://cute-kittens.com
(1) visit malicious site
https://evil-bunnies.net
https://cute-kittens.com
(1) visit malicious site
(2) return malicious JS
https://evil-bunnies.net
https://cute-kittens.com
(1) visit malicious site
(2) return malicious JS
(3) probe affected resources
https://evil-bunnies.net
https://cute-kittens.com
(1) visit malicious site
(2) return malicious JS
(3) probe affected resources
(4) return user-specific response
https://evil-bunnies.net
https://cute-kittens.com
(1) visit malicious site
(2) return malicious JS
(3) probe affected resources
(4) return user-specific response
(5) use side-channel to infer
information about response
13
Response size may leak information about user state
~183kB
14
Response size may leak information about user state
~19kB
~183kB
15
Nethanel Gelernter and Amir Herzberg. "Cross-site search attacks." Proceedings of the 22nd ACM SIGSAC Conference on Computer and
Communications Security (CCS). ACM, 2015.
16
Nethanel Gelernter and Amir Herzberg. "Cross-site search attacks." Proceedings of the 22nd ACM SIGSAC Conference on Computer and
Communications Security (CCS). ACM, 2015.
17
18
XS-Leaks
• Server generates response based on user's state
• Attacker tries to differentiate between two responses
• Examples
• Logged in (=> large response) vs. not logged in (=> small response)
• User has access to resource (=> 200) vs. no access (=> 404)
• Was used to uniquely identify users by giving them access to attacker-controlled resources [1]
• Search query has results (=> response with iframe) vs. no results (=>
no iframe)
[1] Cristian-Alexandru Staicu and Michael Pradel. " Leaky Images: Targeted Privacy Attacks in the Web". Proceedings of
the 28th USENIX Security Symposium, 2019.
time
https://cute-kittens.com
state_0 state_n
time
https://cute-kittens.com
state_0 state_nstate_1
state_1: browser initiated connection to target site
1 fewer connection available in pool (e.g. 255 in Chrome)
=> infer whether endpoint includes resource to certain site
time
https://cute-kittens.com
state_0 state_nstate_1 state_2
state_1: browser initiated connection to target site
state_2: headers of response are received
1 fewer connection available in pool (e.g. 255 in Chrome)
=> infer whether endpoint includes resource to certain site
Promise returned by fetch() resolved
=> measure time to generate response + delay/jitter (Tstate_2 - Tstate_1)
time
https://cute-kittens.com
state_0 state_nstate_1 state_2 state_3
state_1: browser initiated connection to target site
state_2: headers of response are received
state_3: complete response body received
1 fewer connection available in pool (e.g. 255 in Chrome)
=> infer whether endpoint includes resource to certain site
Promise returned by fetch() resolved
=> measure time to generate response + delay/jitter (Tstate_2 - Tstate_1)
Time returned by Resource Timing API (performance.getEntries())
=> measure time to download response (Tstate_3 - Tstate_2)
time
https://cute-kittens.com
state_0 state_nstate_1 state_2 state_3
state_1: browser initiated connection to target site
state_2: headers of response are received
state_3: complete response body received
state_4
state_4: browser cached response
1 fewer connection available in pool (e.g. 255 in Chrome)
=> infer whether endpoint includes resource to certain site
Promise returned by fetch() resolved
=> measure time to generate response + delay/jitter (Tstate_2 - Tstate_1)
Time returned by Resource Timing API (performance.getEntries())
=> measure time to download response (Tstate_3 - Tstate_2)
Resource added to HTTP cache; can be requested w/o connection
=> infer which resources were cached
24
HEIST
HTTP
Encrypted
Information can be
Stolen through
TCP Windows
25
HEIST
• Determine exact response size (compressed)
• 1 TCP window = 10 TCP packets = 14480 bytes of data
• 2nd TCP window can only start after ACK (→ additional round-trip needed)
• Response fits in 1 TCP window → 1 RTT, otherwise 2+ RTTs
• Use side-channel to detect when first byte is received
fetch() promise resolves
• Use side-channel to detect when full response is received
Resource Timing API
• Timing difference < 5ms? Then 1 TCP window, otherwise 2 TCP windows
12
Response (14480 bytes)
1st TCP window
1st TCP window
fetch() resolves PerformanceEntry
Timing difference
Response (14481 bytes)
1st TCP window
ACK
…
2nd TCP window
1st TCP window
ACK
…
2nd TCP window
fetch() resolves
Timing difference (much bigger)
PerformanceEntry
32
• Important prerequisite: reflection of request in response
Needed to align on TCP window size
• Needs some “window-tuning” for larger responses
• Exact size is known after compression
Allows for BREACH-like attack
Extract secret information such as CSRF token
• More information: see whitepaper
https://tom.vg/papers/heist_blackhat2016.pdf
HEIST
time
https://messenger.com/t/<fb_id>
state_0 state_n
state_1 state_2 state_3
state_1: browser parsed response HTML
win.frames.length == 3
state_2: JavaScript replaces iframe ONLY IF user
has had contact with <facebook_id>
win.frames.length == 2
state_3: iframe has been replaced
win.frames.length == 3
const win = window.opener;
win.location = `https://messenger.com/t/${facebookID}`;
Credits: Ron Masas - http://ronmasas.com/posts/facebook-messenger-vulnerability/
34
Browser state changes
• As soon as a resource is requested, the browser will transition
between different “states”
• These state changes can be permanent or temporary
• Permanent: frame is added to included web page
• Temporary: load event is fired
• Time and order when state changes occur can be important
35
Detecting browser state changes
• Two different responses can result in two different state change patterns
• Strict requirement for performing practical XS-Leak attack
• Attacker includes target endpoint as a resource
• E.g. iframe (if no X-Frame-Options + needs rendering)
• E.g. window.open (in case of XFO + needs rendering)
• E.g. <img>.src (in case no rendering required)
• Attacker observes properties/events/… associated with the included resource
• E.g. frames.length
• May need more advanced resource operations
• E.g. first load resource X, then load resource Y
38
XS-Leaks overview
• Response size
• Timing network connections
• Browser-based timing attack (<video>, Cache API, AppCache)
• Storage API (fixed , reintroduced for small disk devices, fixed again)
• HEIST (TCP level)
• Response status
• Application Cache (error when resource redirects)
• history.length (+1 in case resource redirected)
• Resource Timing (difference between start and fetchStart property)
• CSP (policy set by attacker, violation in case of redirect to other domain)
39
XS-Leaks overview (2)
• Cache status
• AppCache (Cache-control: no-store resources cause error)
• Timing (cached resources load much faster)
• Resource content and operations
• frames.length (for iframe or new opened window)
• postMessage() to parent page (may contain sensitive content)
• Event loop (spy on pattern of other processes)
• Navigate to id (triggers blur event on attacker page)
• More techniques likely to be discovered
• Check out https://github.com/xsleaks/xsleaks/
40
Defenses
41
XS-Leaks defenses
• Two main approaches
1. Prevent differences in responses
2. Prevent attacker from observing state-changes
• Often a combination of both approaches
• (1) is purely a server-side effort
• (2) is often controlled by response headers that instruct browser
• Using SameSite cookies can be very effective
• Defends against all attacks except for those based on window.open
42
XS-Leaks defenses
• Different attack techniques may require different defenses
• iframe attacks: set X-Frame-Options or CSP's frame-ancestors
• Some defenses are built-in by default
• Cross-Origin Read Blocking (CORB) – prevents potentially sensitive response
(HTML, JSON, XML) to be in the same renderer as the including document
Was originally implemented as a defense against Spectre
• Soon: SameSite cookies
• Soon: cache partitioning – entries in HTTP cache are bound to top
document location (prevents attacker from detecting if a certain resource
was cached)
43
XS-Leaks defenses
• Browser may give information on the nature of the request
• Sec-Fetch Metadata: detect illegimate requests
• Block such requests or return other content
• Certain mechanisms require opt-in from the server
• Cross-Origin Opener Policy (COOP) – drops reference to opened
window, so attacks using window.open no longer work
• Cross-Origin Resource Policy (CORP) – same-site | same-origin | cross-
site; similar to CORB: block no-cors cross-origin/cross-site requests
Sec-Fetch-Dest: image
Sec-Fetch-Mode: no-cors
Sec-Fetch-Site: cross-site
44
XS-Leaks defenses overviews
• What can I do (as a web developer)?
• Use SameSite attribute on cookies
• Prevent framing (X-Frame-Options/CSP frame-ancestors)
• Send Cross-Origin-Opener-Policy: same-origin (should be adopted by
several browsers soon)
• What can I do (as a user)?
• Avoid the evil bunnies?
• Separate contexts (e.g. incognito; containers extension in Firefox)
45
Conclusion
46
Conclusion
• Responses often depend on the state of the user
• XS-Leaks can be used to extract side-channel information on
response
• Can be used to differentiate two responses
• Leaks information on the state of the user (# search results, identity, …)
• When browser loads a resource, it undergoes a series of state
changes
• Pattern of state changes leaks the information
• Defenses: SameSite cookies, XFO, new mechanisms coming soon
Questions?
@tomvangoethem
1 of 45

Recommended

Http requesting smuggling by
Http requesting smugglingHttp requesting smuggling
Http requesting smugglingApijay Kumar
2.5K views41 slides
ZN27112015 by
ZN27112015ZN27112015
ZN27112015Denis Kolegov
2.7K views14 slides
2016 JavaOne Deconstructing REST Security by
2016 JavaOne Deconstructing REST Security2016 JavaOne Deconstructing REST Security
2016 JavaOne Deconstructing REST SecurityDavid Blevins
1K views80 slides
2017 dev nexus_deconstructing_rest_security by
2017 dev nexus_deconstructing_rest_security2017 dev nexus_deconstructing_rest_security
2017 dev nexus_deconstructing_rest_securityDavid Blevins
1K views82 slides
2018 ecuador deconstruyendo y evolucionando la seguridad en servicios rest by
2018 ecuador deconstruyendo y evolucionando la seguridad en servicios rest2018 ecuador deconstruyendo y evolucionando la seguridad en servicios rest
2018 ecuador deconstruyendo y evolucionando la seguridad en servicios restCésar Hernández
87 views105 slides
Shmoocon Epilogue 2013 - Ruining security models with SSH by
Shmoocon Epilogue 2013 - Ruining security models with SSHShmoocon Epilogue 2013 - Ruining security models with SSH
Shmoocon Epilogue 2013 - Ruining security models with SSHAndrew Morris
718 views34 slides

More Related Content

What's hot

Cache poisoning by
Cache poisoningCache poisoning
Cache poisoningAlexandraLacatus
2.7K views11 slides
Flaying the Blockchain Ledger for Fun, Profit, and Hip Hop by
Flaying the Blockchain Ledger for Fun, Profit, and Hip HopFlaying the Blockchain Ledger for Fun, Profit, and Hip Hop
Flaying the Blockchain Ledger for Fun, Profit, and Hip HopAndrew Morris
1.8K views105 slides
DEF CON 27 - WENXIANG QIAN and YUXIANG LI HUIYU - breaking google home exploi... by
DEF CON 27 - WENXIANG QIAN and YUXIANG LI HUIYU - breaking google home exploi...DEF CON 27 - WENXIANG QIAN and YUXIANG LI HUIYU - breaking google home exploi...
DEF CON 27 - WENXIANG QIAN and YUXIANG LI HUIYU - breaking google home exploi...Felipe Prado
81 views55 slides
DNS over HTTPS by
DNS over HTTPSDNS over HTTPS
DNS over HTTPSDaniel Stenberg
2K views38 slides
BlueHat v17 || Dyre to Trickbot: An Inside Look at TLS-Encrypted Command-And-... by
BlueHat v17 || Dyre to Trickbot: An Inside Look at TLS-Encrypted Command-And-...BlueHat v17 || Dyre to Trickbot: An Inside Look at TLS-Encrypted Command-And-...
BlueHat v17 || Dyre to Trickbot: An Inside Look at TLS-Encrypted Command-And-...BlueHat Security Conference
812 views41 slides
Derbycon - The Unintended Risks of Trusting Active Directory by
Derbycon - The Unintended Risks of Trusting Active DirectoryDerbycon - The Unintended Risks of Trusting Active Directory
Derbycon - The Unintended Risks of Trusting Active DirectoryWill Schroeder
35.9K views51 slides

What's hot(20)

Flaying the Blockchain Ledger for Fun, Profit, and Hip Hop by Andrew Morris
Flaying the Blockchain Ledger for Fun, Profit, and Hip HopFlaying the Blockchain Ledger for Fun, Profit, and Hip Hop
Flaying the Blockchain Ledger for Fun, Profit, and Hip Hop
Andrew Morris1.8K views
DEF CON 27 - WENXIANG QIAN and YUXIANG LI HUIYU - breaking google home exploi... by Felipe Prado
DEF CON 27 - WENXIANG QIAN and YUXIANG LI HUIYU - breaking google home exploi...DEF CON 27 - WENXIANG QIAN and YUXIANG LI HUIYU - breaking google home exploi...
DEF CON 27 - WENXIANG QIAN and YUXIANG LI HUIYU - breaking google home exploi...
Felipe Prado81 views
BlueHat v17 || Dyre to Trickbot: An Inside Look at TLS-Encrypted Command-And-... by BlueHat Security Conference
BlueHat v17 || Dyre to Trickbot: An Inside Look at TLS-Encrypted Command-And-...BlueHat v17 || Dyre to Trickbot: An Inside Look at TLS-Encrypted Command-And-...
BlueHat v17 || Dyre to Trickbot: An Inside Look at TLS-Encrypted Command-And-...
Derbycon - The Unintended Risks of Trusting Active Directory by Will Schroeder
Derbycon - The Unintended Risks of Trusting Active DirectoryDerbycon - The Unintended Risks of Trusting Active Directory
Derbycon - The Unintended Risks of Trusting Active Directory
Will Schroeder35.9K views
Apache httpd 2.4 Reverse Proxy by Jim Jagielski
Apache httpd 2.4 Reverse ProxyApache httpd 2.4 Reverse Proxy
Apache httpd 2.4 Reverse Proxy
Jim Jagielski193.1K views
Carlos García - Pentesting Active Directory [rooted2018] by RootedCON
Carlos García - Pentesting Active Directory [rooted2018]Carlos García - Pentesting Active Directory [rooted2018]
Carlos García - Pentesting Active Directory [rooted2018]
RootedCON11.6K views
2017 JavaOne Deconstructing and Evolving REST Security by David Blevins
2017 JavaOne Deconstructing and Evolving REST Security2017 JavaOne Deconstructing and Evolving REST Security
2017 JavaOne Deconstructing and Evolving REST Security
David Blevins1.1K views
Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names... by OpenDNS
Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...
Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...
OpenDNS8.7K views
Http response splitting by Sharath Unni
Http response splittingHttp response splitting
Http response splitting
Sharath Unni3.4K views
Covert Timing Channels using HTTP Cache Headers by Denis Kolegov
Covert Timing Channels using HTTP Cache HeadersCovert Timing Channels using HTTP Cache Headers
Covert Timing Channels using HTTP Cache Headers
Denis Kolegov2.4K views
External to DA, the OS X Way by Stephan Borosh
External to DA, the OS X WayExternal to DA, the OS X Way
External to DA, the OS X Way
Stephan Borosh6.8K views
Carlos García - Pentesting Active Directory Forests [rooted2019] by RootedCON
Carlos García - Pentesting Active Directory Forests [rooted2019]Carlos García - Pentesting Active Directory Forests [rooted2019]
Carlos García - Pentesting Active Directory Forests [rooted2019]
RootedCON4.5K views
End-to-End Analysis of a Domain Generating Algorithm Malware Family by CrowdStrike
End-to-End Analysis of a Domain Generating Algorithm Malware FamilyEnd-to-End Analysis of a Domain Generating Algorithm Malware Family
End-to-End Analysis of a Domain Generating Algorithm Malware Family
CrowdStrike9K views
Modern Reconnaissance Phase on APT - protection layer by Shakacon
Modern Reconnaissance Phase on APT - protection layerModern Reconnaissance Phase on APT - protection layer
Modern Reconnaissance Phase on APT - protection layer
Shakacon789 views

Similar to Side-Channels on the Web: Attacks and Defenses

Help, my browser is leaking! Exploring XSLeaks attacks and defenses - Tom Van... by
Help, my browser is leaking! Exploring XSLeaks attacks and defenses - Tom Van...Help, my browser is leaking! Exploring XSLeaks attacks and defenses - Tom Van...
Help, my browser is leaking! Exploring XSLeaks attacks and defenses - Tom Van...NoNameCon
117 views72 slides
[OPD 2019] Side-Channels on the Web:
Attacks and Defenses by
[OPD 2019] Side-Channels on the Web:
Attacks and Defenses[OPD 2019] Side-Channels on the Web:
Attacks and Defenses
[OPD 2019] Side-Channels on the Web:
Attacks and DefensesOWASP
198 views48 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
Openstack meetup lyon_2017-09-28 by
Openstack meetup lyon_2017-09-28Openstack meetup lyon_2017-09-28
Openstack meetup lyon_2017-09-28Xavier Lucas
118 views31 slides
HTML5 hacking by
HTML5 hackingHTML5 hacking
HTML5 hackingBlueinfy Solutions
3.1K views84 slides
Http requesting smuggling by
Http requesting smugglingHttp requesting smuggling
Http requesting smugglingApijay Kumar
2.3K views41 slides

Similar to Side-Channels on the Web: Attacks and Defenses(20)

Help, my browser is leaking! Exploring XSLeaks attacks and defenses - Tom Van... by NoNameCon
Help, my browser is leaking! Exploring XSLeaks attacks and defenses - Tom Van...Help, my browser is leaking! Exploring XSLeaks attacks and defenses - Tom Van...
Help, my browser is leaking! Exploring XSLeaks attacks and defenses - Tom Van...
NoNameCon117 views
[OPD 2019] Side-Channels on the Web:
Attacks and Defenses by OWASP
[OPD 2019] Side-Channels on the Web:
Attacks and Defenses[OPD 2019] Side-Channels on the Web:
Attacks and Defenses
[OPD 2019] Side-Channels on the Web:
Attacks and Defenses
OWASP198 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
Openstack meetup lyon_2017-09-28 by Xavier Lucas
Openstack meetup lyon_2017-09-28Openstack meetup lyon_2017-09-28
Openstack meetup lyon_2017-09-28
Xavier Lucas118 views
Http requesting smuggling by Apijay Kumar
Http requesting smugglingHttp requesting smuggling
Http requesting smuggling
Apijay Kumar2.3K views
HTTP cookie hijacking in the wild: security and privacy implications by Priyanka Aash
HTTP cookie hijacking in the wild: security and privacy implicationsHTTP cookie hijacking in the wild: security and privacy implications
HTTP cookie hijacking in the wild: security and privacy implications
Priyanka Aash1.1K views
Websocket vs SSE - Paris.js - 24/06/15 by streamdata.io
Websocket vs SSE - Paris.js - 24/06/15Websocket vs SSE - Paris.js - 24/06/15
Websocket vs SSE - Paris.js - 24/06/15
streamdata.io1.4K views
Krzysztof Kotowicz - Hacking HTML5 by DefconRussia
Krzysztof Kotowicz - Hacking HTML5Krzysztof Kotowicz - Hacking HTML5
Krzysztof Kotowicz - Hacking HTML5
DefconRussia9.3K views
Html5 security by Krishna T
Html5 securityHtml5 security
Html5 security
Krishna T2.6K views
Helen Tabunshchyk "Handling large amounts of traffic on the Edge" by Fwdays
Helen Tabunshchyk "Handling large amounts of traffic on the Edge"Helen Tabunshchyk "Handling large amounts of traffic on the Edge"
Helen Tabunshchyk "Handling large amounts of traffic on the Edge"
Fwdays167 views
Cdn technology overview by Yoohyun Kim
Cdn technology overviewCdn technology overview
Cdn technology overview
Yoohyun Kim93 views
Multi-Layer DDoS Mitigation Strategies by Logan Best
Multi-Layer DDoS Mitigation StrategiesMulti-Layer DDoS Mitigation Strategies
Multi-Layer DDoS Mitigation Strategies
Logan Best349 views
Introduction to Ethereum by Arnold Pham
Introduction to EthereumIntroduction to Ethereum
Introduction to Ethereum
Arnold Pham1.4K views
Hacking HTML5 offensive course (Zeronights edition) by Krzysztof Kotowicz
Hacking HTML5 offensive course (Zeronights edition)Hacking HTML5 offensive course (Zeronights edition)
Hacking HTML5 offensive course (Zeronights edition)
Krzysztof Kotowicz4.2K views
Multi-Layer DDoS Mitigation Strategies by Sagi Brody
Multi-Layer DDoS Mitigation StrategiesMulti-Layer DDoS Mitigation Strategies
Multi-Layer DDoS Mitigation Strategies
Sagi Brody3.2K views

Recently uploaded

hamro digital logics.pptx by
hamro digital logics.pptxhamro digital logics.pptx
hamro digital logics.pptxtupeshghimire
11 views36 slides
ARNAB12.pdf by
ARNAB12.pdfARNAB12.pdf
ARNAB12.pdfArnabChakraborty499766
5 views83 slides
ATPMOUSE_융합2조.pptx by
ATPMOUSE_융합2조.pptxATPMOUSE_융합2조.pptx
ATPMOUSE_융합2조.pptxkts120898
35 views70 slides
How to think like a threat actor for Kubernetes.pptx by
How to think like a threat actor for Kubernetes.pptxHow to think like a threat actor for Kubernetes.pptx
How to think like a threat actor for Kubernetes.pptxLibbySchulze1
7 views33 slides
Affiliate Marketing by
Affiliate MarketingAffiliate Marketing
Affiliate MarketingNavin Dhanuka
20 views30 slides
WITS Deck by
WITS DeckWITS Deck
WITS DeckW.I.T.S.
27 views22 slides

Recently uploaded(10)

Side-Channels on the Web: Attacks and Defenses

  • 1. Side-Channels on the Web: Attacks and Defenses Tom Van Goethem @tomvangoethem
  • 6. What can the bunnies (attackers) do?
  • 7. 7 Attacker model • Cross-origin attack (evil-bunnies.net vs. cute-kittens.com) • Subject to Same-Origin-Policy • Can't extract information directly • Attacker infers information based on state of victim at target site • Logged in or not? • Search query has results? • Launch cross-site requests; can't access response directly • Attack needs to exploit side-channel leaks
  • 10. https://evil-bunnies.net https://cute-kittens.com (1) visit malicious site (2) return malicious JS (3) probe affected resources
  • 11. https://evil-bunnies.net https://cute-kittens.com (1) visit malicious site (2) return malicious JS (3) probe affected resources (4) return user-specific response
  • 12. https://evil-bunnies.net https://cute-kittens.com (1) visit malicious site (2) return malicious JS (3) probe affected resources (4) return user-specific response (5) use side-channel to infer information about response
  • 13. 13 Response size may leak information about user state ~183kB
  • 14. 14 Response size may leak information about user state ~19kB ~183kB
  • 15. 15 Nethanel Gelernter and Amir Herzberg. "Cross-site search attacks." Proceedings of the 22nd ACM SIGSAC Conference on Computer and Communications Security (CCS). ACM, 2015.
  • 16. 16 Nethanel Gelernter and Amir Herzberg. "Cross-site search attacks." Proceedings of the 22nd ACM SIGSAC Conference on Computer and Communications Security (CCS). ACM, 2015.
  • 17. 17
  • 18. 18 XS-Leaks • Server generates response based on user's state • Attacker tries to differentiate between two responses • Examples • Logged in (=> large response) vs. not logged in (=> small response) • User has access to resource (=> 200) vs. no access (=> 404) • Was used to uniquely identify users by giving them access to attacker-controlled resources [1] • Search query has results (=> response with iframe) vs. no results (=> no iframe) [1] Cristian-Alexandru Staicu and Michael Pradel. " Leaky Images: Targeted Privacy Attacks in the Web". Proceedings of the 28th USENIX Security Symposium, 2019.
  • 20. time https://cute-kittens.com state_0 state_nstate_1 state_1: browser initiated connection to target site 1 fewer connection available in pool (e.g. 255 in Chrome) => infer whether endpoint includes resource to certain site
  • 21. time https://cute-kittens.com state_0 state_nstate_1 state_2 state_1: browser initiated connection to target site state_2: headers of response are received 1 fewer connection available in pool (e.g. 255 in Chrome) => infer whether endpoint includes resource to certain site Promise returned by fetch() resolved => measure time to generate response + delay/jitter (Tstate_2 - Tstate_1)
  • 22. time https://cute-kittens.com state_0 state_nstate_1 state_2 state_3 state_1: browser initiated connection to target site state_2: headers of response are received state_3: complete response body received 1 fewer connection available in pool (e.g. 255 in Chrome) => infer whether endpoint includes resource to certain site Promise returned by fetch() resolved => measure time to generate response + delay/jitter (Tstate_2 - Tstate_1) Time returned by Resource Timing API (performance.getEntries()) => measure time to download response (Tstate_3 - Tstate_2)
  • 23. time https://cute-kittens.com state_0 state_nstate_1 state_2 state_3 state_1: browser initiated connection to target site state_2: headers of response are received state_3: complete response body received state_4 state_4: browser cached response 1 fewer connection available in pool (e.g. 255 in Chrome) => infer whether endpoint includes resource to certain site Promise returned by fetch() resolved => measure time to generate response + delay/jitter (Tstate_2 - Tstate_1) Time returned by Resource Timing API (performance.getEntries()) => measure time to download response (Tstate_3 - Tstate_2) Resource added to HTTP cache; can be requested w/o connection => infer which resources were cached
  • 25. 25 HEIST • Determine exact response size (compressed) • 1 TCP window = 10 TCP packets = 14480 bytes of data • 2nd TCP window can only start after ACK (→ additional round-trip needed) • Response fits in 1 TCP window → 1 RTT, otherwise 2+ RTTs • Use side-channel to detect when first byte is received fetch() promise resolves • Use side-channel to detect when full response is received Resource Timing API • Timing difference < 5ms? Then 1 TCP window, otherwise 2 TCP windows 12
  • 28. 1st TCP window fetch() resolves PerformanceEntry Timing difference
  • 31. 1st TCP window ACK … 2nd TCP window fetch() resolves Timing difference (much bigger) PerformanceEntry
  • 32. 32 • Important prerequisite: reflection of request in response Needed to align on TCP window size • Needs some “window-tuning” for larger responses • Exact size is known after compression Allows for BREACH-like attack Extract secret information such as CSRF token • More information: see whitepaper https://tom.vg/papers/heist_blackhat2016.pdf HEIST
  • 33. time https://messenger.com/t/<fb_id> state_0 state_n state_1 state_2 state_3 state_1: browser parsed response HTML win.frames.length == 3 state_2: JavaScript replaces iframe ONLY IF user has had contact with <facebook_id> win.frames.length == 2 state_3: iframe has been replaced win.frames.length == 3 const win = window.opener; win.location = `https://messenger.com/t/${facebookID}`; Credits: Ron Masas - http://ronmasas.com/posts/facebook-messenger-vulnerability/
  • 34. 34 Browser state changes • As soon as a resource is requested, the browser will transition between different “states” • These state changes can be permanent or temporary • Permanent: frame is added to included web page • Temporary: load event is fired • Time and order when state changes occur can be important
  • 35. 35 Detecting browser state changes • Two different responses can result in two different state change patterns • Strict requirement for performing practical XS-Leak attack • Attacker includes target endpoint as a resource • E.g. iframe (if no X-Frame-Options + needs rendering) • E.g. window.open (in case of XFO + needs rendering) • E.g. <img>.src (in case no rendering required) • Attacker observes properties/events/… associated with the included resource • E.g. frames.length • May need more advanced resource operations • E.g. first load resource X, then load resource Y
  • 36. 38 XS-Leaks overview • Response size • Timing network connections • Browser-based timing attack (<video>, Cache API, AppCache) • Storage API (fixed , reintroduced for small disk devices, fixed again) • HEIST (TCP level) • Response status • Application Cache (error when resource redirects) • history.length (+1 in case resource redirected) • Resource Timing (difference between start and fetchStart property) • CSP (policy set by attacker, violation in case of redirect to other domain)
  • 37. 39 XS-Leaks overview (2) • Cache status • AppCache (Cache-control: no-store resources cause error) • Timing (cached resources load much faster) • Resource content and operations • frames.length (for iframe or new opened window) • postMessage() to parent page (may contain sensitive content) • Event loop (spy on pattern of other processes) • Navigate to id (triggers blur event on attacker page) • More techniques likely to be discovered • Check out https://github.com/xsleaks/xsleaks/
  • 39. 41 XS-Leaks defenses • Two main approaches 1. Prevent differences in responses 2. Prevent attacker from observing state-changes • Often a combination of both approaches • (1) is purely a server-side effort • (2) is often controlled by response headers that instruct browser • Using SameSite cookies can be very effective • Defends against all attacks except for those based on window.open
  • 40. 42 XS-Leaks defenses • Different attack techniques may require different defenses • iframe attacks: set X-Frame-Options or CSP's frame-ancestors • Some defenses are built-in by default • Cross-Origin Read Blocking (CORB) – prevents potentially sensitive response (HTML, JSON, XML) to be in the same renderer as the including document Was originally implemented as a defense against Spectre • Soon: SameSite cookies • Soon: cache partitioning – entries in HTTP cache are bound to top document location (prevents attacker from detecting if a certain resource was cached)
  • 41. 43 XS-Leaks defenses • Browser may give information on the nature of the request • Sec-Fetch Metadata: detect illegimate requests • Block such requests or return other content • Certain mechanisms require opt-in from the server • Cross-Origin Opener Policy (COOP) – drops reference to opened window, so attacks using window.open no longer work • Cross-Origin Resource Policy (CORP) – same-site | same-origin | cross- site; similar to CORB: block no-cors cross-origin/cross-site requests Sec-Fetch-Dest: image Sec-Fetch-Mode: no-cors Sec-Fetch-Site: cross-site
  • 42. 44 XS-Leaks defenses overviews • What can I do (as a web developer)? • Use SameSite attribute on cookies • Prevent framing (X-Frame-Options/CSP frame-ancestors) • Send Cross-Origin-Opener-Policy: same-origin (should be adopted by several browsers soon) • What can I do (as a user)? • Avoid the evil bunnies? • Separate contexts (e.g. incognito; containers extension in Firefox)
  • 44. 46 Conclusion • Responses often depend on the state of the user • XS-Leaks can be used to extract side-channel information on response • Can be used to differentiate two responses • Leaks information on the state of the user (# search results, identity, …) • When browser loads a resource, it undergoes a series of state changes • Pattern of state changes leaks the information • Defenses: SameSite cookies, XFO, new mechanisms coming soon