1 00:00:00,000 --> 00:00:07,260 Hello, hello, and welcome to HTTP 1.1 Must Die, the desync endgame. 2 00:00:08,340 --> 00:00:13,160 Have you ever had a good thing that went a bit too far? 3 00:00:13,160 --> 00:00:16,400 Maybe you got more than you bargained for. 4 00:00:16,500 --> 00:00:24,520 This is the fourth year that I've spent researching HTTP desync attacks, and so I thought I knew what I was going to find. 5 00:00:24,520 --> 00:00:38,380 The plan was to neatly wrap up a well-understood attack class, by finding some weird bugs and niche flaws in obscure systems, the long tail of desync attacks. 6 00:00:38,440 --> 00:00:45,100 But what I actually discovered changed both my perspective and the title of this presentation. 7 00:00:46,100 --> 00:01:02,980 So today, in this session, I'm going to share tools and techniques to enable you to embrace the never-ending horror of HTTP 1.1, navigate the desync endgame, and convince the rest of the world that it's time for HTTP 1 to die. 8 00:01:03,220 --> 00:01:11,220 This started back in 2019, when I realized that H1 has a fatal flaw. 9 00:01:11,220 --> 00:01:17,120 The isolation between individual HTTP requests is fundamentally broken. 10 00:01:17,120 --> 00:01:24,000 There's no single reliable way to tell where one request finishes and the next request starts. 11 00:01:24,000 --> 00:01:34,920 So an attacker who finds the tiniest parser discrepancy between the frontend and backend server can cause a desync, enabling complete site takeover. 12 00:01:35,620 --> 00:01:46,420 And with HTTP 1 being an old, lenient, text-based protocol with thousands of different implementations, finding parser discrepancies was not hard. 13 00:01:46,420 --> 00:01:52,580 At the time, it felt like you could hack pretty much any website you wanted to. 14 00:01:52,580 --> 00:02:01,560 For example, I was able to show this could be exploited to get persistent control over PayPal's login page twice. 15 00:02:02,200 --> 00:02:04,580 But we knew what the solution was. 16 00:02:04,580 --> 00:02:13,580 If we deployed HTTP 2 for the upstream connection between the frontend and backend, then we could almost eliminate the entire attack class. 17 00:02:14,440 --> 00:02:17,440 So six years later, what actually happened? 18 00:02:17,440 --> 00:02:19,580 Well, we didn't do that. 19 00:02:19,580 --> 00:02:32,500 We have started using H2 for the connection between the client and the frontend, but then most servers just downgrade that request to H1 to talk to the backend, and that conversion actually makes the threat worse. 20 00:02:33,520 --> 00:02:38,060 And then because we could see, well, okay, maybe that's not ideal. 21 00:02:38,060 --> 00:02:40,180 Yes, some things are getting hacked. 22 00:02:40,180 --> 00:02:45,380 We decided to bolt on the ultimate security measure, regular expressions. 23 00:02:46,260 --> 00:02:49,280 The result is a mess. 24 00:02:49,280 --> 00:02:52,740 Here's a classic desync detection probe. 25 00:02:52,740 --> 00:03:04,820 You send two requests, and if the target is vulnerable, the first one poisons the connection to the backend, so the second request gets prefixed with the text shown in orange. 26 00:03:05,460 --> 00:03:14,180 Now, if you try this technique on a modern site, chances are the attack will fail even if they're actually vulnerable. 27 00:03:14,180 --> 00:03:24,320 That's because it will get blocked by multiple regular expressions, or the gadget might not work on that target, or it might get missed due to the race condition involved in that technique as well. 28 00:03:24,360 --> 00:03:31,920 And there's an alternative timeout-based approach that avoids the race condition issue, but it gets blocked by even more regular expressions. 29 00:03:32,880 --> 00:03:39,680 So to summarize, over the last six years, the industry has patched the detection methodology. 30 00:03:39,680 --> 00:03:45,740 They've patched the scanning tools, they haven't fixed the actual vulnerability. 31 00:03:46,060 --> 00:03:56,420 This has created the desync end game where everything looks secure until you make the tiniest change to your approach. 32 00:03:56,420 --> 00:03:59,140 Let's take a look at an example. 33 00:03:59,680 --> 00:04:08,600 A few months ago, I got an email from Vans saying he'd found a puzzling vulnerability and would like to know my thoughts about what was happening. 34 00:04:08,600 --> 00:04:14,000 The attack that he was trying to do was a pretty standard technique. 35 00:04:14,000 --> 00:04:25,660 You send a request that looks like this, gets downgraded to H1, poisons the connection to the back end, and the next person to access the affected site gets redirected to his server. 36 00:04:26,140 --> 00:04:36,800 And that redirection would get saved in a cache, enabling persistent cache poisoning of JavaScript files and giving persistent control over every page on the site. 37 00:04:37,400 --> 00:04:50,780 And the attack was working absolutely fine except for one small thing, which is that the users that we were seeing being hijacked weren't actually trying to access the target website. 38 00:04:50,780 --> 00:04:57,820 They were trying to access random other websites, including things like banks, which is a bit weird. 39 00:04:58,300 --> 00:05:02,560 So, clearly, the server setup doesn't look like this. 40 00:05:02,560 --> 00:05:22,280 And after seeing what infrastructure the target site was on, my first guess was that this was a desync between the CloudFlare front end and Heroku's reverse proxy, which would mean we were exploiting random websites hosted on the Heroku platform. 41 00:05:22,980 --> 00:05:27,860 And that was plausible, but actually completely wrong. 42 00:05:27,860 --> 00:05:29,680 It's not that simple. 43 00:05:29,940 --> 00:05:40,520 So, I realized this when I tried to replicate his attack and went, hang on, this attack is getting blocked by CloudFlare's cache. 44 00:05:40,520 --> 00:05:43,980 So, the attack isn't actually reaching the backend server. 45 00:05:43,980 --> 00:05:46,820 So, there's no way that this could possibly work. 46 00:05:46,920 --> 00:05:51,300 But when I corrected his mistake, the attack stopped working. 47 00:05:51,440 --> 00:05:55,340 And I replied back in an email and said, it's not working for me. 48 00:05:55,340 --> 00:05:56,760 And he said, are you sure? 49 00:05:56,760 --> 00:06:03,460 And I went back and I tried his broken version of the attack and it actually worked fine when you did it like that. 50 00:06:03,460 --> 00:06:09,340 So, what that means is that Heroku has nothing to do with this. 51 00:06:09,340 --> 00:06:18,180 There was a period of time during which if you tested any website on CloudFlare and you did it correctly, you wouldn't find anything. 52 00:06:18,180 --> 00:06:32,760 But if you forgot to specify a cache buster, well, then you'd cause a desync inside CloudFlare's own infrastructure, enabling you to persistently compromise almost every website using CloudFlare. 53 00:06:32,820 --> 00:06:35,800 This is the desync endgame. 54 00:06:35,800 --> 00:06:43,260 Everything looks secure, but if you do one slightly wrong, you can end up hacking 24 million websites. 55 00:06:44,900 --> 00:06:46,960 How do bugs like that even happen? 56 00:06:46,960 --> 00:06:53,500 Well, partly it's the excessive complexity of the systems involved. 57 00:06:53,500 --> 00:07:07,400 For example, in this case, we know CloudFlare is receiving a request over H2, converting it to H1 for internal use and then converting it back to H2 again to talk to the upstream, which is obviously not ideal. 58 00:07:07,400 --> 00:07:12,540 But the underlying problem comes from the foundation. 59 00:07:13,200 --> 00:07:24,300 There's this idea that HTTP 1 is a simple protocol and that makes it a secure foundation for whatever arbitrarily complex system you want to build. 60 00:07:24,300 --> 00:07:30,780 But the truth is that as soon as you start to proxy H1, it gets really quite complex. 61 00:07:31,200 --> 00:07:41,840 To illustrate that, here's five lies that I used to personally believe and every one of these is going to be used for an exploit in this presentation. 62 00:07:44,240 --> 00:08:08,800 When combined, the last three lies here taken together mean that your proxy needs state just to read in the correct number of bytes off the TCP socket from the backend server and you need special casing just to read in the headers before you even get to the body and the entire response may arrive before you've even received the complete request from the client. 63 00:08:09,300 --> 00:08:10,900 This is HTTP 1. 64 00:08:10,900 --> 00:08:22,620 It's the foundation of the web and it's composed of landmines that routinely expose millions of websites and we've spent six years demonstrating that we're not able to fix it. 65 00:08:22,620 --> 00:08:24,500 It needs to die. 66 00:08:24,920 --> 00:08:27,320 So, how do we kill it? 67 00:08:27,560 --> 00:08:38,100 Well, we need to collectively show the world that HTTP 1.1 is insecure and that more desync attacks are always coming. 68 00:08:38,200 --> 00:08:41,340 And in the rest of this session, I'll show you how to do that. 69 00:08:41,700 --> 00:08:51,840 First, I'm going to introduce a new toolkit to handle the desync end game and then I'll introduce two entire new classes of attack exposing a few million more websites. 70 00:08:52,120 --> 00:09:03,080 Then I'll take a focused look at how we can escape this situation and wrap up and take some and take some questions at the back. 71 00:09:03,480 --> 00:09:08,500 Now, during this session, I'm going to be roughly following the research journey. 72 00:09:08,500 --> 00:09:15,640 So, towards the start, we're going to be gaining knowledge, but not very much by way of bug bounties. 73 00:09:15,640 --> 00:09:24,800 And then towards the end, as the knowledge that we've gained takes us further beyond the state of the art, things are going to rapidly get a lot more profitable. 74 00:09:25,420 --> 00:09:30,740 All bounties in this presentation were split equally between everyone involved. 75 00:09:30,740 --> 00:09:43,840 A hundred percent of my cut of the bounties has been doubled by Port Swigger and donated to a local charity and all vulnerabilities in named targets have been resolved. 76 00:09:45,220 --> 00:09:50,960 So, how do you win in the end game when there's regexes everywhere? 77 00:09:50,960 --> 00:09:57,020 Well, what you need is a reliable way to detect parser discrepancies. 78 00:09:57,100 --> 00:10:02,480 And back in 2021, in a presentation at Black Hat Europe, Daniel Thatcher gave us one. 79 00:10:02,480 --> 00:10:15,820 And I was so hyped by this talk that I took the concept and I implemented an extra powerful version in HTTP request smuggler version 3, which I've just released. 80 00:10:15,820 --> 00:10:22,820 This is an open source burp suite extension fully compatible with the free version. 81 00:10:22,840 --> 00:10:35,260 What it does is it uses a broad range of techniques to analyze and classify how the front end and back end are parsing the request and find discrepancies. 82 00:10:36,280 --> 00:10:51,580 For example, on this target, by looking at simply the status codes, we can see that if we use a space to mask a host header, then we get a unique result that's different to what we get if we just leave the host header out entirely. 83 00:10:51,580 --> 00:10:56,020 And just from that, we can infer that we found a parser discrepancy. 84 00:10:56,280 --> 00:11:07,100 This particular one I will call a visible hidden discrepancy because the masked header is visible to the front end but hidden from the back end. 85 00:11:07,720 --> 00:11:17,320 That scenario can usually be exploited to cause a CL0 desync simply by hiding the content length header as shown here. 86 00:11:17,960 --> 00:11:31,500 But crucially, if you run into any issues when you're trying to convert it into a desync like that, well, you can adapt and overcome those problems because you know the underlying flaw. 87 00:11:31,760 --> 00:11:37,060 For example, on a different target, they were blocking get requests when they had a body. 88 00:11:37,060 --> 00:11:42,120 But I was able to bypass that simply by switching the method to options. 89 00:11:42,120 --> 00:11:48,420 It's that kind of versatility that makes this detection approach so valuable. 90 00:11:49,100 --> 00:11:55,460 It also achieves pretty good coverage by combining different headers, permutations and strategies. 91 00:11:55,460 --> 00:12:11,580 For example, in this one here, we're still using the host header and we're still using a leading space to hide the host header but this time we're using a duplicate host header with a malformed value to reveal the issue. 92 00:12:11,580 --> 00:12:18,600 And in this example, that's revealed a desync on a web VPN used by a bank. 93 00:12:19,580 --> 00:12:23,860 This system even lets you predict vulnerabilities. 94 00:12:24,100 --> 00:12:31,540 For example, the RFC says you're allowed to accept a slash end by itself as a line terminator. 95 00:12:31,540 --> 00:12:37,020 And the tool has detected on this target, they're not doing that. 96 00:12:37,020 --> 00:12:44,800 Which means if you place that server behind an RFC compliant proxy, there's a good chance it will be vulnerable. 97 00:12:44,800 --> 00:12:51,600 And we were able to trace that issue back to the underlying library and a patch is on the way. 98 00:12:52,160 --> 00:12:58,140 The tool also flagged a whole load of servers running IIS behind Amazon's application load balancer. 99 00:12:58,520 --> 00:13:04,700 As you can infer from the server banners here, this discrepancy is a hidden visible one. 100 00:13:04,700 --> 00:13:07,280 So it's the opposite way around. 101 00:13:07,280 --> 00:13:10,920 It's the front end that doesn't see the masked header. 102 00:13:11,380 --> 00:13:16,060 Now, these targets are protected by AWS desync guardian. 103 00:13:16,060 --> 00:13:19,840 And when I saw that, I thought, oh, this thing's a bit of a pain to deal with. 104 00:13:19,840 --> 00:13:23,260 So I just put it on the shelf and thought I'd come back to it later. 105 00:13:23,940 --> 00:13:34,860 And while it sat on my shelf, Thomas Stacey independently discovered the same issue and bypassed desync guardian for a full exploit on those targets. 106 00:13:35,520 --> 00:13:44,580 The interesting thing is that even now that his bypass has been fixed, they haven't actually fixed the parser discrepancy. 107 00:13:44,580 --> 00:13:53,920 So these systems are still vulnerable to header injection and to patch that, you have to change a couple of settings on your front end. 108 00:13:54,060 --> 00:14:00,140 Now, when I saw that, I went to AWS and said, hang on, why don't you just change these settings by default? 109 00:14:00,140 --> 00:14:02,060 Why not make it secure by default? 110 00:14:02,700 --> 00:14:15,000 And they said, well, some of their clients are using ancient HTTP clients which send malformed requests and they couldn't possibly break those clients. 111 00:14:15,520 --> 00:14:19,420 So that's why things are vulnerable by default. 112 00:14:19,420 --> 00:14:27,840 Basically, when you use a cloud proxy, you're importing other people's technical debt into your own infrastructure. 113 00:14:29,100 --> 00:14:34,000 This finding is where things started to go off on a little bit of a tangent. 114 00:14:34,080 --> 00:14:39,620 And I'm quite sad I can't name it because we're going to be talking about this one target for the next ten minutes. 115 00:14:39,960 --> 00:14:42,900 It's another hidden visible scenario. 116 00:14:42,900 --> 00:14:47,480 And the obvious exploit of using transfer encoding doesn't work. 117 00:14:47,620 --> 00:14:53,380 So it forced me to ask, well, how do you cause a desync on this? 118 00:14:53,380 --> 00:14:57,000 What happens if you smuggle a content length header? 119 00:14:57,420 --> 00:15:03,980 That would be a zero CL desync and these are widely regarded as impossible. 120 00:15:04,100 --> 00:15:15,920 That's because when the front end doesn't see the content length header, it only forwards the header block to the back end and then the back end ends up timing out while waiting for the body to arrive. 121 00:15:16,460 --> 00:15:26,820 In other words, as soon as you try the attack, you get a server side deadlock, which is great for taking down servers, but not very useful for desync attacks. 122 00:15:28,120 --> 00:15:33,840 Last year, while researching timing attacks, I stumbled on the solution. 123 00:15:34,280 --> 00:15:49,900 Whenever I tried to time how long it would take to load a static file served by NGINX, I would get a negative time stamp because NGINX was responding to my request before I'd actually finished sending it. 124 00:15:50,140 --> 00:16:01,560 This was a massive nuisance at the time, but it showed that sometimes servers respond to incomplete requests, which is something that would let us escape this deadlock. 125 00:16:01,780 --> 00:16:07,420 However, the target isn't running NGINX, it's running IIS. 126 00:16:07,560 --> 00:16:13,340 So how do we make IIS respond early to our request? 127 00:16:16,180 --> 00:16:18,100 Documentation is a wonderful thing. 128 00:16:18,400 --> 00:16:21,120 And this is an example of why. 129 00:16:21,300 --> 00:16:32,840 On Windows, if you use one of the following names for a file or a folder, the operating system will think you're referring to a device driver or something like that and then just blow up. 130 00:16:32,880 --> 00:16:36,120 So what happens if you hit that path on a server? 131 00:16:36,400 --> 00:16:47,120 Well, you hit a special code path which makes the server respond early without waiting for the body to arrive, thereby escaping the deadlock. 132 00:16:47,380 --> 00:16:59,040 That means that when the next request arrives, the back end will chop some data off the start of the request and you'll probably get a 400 bad request response. 133 00:16:59,680 --> 00:17:05,260 Seeing this happen was quite an emotional moment for me for two key reasons. 134 00:17:05,260 --> 00:17:11,920 Firstly, I'd known about that slash con feature for over ten years. 135 00:17:11,920 --> 00:17:15,580 But this was the first time I'd actually been able to make use of it. 136 00:17:15,980 --> 00:17:32,340 And secondly, over the last six years, while researching desync attacks, I'd seen so many mysterious bad request responses that I actually made my tool report them as mystery 400 findings. 137 00:17:32,340 --> 00:17:38,340 And this was the moment when I realized that all of those findings were probably actually exploitable. 138 00:17:39,160 --> 00:17:47,700 So if you find a zero CL desync scenario, to make it work, the first thing you need is an early response gadget. 139 00:17:48,400 --> 00:17:54,380 Next up, we need to get beyond that bad, the bad request response to something more promising. 140 00:17:54,380 --> 00:18:07,220 And you can do that by nesting a second request line inside the header block of the second request and adjusting the content length of the first request to slice out the data before it. 141 00:18:07,600 --> 00:18:20,220 This proves that there's a zero CL desync, but it's not a realistic attack because our victim is not going to conveniently contain a payload to exploit themselves inside their own request. 142 00:18:20,760 --> 00:18:28,400 What we need is a way to add our payload to their request instead of just chopping bits off. 143 00:18:28,560 --> 00:18:32,180 And we can do that with a double desync. 144 00:18:32,220 --> 00:18:34,820 This is where things get a tiny bit complex. 145 00:18:34,820 --> 00:18:54,260 So this is a two-stage attack where the first request from the attacker causes a zero CL desync that weaponizes the second request that also comes from the attacker to cause a CL zero desync that means the third request from the victim gets exploited. 146 00:18:54,500 --> 00:19:15,800 This is the cleanest conceptual way to do it where you simply chop the headers off the second request but in practice this rarely actually works because front ends tend to inject extra headers to requests before forwarding them to the back end which makes all your length calculations incorrect. 147 00:19:16,540 --> 00:19:36,860 I'm releasing a script which works out the length of the injected header but unfortunately these headers often contain values like your IP address which means even if you can identify the offset your attack will work perfectly for you but then break as soon as you give it to someone else. 148 00:19:37,440 --> 00:19:40,240 Fortunately there's a better way. 149 00:19:41,160 --> 00:19:53,700 Most servers inject headers at the end of the header block so that means that if your payload starts before that your attack although it now looks quite ugly will be a lot more reliable. 150 00:19:53,820 --> 00:20:13,660 In this example here I'm just chaining the desync with a input reflection on the website to reveal the value of the injected header but by then chaining that with the head technique to merge two responses into one I was able to serve malicious JavaScript to random live users of the website. 151 00:20:14,280 --> 00:20:27,980 There was a race condition involved in this which caused me a huge amount of pain but basically it just meant the attack would work reliably as long as you were sending a few hundred requests per second. 152 00:20:28,820 --> 00:20:40,560 Now things got a bit involved there but the good news is we've just published a web security academy lab so you can practice that technique yourself on a live system for free. 153 00:20:40,960 --> 00:20:46,980 And in about a week's time I'll be attempting to do a live demo showing how to solve that lab. 154 00:20:47,920 --> 00:21:06,600 Now with that technique we were able to exploit a reasonable number of targets with the best payout coming from XNS and notably most of those targets were vulnerable because they had a web application firewall. 155 00:21:06,600 --> 00:21:13,660 They would have been secure if they had not deployed that web application firewall in front of their website. 156 00:21:15,100 --> 00:21:28,800 Now at this point I thought great we're done the desync threat is finally fully mapped and any future issues will be weird niche problems rather than big class breaks and I can finally start to research something else. 157 00:21:28,940 --> 00:21:33,460 This is a mistake that I make every single year. 158 00:21:33,680 --> 00:21:44,980 It took the next discovery for me to finally realize the truth which is that more desync attacks are always on the way. 159 00:21:46,660 --> 00:21:58,320 Back in 2022 I tried out exploiting the expect header but I didn't find anything but as it turns out I wasn't looking close enough. 160 00:21:58,620 --> 00:22:19,720 The first clue that the expect header is something special is that it instantly broke turbo intruder which is my HTTP client and fixing it introduced a ton of complexity and if something introduces complexity for a client or for a server it's always way worse for a proxy. 161 00:22:20,440 --> 00:22:28,580 Expect is supposed to break sending a request into a two-part process so the client can bail early in order to save bandwidth. 162 00:22:28,580 --> 00:22:37,660 No browsers support it but because it's in the RFC and has been since forever virtually all servers attempt to support it. 163 00:22:38,240 --> 00:22:52,420 But because it introduces statefulness into a core area of the logic that didn't previously need it, it raises a load of questions about edge cases and basically when you send this header things go wrong. 164 00:22:53,000 --> 00:23:10,180 For example on this site the head request which is a special case works fine and the expect header which is a special case works fine but you combine the two and the server forgets about the first special case, tries to read too many bytes from the backend server and deadlocks. 165 00:23:10,640 --> 00:23:27,700 Now that's the kind of flaw that you could predict but you'll also find some more unexpected discoveries such as the fact that on multiple different web servers if you send the expect header they just leak memory including secret keys. 166 00:23:28,040 --> 00:23:36,000 When I went to report that particular one I found they'd just deleted their bug bounty program which is not ideal. 167 00:23:37,320 --> 00:23:56,540 Now because the expect header triggers two header blocks and all other responses have one, it often breaks attempts by front end servers to strip sensitive headers in order to hide them from end users and thereby it reveals internal headers. 168 00:23:56,540 --> 00:24:08,580 And this technique works on everything on the Netlify CDN and when I went to report that to them they said this is actually a feature but they did pay me for it. 169 00:24:08,580 --> 00:24:13,160 But I don't think they fixed it so if you need any of those values it might come in useful. 170 00:24:14,200 --> 00:24:24,780 Now around this time I got a message from a small team of full time bounty hunters who had also noticed the expect header making interesting things happen. 171 00:24:25,280 --> 00:24:31,260 And this kind of made me panic because in general a research collision is not good news. 172 00:24:31,260 --> 00:24:40,600 In fact we lost a potential Defcon presentation this year on SAML exploitation thanks to a different research collision. 173 00:24:41,040 --> 00:24:54,580 But this issue hadn't been published yet and since I knew these people from their research on T0 request smuggling and they already knew the technique, I figured we might as well team up. 174 00:24:54,580 --> 00:25:01,040 With my help hopefully they'd make more money and with their help I should end up with more case studies. 175 00:25:01,180 --> 00:25:02,860 This was a good decision. 176 00:25:03,200 --> 00:25:12,600 We quickly found that by sending a normal valid expect header you get a zero CLD sync on a whole lot of targets. 177 00:25:12,600 --> 00:25:15,500 So I'm going to focus on two in particular. 178 00:25:16,120 --> 00:25:27,820 On this one, this was just a great interaction because T-Mobile gave us a $12,000 payout even though it only affected a single pre-production server. 179 00:25:28,500 --> 00:25:46,160 And on this target it only worked if you obfuscated the expect header value by adding a single character and the vulnerable domain holds the attachments to the vulnerability reports sent to GitLab's bug bounty program. 180 00:25:47,120 --> 00:25:50,340 Which obviously would be quite nice to see some of those, wouldn't it? 181 00:25:50,900 --> 00:25:55,580 So on this target we opted to go for response queue poisoning. 182 00:25:55,580 --> 00:26:10,860 This is a truly glorious attack where you smuggle two complete requests which makes the server lose track of which response is meant to go to who and just sends everyone random responses intended for other users. 183 00:26:11,280 --> 00:26:29,380 Now it can be quite hard on low traffic servers like that target but we persisted and after sending 27,000 requests we got access to someone else's private vulnerability report and a respectable $7,000 payout off GitLab. 184 00:26:30,240 --> 00:26:38,220 Using similar techniques elsewhere we got some really quite nice bounties that I can't talk about taking the total to over 100K. 185 00:26:38,700 --> 00:26:43,000 The expect header also causes CL0 desyncs. 186 00:26:43,000 --> 00:26:47,020 Basically if you send expect everything that might go wrong does. 187 00:26:47,260 --> 00:26:55,840 So this one affects every single website on our favorite, the Netlify CDN. 188 00:26:55,840 --> 00:27:08,880 And once again we've got response queue poisoning but this time it's affecting the entire CDN so it's hijacking a continuous stream of responses from over a million different websites. 189 00:27:09,440 --> 00:27:27,240 Now we found this vulnerability on a particular Netlify user that has their own bounty program but because we were hijacking responses from so many websites we couldn't actually get a response from that target which was a bit annoying because it meant we couldn't report it to them. 190 00:27:27,600 --> 00:27:33,980 And then the issue mysteriously stopped working so we said okay let's just report it to Netlify. 191 00:27:34,320 --> 00:27:43,420 And they said websites using Netlify are not in scope and didn't pay us anything which was a bit disappointing. 192 00:27:43,700 --> 00:27:57,420 And normally when I have a bad bounty experience I don't talk about it because it just distracts everyone from the technical content but this particular one is useful context as to something that happened shortly later. 193 00:27:58,820 --> 00:28:04,960 This is the last desync attack in this presentation and it's a special one. 194 00:28:05,080 --> 00:28:16,860 It gave us full control over auth.lastpass.com letting us serve content from entirely different websites on there and letting us their maximum bounty but there was more to it. 195 00:28:16,860 --> 00:28:21,420 This technique worked on a large number of websites. 196 00:28:22,120 --> 00:28:31,200 There's a few select sites where if you find that you can hack them you know that you're on to something really good. 197 00:28:31,640 --> 00:28:38,100 And with that technique there was significant evidence that we could have used it to hack example.com. 198 00:28:38,720 --> 00:28:45,160 This would have been seriously cool because I bet they get a lot of interesting traffic. 199 00:28:45,460 --> 00:28:55,380 Unfortunately they don't have a VDP or bounty program or anything like that so it would have been illegal to prove it and we will never know for sure. 200 00:28:55,540 --> 00:29:00,400 Hopefully I can persuade them to set one up and have another go next year. 201 00:29:01,260 --> 00:29:08,080 Now most of the targets were using the Akamai CDN so we kind of had a choice here. 202 00:29:08,080 --> 00:29:19,500 Should we report the vulnerability to every affected company individually or should we report it to Akamai only and if they react the same way as Netlify did, not get paid. 203 00:29:19,920 --> 00:29:22,660 You can probably guess which option was more appealing. 204 00:29:24,580 --> 00:29:33,060 It was a tricky decision for me because having a good relationship with a CDN over the long term is important. 205 00:29:33,340 --> 00:29:41,340 But when I collaborate with bounty hunters I want them to make more money as a result of working with me not less. 206 00:29:41,720 --> 00:29:48,720 So looking at the specifics of that finding I said to the bounty hunters, well you would have found this without me. 207 00:29:48,720 --> 00:29:58,340 So I'm going to sit this one out, you report it, don't put me on the report and I won't take a cut of the payouts. 208 00:29:58,500 --> 00:30:10,040 This is a decision that I still have somewhat mixed feelings about because they went on to earn over $200,000 from this issue. 209 00:30:11,400 --> 00:30:17,260 Overall the reports were well received but things didn't go entirely smoothly. 210 00:30:17,420 --> 00:30:36,380 It turned out that the vulnerability was actually fully inside Akamai's infrastructure so they just got hammered with support tickets from their clients and it seemed to be taking them a while to fix it and because it had been reported to so many different companies I got stressed about the technique potentially leaking before it was fixed. 211 00:30:36,720 --> 00:30:43,880 So I reached out to Akamai directly and got a $9,000 bounty in the process for that. 212 00:30:43,900 --> 00:30:53,740 But although they got a hot fix out for some clients quite fast it still took over 65 days from that point to fully resolve the vulnerability. 213 00:30:54,520 --> 00:31:08,980 Overall that one was quite a stressful experience but at least I got some good US dollar backed evidence of the dangers posed by HTTP 1.1 as it took the total bounties earned to over $350,000. 214 00:31:10,440 --> 00:31:17,140 So all the attacks I've shown you are exploiting implementation flaws. 215 00:31:17,140 --> 00:31:33,320 So it might seem weird to say that the solution is to delete the protocol but they all come from the same single protocol flaw which is the lack of robust request isolation. 216 00:31:33,600 --> 00:31:35,600 It's compounded by two key factors. 217 00:31:35,600 --> 00:31:49,740 One is that HTTP 1.1 is not simple if you're trying to proxy it and number two is that we basically don't want to patch HTTP 1.1 the right way because it would break support for legacy clients. 218 00:31:50,160 --> 00:31:57,040 These factors all just combine to mean exactly one thing which is that more desync attacks are always coming. 219 00:31:57,800 --> 00:32:01,480 To escape we need to use H2 or 3. 220 00:32:01,480 --> 00:32:04,380 It's not the perfect protocol by any means. 221 00:32:04,380 --> 00:32:13,100 It's obnoxiously complex and it's binary so you can't just read it but it doesn't have the fatal flaw. 222 00:32:13,100 --> 00:32:19,900 So what that means is that the inevitable implementation bugs are going to be much lower impact. 223 00:32:20,520 --> 00:32:24,620 Of course, don't use HB2 downgrading. 224 00:32:24,620 --> 00:32:26,600 That just makes everything worse. 225 00:32:27,040 --> 00:32:39,680 So to kill request smuggling, make sure your origin server supports H2 and then turn on upstream H2 on the front end and the protocol will just take care of everything else. 226 00:32:39,840 --> 00:32:45,220 Note that you do not need to turn off HB1 for clients. 227 00:32:45,660 --> 00:32:54,460 That's because those connections are not shared between different users which makes them significantly less dangerous. 228 00:32:55,140 --> 00:33:03,380 Unfortunately, some major players such as Nginx, Akamai, CloudFront and Fastly don't support upstream H2 yet. 229 00:33:03,380 --> 00:33:11,160 So if you're stuck on one of those, there's some other approaches you can take to try to mitigate these issues. 230 00:33:11,160 --> 00:33:16,960 But I do not regard any of these as adequate long term solutions. 231 00:33:16,960 --> 00:33:21,380 It's mostly about surviving until you can deploy H2. 232 00:33:21,700 --> 00:33:26,760 The only way to use H1 safely is don't have a front end server. 233 00:33:27,760 --> 00:33:34,680 We will be releasing more updates to request smuggler 3 as more techniques become known. 234 00:33:34,680 --> 00:33:40,340 So at least if you're doing regular scans with that, you'll find out relatively fast if you're exposed. 235 00:33:41,240 --> 00:33:44,280 Now, this is where I need your help. 236 00:33:44,680 --> 00:33:51,120 The number one problem that we've got is that people think upstream H1 is secure. 237 00:33:51,120 --> 00:33:55,120 So together, we need to show the world the truth. 238 00:33:55,120 --> 00:34:05,780 We need to show how broken it is by exploiting systems, breaking them and sharing our findings with the message that more desync attacks are coming. 239 00:34:06,020 --> 00:34:27,000 And because we're in the desync end game, and there's inevitably going to be future waves of regular expressions, regular expressions dedicated to breaking every detection method we can think of, take my tools and take techniques but adapt them. 240 00:34:27,000 --> 00:34:32,820 Make small changes and you'll discover a lot more vulnerabilities. 241 00:34:33,920 --> 00:34:39,300 For me, the key big research question is what's the next expect? 242 00:34:39,300 --> 00:34:45,260 What other features in HTTP 1.1 have serious desync potential? 243 00:34:45,320 --> 00:34:55,520 The cool thing about this question is that H1 is so poorly understood that there's actually tons to find even beyond the realm of desync attacks. 244 00:34:56,080 --> 00:35:04,200 For example, it's well known that you can use the trace method to leak internal headers if the back end supports it. 245 00:35:04,200 --> 00:35:07,280 But what if the back end has disabled trace? 246 00:35:07,800 --> 00:35:09,100 Does that mean they're secure? 247 00:35:09,100 --> 00:35:19,480 Well, unfortunately not because using the max forwards header, you can target an arbitrary intermediary server with that request instead. 248 00:35:19,480 --> 00:35:24,580 So unless they've configured every server in the chain, the technique still works. 249 00:35:24,580 --> 00:35:30,500 Basically, HTTP 1 is an absolute gold mine for all kinds of research. 250 00:35:31,180 --> 00:35:40,300 There's a whole load of further reading available online and you can find everything you need linked from http1mustdie.com. 251 00:35:40,300 --> 00:35:54,980 Note, this website is hosted on CloudFront and that means it is actually using upstream HTTP 1, but if you can get a desync on it, we will pay you a bonus on your bug bounty. 252 00:35:56,180 --> 00:36:00,780 The three key things to take away are that this is not the end. 253 00:36:00,780 --> 00:36:03,960 More desync attacks are always coming. 254 00:36:04,120 --> 00:36:12,000 If we want a secure web, HTTP 1 needs to die and together we can kill it. 255 00:36:13,860 --> 00:36:16,500 I'm also going to have some t-shirts to hand out. 256 00:36:16,760 --> 00:36:22,540 Don't forget to follow me on social media and if you have any more questions after that, feel free to chuck me an email. 257 00:36:22,720 --> 00:36:23,940 Thank you for listening.