All right. So, please join me in welcoming Alfonso and Alejo. Hi, DEF CON. Our presentation today is about TLS 1.3, which is going to be the next major version of TLS, which will be released soon. It has a new feature, which is called 0RTT, Zero Roundtrip Time Resumption, which speeds up the session resumption. However, it has some security impacts. This is a known issue that has been acknowledged by the protocol specification. So, our intent today is to give you a better understanding of TLS 1.3 and this new feature, 0RTT. Two, is to raise awareness across the audience about this new feature, about the potential risks of using 0RTT. And three, is to provide you recommendations about how to mitigate those risks of using 0RTT. Finally, a minor disclaimer. What we are going to discuss here is just our own opinion and does not reflect the view of our employer. Hi, DEF CON. My name is Alfonso Garcial Guazil. I work for Cisco as a senior security consultant. I mostly do penetration testing and some research and development focused on offensive security. And I'm glad to be here for the first time. Hi, my name is Aleho Mudriyo Moja. I am a senior security consultant at Cisco. I am the lead for EMIR, Europe Middle east African, Russia. I have more than ten years of experience in the security field, since the very first and as Fonso said, we are really happy to be here at DEF CON. So, once we have introduced ourselves, let's introduce TLS 1.3. So, first a bit of history. So, four years ago, a working group was created. And that working group had a mission. That mission was to develop the new version of TLS, TLS 1.3. There has been 28 iterations of the protocol specification. And as you can imagine, that has been a long journey. So, now with this introduction, let's move on to some of the good things that TLS is going to bring to us, 1.3. One of the good things is that it has followed a simple approach. So, only five ciphers are going to be defined in the TLS 1.3 specification. That means that the implementation is going to be easier and also that will reduce the complexity of the protocol. If we compare this to previous version of TLS, that's a huge improvement. Because if you recall, those previous versions support dozens of ciphers. Another good thing is that TLS 1.3 is not going to be vulnerable to previous known attacks against previous version of TLS. So, for example, you can think about RC4, RSA, CBC encryption mode or even compression attacks. Good luck finding them on TLS 1.3. Because you are not going to find them. Also another good thing is that it supports perfect forward secrecy by default. It's by default enabled. And that's something that is not going to be optional like on previous version of TLS. Just a quick recap about the forward secrecy. Imagine that an attacker is able to store all your secure communications. Perfect forward secrecy is going to ensure that even if the attacker managed to steal the server private keys, he wouldn't be able to decrypt your secure communications because ephemeral system keys were used. Also, the TLS 1.3 protocol went through some formal security analysis, which basically it took and the protocol specification, its machine state, its security assumption and those were analyzed and some witnesses were identified. With that information, the protocol was refined and improved before its final release. Let's talk now about the compatibility issues. So, last year, Chrome and Firefox were doing some field tests. And what they found is that around 5% of the users were not able to connect to the website using TLS 1.3. They analyzed the data and they found that that behavior was caused by something called middle boxes. A middle box is a corporate networking device that is inspecting or intercepting HTTP. What happened in the end is that they made some modifications to the protocol. Specifically, they changed the TLS 1.3 handshake in order to look like a TLS 1.2 session resumption. And that fixed the issues with the middle boxes. So, at the end, the protocol, it may not be as pure as it could be, but given the circumstances, I think it was the right thing to do. And let's focus on the topic for this conversation or this presentation. Sorry. So, one of the things the working group wanted to do is to have a faster TLS. And this is special important on mobile networks due to the latency. So, CRTT was created. CRTT is a session resumption that can push data to a server. Also called early data. data. Basically, from the importance of the 0RTT is that it should have a session ticket, the message and also the early data will be encrypted using a pre-shared key. And then when the server receives that message, if he can decrypt it, he will process that data. So it seems that 0RTT is making things faster because it's pushing data to the server. However, it has some security implications. So which are those security implications? The first one is that we lose perfect forward secrecy on 0RTT messages. And the second thing is that 0RTT messages could be vulnerable to replay attacks. Yes, and that's something really important. Because we know TLS and replay attacks was never one of our concerns. But that's going to change with 0RTT. So you may be wondering, hopefully I have convinced you of taking your attention on the previous slide. But maybe you can say that, okay, you're not going to use TLS 1.3 or that TLS is not yet an official internet standard, which is true. But, however, you should at least I will try to convince you because TLS is going to be present in your browser's implementations or even CDNs right now. So, for example, if we look at Firefox, you will see that Firefox has been supporting TLS. So, for example, if you look at Firefox, you will see that Firefox has been supporting TLS 1.3 and 0RTT by default for months. Also, Chrome is supporting TLS 1.3. If we move to the implementations, we can see that OpenSSL on the next version of OpenSSL, which is going to be 1.1.1, is on pre-release status and will support TLS 1.3 with 0RTT. Same goes for BoringSSL. And maybe you have heard the news, but Facebook has just released their own implementation of TLS 1.3. We will see that in the next version of OpenSSL. So, we are going to see that in the next version which also supports 0RTT. And then we have the CDNs and the CDNs may be supporting or planning to be supporting 0RTT also. Just going back a bit about their Facebook and their implementation, they mentioned that they are receiving around 50% of all the traffic that they are receiving is using TLS 1.3. Which is a lot. So, that means that TLS 1.3 is already with us and its use is going to be increased over time. So, we have to be upcoming weeks and months. So let's dig a bit more about TLS, specifically on the TLS 1.3 handshake. So first the client will send a client hello message to the server making some educated guesses about which options the server will prefer. The server will receive the message and then will send back the required cryptographic material in order to complete the handshake, including the certificate and a proof that he has the secret keys of the certificate. The client will receive that message. It will verify that the certificate is valid in order to ensure that he's talking with the right endpoint. He will also check for that proof of knowledge. And then he will send a finished message saying, okay, we have finished the TLS handshake. Let's start the secret communications. And as you can see here, after the TLS 1.3 handshake, the server will send a message saying, okay, we have finished the TLS handshake. Has been completed. Application data can be transmitted securely. We have also added the new session ticket message because that's important and it will be used in the future. So now let's discuss the CRTT message, which is used to do session resumptions. So imagine that we have a browser that needs to resume the previous established session with a web application. What it's going to do is it's going to create a CRTT message. But the bits that are interesting to us is that it will contain a session ticket and it will contain data that is going to be pushed to the server that will be encrypted using a CRT key. That will be sent to the server. The server will process that information. We will try we will check if the session ticket is a valid one. And also we will try to decrypt the data. If the data encryption is successful, it will push that data to the web application and then it will send that message to the send the response back to the client, including a new session ticket. And then the client will receive the message and will say, okay, we have done this session resumption. Then I'm not going to send you any more early data. Let's continue the conversation. And as you can see there, the application data will be sent securely. So hopefully, as you can see, it may be feasible to do replay attacks. And that's because the only thing that an attacker needs to have is to have that message that can be replayed to the server. And the server will just check that it has a valid session ticket and that he can decrypt the data. So let's see how a real attack may look like. So imagine that we have a banking application. And there is a customer that is using that banking application because he wants to do a money transfer to one of his friends. However, he doesn't know that the the , this friend is not really trustworthy because he's the attacker that is on that diagram. Okay. So the customer, when he clicks submit on the browser form, the browser is going to create a zero RTT message that will include that HTTP request of transfer funds. And that message will have a session ticket and then it is encrypted with a pressure key. Oops, sorry. That message will be sent to the server. In this case, the attacker is not going to do anything with it. It will only copy that message because he plans to replay it later on. So then the server will receive the message, it will decrypt because it has the right pressure key and will send that message up to the web application which will perform the first money transfer. And then the server will send back the response to the browser. So what could happen if the attacker replayed that original message? Let's see. So as that message has the right session ticket and is encrypted with the right pre-shared key, the server will receive it, process it, send to the web application, which would perform the second money transfer. And then as we can see, the attacker can do this as many times as he wants. He just needs to keep replaying that original message again and again. So is it everything as bad as this looks like? Not really. Okay. The working group put a lot of effort in order to describe these potential security risks and security implications regarding the zero RTT functionality. And they also added within the RFC the recommended protections and even mitigations. One of those two protections is single-use tickets. With single-use tickets, the server is able to prevent replay attacks because it has a database of fresh session tickets. How it works is when the server sends a session ticket to the browser, it will add to his database, and when he receives a zero RTT message with a session ticket, he will verify that that session ticket is on the database, and then he will accept the message, and then will remove that session ticket from the database of fresh session tickets. The next time he receives a second message, zero RTT message, he will check again that session ticket, and will find that it's no longer in the database. And then he will... He will reject that message because it means that it is a replay attack. So it seems that this protection is quite good. However, it has one potential issue. And it's how you keep that database synchronized in medium or big environments. And that's the challenge here, is to synchronize the database across multiple systems without allowing and without creating an opportunity window that an attacker can take advantage of. Another protection will be the client hello recording. Similar to before, in this instance, the server will keep a list of all the client hello that he is receiving. So the first time that he receives a zero RTT message, he will store that client hello on his list. And if he receives that message again, he will see that that client hello has been already processed. So he will reject that zero RTT message. Same as before, the challenge here is how you synchronize that list on a global and distributed database. And that's how you keep that database synchronized in medium or big environments. Another mitigation that is specified within the RFC is called freshness checks. So when the client is sending zero RTT messages to the server, it's including a timestamp, which is basically from the perspective of the client when that message was sent. So what a server can do is he can just reject any messages that has arrived outside an acceptable timeframe window. Another protection that is mentioned in the RFC is application profiles. And according to the TLS 1.3 specification, or to the RFC, let me see if I can quote it properly, application protocols must not use zero RTT data unless it has a profile that defines its use. Which basically means that the application should be able to define which functionality or which paths are going to be exposed over zero RTT. Application profiles is a RFC. So it's a RFC that defines its use. Which is related to TLS, but it's still a work in progress. And after that, we can have different other types of protections or mitigations. For example, OpenSSL has decided to have segregated APIs for the traditional TLS and this new zero RTT TLS feature. And that means that if a developer wants to use zero RTT, it's because he really wants to do it. And because he ideally knows which are the potential security. Other security controls can be added also at the browser or at the server level. Like, for example, not allowing zero RTT on, only allowing zero RTT messages on HTTP safe methods, which would be get, hit, or option methods. Finally, what also can be done is just, for example, for the requests that are being sent to the web application, make sure that those requests are idempotent. What means that? It means that if a developer wants to use zero RTT, it's because he really wants to do it. It means that the final state of the web application or backend, it will be the same independently of how many times you receive the same request. If it's once or multiple times, it shouldn't matter. Now, let's see here a table that we have put together after our research of what we have seen so far. So, the first two columns are basically related to the two protections that are mentioned on the RFC, single-use tickets and client hello recordings. You don't need to implement both. You just need to implement one. One of those two. Then, the third column is for application profile. And finally, we have a fourth column for some interesting notes. So, as you can see here, OpenSSL is using single-use tickets. And as I mentioned before, it has different APA in order to handle the zero RTT and normal TLS. Boring SSL has support for zero RTT, but is disabled by default. Cloudflare. Cloudflare is working to implement single-use tickets. They have implemented application profiles using HTTP headers, and they have zero RTT disabled by default. You can enable it, but you need to go to the dashboard and do that explicitly. And even if you enable, that zero RTT will only be available on HTTP-safe methods like GET. And they added on top of that another protection, which is that they are only allowing GET methods without parameters for zero RTT messages. Then, we have Chrome. Chrome has no zero RTT at the moment support. And Firefox is support zero RTT by default. And as we can see here, it will only send zero RTT messages on safe methods. In this case, GET request will be over zero RTT, but not post request. Okay. So, we are going to show the potential impact of zero RTT. When an attacker is in the middle of the communication. Today is therete sequence. So, first, the path generalized communication path between the web browser and the web server. Both, the web browser and the web server, will have DLS 1.3 and RET enabled. As web browser, we are going to use Firefox with HTTPS2 enabled, which is already enabled by default. fault. As a victim application we are going to use our own banking application which uses a get request with rest format to perform a money transfer. Firefox only uses zero RTT for safe methods. However, how many applications use get to perform actions which should be made using POST or other methods? Well, we see a lot of them while we are performing web service assessments. In a normal situation in which the web browser, well, in which there is not any attacker in the middle of the communications, the web browser will only show a message or will only, sorry, will only send a request using zero RTT. The fact is that we are not using the first one. Then the TLS connection would be established and the following requests will be sent using this created secure channel. Until the KIPA lifetime turns out. So this is why we think that it is highly unlikely that an attacker could catch a tempting request to be replayed only with passive techniques. But let's see this with a video. As I mentioned before, we are going to use the latest Firefox version. This is the tool that we created to test the replay attacks. The tool is in the middle of the communication and in this first mode, it will only show a message when zero RTT is detected. The tool is not HTTPS proxy. It is only a TCP proxy, which means that it is not the TLS termination point. And therefore, it cannot see the unencrypted data. However, it can see the TCP, the TLS packet headers. And using this information, it can detect when zero RTT is used. This is our banking application. The domain points directly to the web server. And as you can see, the certificate was correctly validated by the web browser. So the browser will not note that we are performing the man-in-the-middle. As you can see, although we are performing requests, we can see that we are not receiving requests. Nothing is shown by the tool because nothing is sent using zero RTT. As seen on the timer, we go forward three minutes without performing any requests to consume the KIPA lifetime. Now that the KIPA lifetime has been consumed, the first request and only the first request that the user performs will be sent using zero RTT. This is the request and this request could be potentially replayed. But the next requests is a request to the server. lifetime times out again will be sent using the established secure channel. This is why we think that passive attack is unlikely to work. Okay. But can we control when the web browser uses zero RTT? So can we improve this attack? The response is let's see. This is the TLS handshake that Alejo already explained. After a full TLS handshake or a zero RTT handshake, we want the server to receive the HTTP request and the browser to receive the server response. After that, if we don't do anything, the next request will be sent using the established secure channel like we saw before. However, we can finish the connection at the TCP layer by sending things or reset packets and then the browser will send the next HTTP request using zero RTT. If we do this for every new TLS connection, we will be able to send the next HTTP request and there will be much more chances that the attacker can replay the request that he wants. Because the most part of the request will be sent using zero RTT. Let's see this with another video. Well, now the tool is configured to do this technique. So let's see how it works. So let's see what happens once IAnd we had a notification from the attacker. So let's see. regret and now that I turtle it it will be Wong and Joe's. So I normally don't see any landing on, exactly where I want to go. Because this mode another or an IP address. So that the builder". Okay. Good. Good. So theIs usually doing some kind of thing with that. We're going to start As you can see now, the most part of the requests are sent using zero RTT. Due to the use of HTTP2, some of the GET requests are not really sent over zero RTT. Only the HTTP2 preface is sent over it and the real request is sent later in the established secure channel. However, we have noticed that for the requests initiated by Ajax, the most part of them are sent using zero RTT. Now we perform a money transfer of $2. Now we perform a money transfer of $2. But we don't want to replay it. Just to demonstrate that we are not tricking you. And as you can see, we have one money transfer. Now we perform a money transfer of $2. But we don't want to replay it. Just to demonstrate that we are not tricking you. And as you can see, we have one money transfer of $2. Now we perform a money transfer of $3. This time we want to replay it three times. And we press in the transaction list. It can be seen that the attack was successful. A user only sent one money transfer. But we have four. So, it's a great success. work. Okay. But now we have seen that replay attack can work against a vulnerable application which is hosted behind a server. It doesn't implement single use ticket or client help. What about a server that these techniques? Is it possible to a replay yet? Well, as you can imagine, the response is yes. And I'm going to try to explain how. In this situation, the web browser will send money transfer request using zero RTT. The attacker intercepts it and sends it to the web server. The web server will accept it because it is a fresh zero RTT. At this moment, the web browser is waiting for the server confirmation that the zero RTT was accepted. But the attacker sends this message. The attacker again, well, opening a new TCP connection, but he sends again the same message. And again, the same zero RTT packets to the web browser. To the web server, sorry. And now the web server rejects it because it is implementing single use ticket and simple reply like this one doesn't work because it is a non-fresh zero RTT. The attacker now sends back the rejection to the web browser. From the point of view of the web browser, the zero RTT was rejected and no money transfer was made. However in reality, one money transfer was made. According to the TLS 1.3 RFC, after a zero RTT rejection, a full handshake has to be done. So the web browser and the web server, they are the same. Now, the attacker calls the zero RTT. Now, the server is do the full handshake and after that the web browser since it thinks that the money transfer was not made at the first time, now it repeats the request, the HTTP request. And the web server accepts it because now it is not using zero RTT. It is using the established secure channel. So after the attack, from the point of view of the web browser, only one money transfer has been made. But really what has happened is that two money transfers has been made. With this, we can basically perform only one replay. But at least we can perform one replay against a server which has these anti-replay protections. Let's see this in a new video. The tool is now configured to perform this last replay technique in combination with the killing technique. The banking application is now hosted behind a reverse proxy which has enabled zero RTT. This reverse proxy uses open SSL, the pre-release version, which implements single use ticket. Like in the previous video, we perform a money transfer of two dollars without replaying it. And refreshing the transaction list can be seen that only one money transfer was made. Now the transfer has been completed. We can see that the transfer, the free money transfer is because we didn't perform any replay attack. However, now we perform a money transfer of $3. And we perform this last replay technique in which the web browser helps us. And as you can see, here instead of having one money transfer, we have two money transfers. So the attack was successful. Okay, this brings me to tell you that we are going to release this tool. And if you want to use it, you have to redirect somehow the traffic from the web browser to the tool. As you saw in the demos, we were using tags for the HTTP request. Like for example, send money. The tags are based on the encrypted packets lens and you can create them in the monitor mode of the tool. The tool also provides two other modes to perform the two different replay techniques. And also with the kill parameter, it performs the killing technique to force the web browser to use zero RTT. The tool should be available now at this GitHub repo. . Okay. So all the tests are 촶 as seen on the slide. It tells you the ethics of the use of zero mortgage임. When we deploy previous version of TLS, how the data is interested is totally transparent to the application. However, with zero RTT, that's going to change. Because it creates a dependency between the TLS and the application layer, which was not present before. So that means that the application will need to know if zero RTT has been used so he can prevent replay attacks. .. . And for policy, this is the next step, which I'm going to do. And if And at the end, the ultimate responsibility would be on the application itself to prevent replay attacks. And you can ask, how we can do that? Let's see what we can do. So first thing that you can do or you should do is disable 0tt. And only enable it if you are really, really, really sure of what you're doing. All the things that can be done is just, for example, you can try to make sure that your application is replay safe. But that can be quite a challenge. But if you go there, what you can do is you can apply a street cross-site request for a policy, not only at the session level, not only at the form level, but at the request level. Another mitigation that you can deploy is to migrate those get requests that are not replay safe to post requests. And why? Because most likely the browsers are not gonna send 0tt data on point. So you don't want to send a post request. Also, you can make sure regarding the web services, and especially with the rest web services, you need to make sure that those are developed properly and that get, post, put, and delete are used properly, and with regarding the get methods, you need to make sure that those actions are either read-only or idempotent. And finally, you should deploy a street application profile, which basically defines which are the functionality that you really want to expose over 0tt. To finish this presentation, we have some takeaways. The first one is that TLS 1.3 is awesome, and all of us will use it, but take care with 0tt. The second one is that, if you want to use 0tt, make sure that your application should be 0tt aware to prevent side effects. And the last one is that maybe you need to change your application or your server configuration in order to prevent replay attacks. Thank you so much, and if you have any question, we will be around. Thank you.