When you exit please exit out the back right side. Actually if you're looking at me it's your back left side. My right side. Good body girl, way up body look tight. And me and you up inside this dance here tonight. Me no see you with no partner, who up say me right. She say no, but she still say you forward and right. Then we go inna the corner. Outta the life us make the, buy you a drink babes if that's alright. Me ask her what she want, she say brandy and Sprite. So are you want a double? She say yeah if you like. Yeah. Yeah. Yeah. Yeah. Yeah. Yeah. Good body girl, way up body look tight. And me and you up inside this dance here tonight. We no see you with no partner, who up say me right. She say no, but she still say you forward and right. Then we go inna the corner. Outta the life us make the, buy you a drink babes if that's alright. Me ask her what she want, she say brandy and Sprite. So are you want to double? She say yeah if you like. Come back with this drink stem, grab she by the Take her now and darken her via Snow White session The way she hold me, me feel the connection Me know she feel me cause she ask me a question Some things where she a tell me Lord it turn me on And when she say she would a love a star in a pond Me leg them buckle, me head it gone Me long love it and me cure when me ready be proper You never, never, never, never cross over You never, never, never, never go far Rusha lalalalal I'll never cross over I'll never cross over You never, never, never, never go commercial You never, never, never, never go commercial You never, never, never, never go commercial You never, never, never, never go commercial Jump, jump, jump, jump Jump, jump, jump, jump Joke, joke, joke, joke Joke, joke, joke, joke Joke, joke, joke, joke Joke, joke, joke, joke Joke, joke, joke, joke Joke, joke, joke, joke Joke, joke, joke, joke Joke, joke, joke, joke Joke, joke, joke, joke Joke, joke, joke, joke Joke, joke, joke, joke Joke, joke, joke, joke Joke, joke, joke, joke Joke, joke, joke, joke, joke hello everyone and welcome to this talk called analyzing the security of bgp message passing so this talk will be presented by daniel dos santos and myself simon guillot so first quick introduction the people that work on this vulnerability research project are stanislav dashevsky amin amri and usama kero and there's a direction of daniel here and we are from the vedere labs team in at force code technologies and our mission includes the vulnerability research threat research and threat intelligence so now we're going to look at the relevant past research past research so is that we did so we had an initiative called project memoria where we analyzed multiple tcp ip stacks that we found in iot and ot devices and in total we found the 61 vulnerabilities that we presented to the community previously and this is inspired us to do this bgp research because most of the issues we formed were in were passing issue there and very few are in way Muslim 분�ity that is issues and we even published an informational RFC specifically about DNS implementations. So first Daniel will present you what is BGP and how and where it is used, then I will talk more about the vulnerabilities we found and the methodology we used and we will conclude with the security implications. So wait, hold on. So I just heard a rumor. You guys have never spoken here before, is that correct? First time. What's the tradition for first time speakers at DEF CON? There you go. To the first time speakers, Salud! So let's talk a little bit about BGP, right? And I do expect that a lot of people here will know at least that BGP exists, more or less what it's used for, and kind of what it looks like. But I want to talk a little bit about different uses of BGP as well that people might not be so much aware of. So first of all, you know, the Internet in kind of a nutshell, right? Where is BGP used that kind of everybody knows about? You have edge devices on a network communicating to other edge devices on a network, on another network, and those devices communicate via data packets that are routed from one network to another via routers, and those routers need to know how to get these packets, you know, from network A to network B, and BGP is the routing protocol that allows these routers to exchange routing information and kind of say, you know, I'm responsible for networks X, Y, and Z with this specific IP block and so on. And as Simon mentioned, we did some research in the past into TCP IP stacks and basically the protocols used at the edge devices, and now we wanted to focus on the router side of things and on BGP, right? So BGP, routing for the Internet, it's the protocol that is used to exchange routing and reachability information among autonomous systems, and an autonomous system is a block of IPs that is leased to an organization by a register for a certain time period, right? Just like you have in the domain name system, a domain is assigned to somebody for a certain period of time. Similarly, an autonomous system does that for a block of IPs. So BGP is the protocol that is used to advertise IPs. So it's based on autonomous system numbers and peer networks that are considered to be part of an autonomous system, and it can be either used internally within an autonomous system, so called internal BGP, or externally called external BGP with peers on the own Internet. And BGP is a protocol that makes routing decisions based on paths, network policies, rule sets, and so on, to kind of decide how a packet gets from one device in one network to another device in a network all the way on the other side of the network. side of the world potentially. But as I mentioned at the beginning, there are other use cases nowadays for BGP beyond the typical network internet scale routing. So data centers in the past decade have grown to such a large size that many organizations use BGP internally these days for routing internally in their own data centers, right? BGP is also used for MPLS, layer three VPNs across different organization sites. So a same organization that has sites across the globe and wants to connect them via a VPN sometimes use BGP to exchange specific information for making that VPN possible. It's also embedded in custom appliances that go sometimes in internet service providers or internet exchanges. Some content providers like Netflix, for instance, they have their specific way to, you know, treat traffic and do that more efficiently. And they kind of embed these appliances directly in some ISPs. And, you know, there are emerging use cases like load balancing and people get creative and they're using BGP for a lot of other use cases these days. So just want to kind of open your mind to the fact that everything that we mentioned, you know, BGP being used for the internet routing cases is the typical use case. It's what it's mostly used for still these days, but there are many other uses for it. So in summary, why I'm saying that is because BGP security per se is not just for internet service providers and internet exchanges anymore, right? Any organization will potentially be using a BGP and should be responsible for the security of BGP within their networks. So the basics of BGP, right, so BGP is a protocol with a kind of a simple state machine. You have six states there, a limited set of messages that, you know, transition from those states. So basically you have peers that are waiting. They set up a connection. There is a keep alive message that keeps that connection open that is sent every X seconds. There is a notification when some error happens or there's an update message to update the routing tables between the peers. And the packets are also relatively straightforward, right? So you have a package that has a header with a length and a type of a message. And then you have the content of the message, which is also not super complex, right? So what potentially could go wrong with BGP? So, well, the fact, and going back to kind of the basics, and this is something that is well known, that BGP, like DNS, like many other early Internet protocols, has no built-in security, right? Like authentication, authorization mechanisms, and things like that. So mistakes or intentional attacks that lead to network outages and traffic redirection in BGP happen. Frequently, right? The situation has been improving in past years. And we'll talk in the next slide a little bit about some of the traditional routing BGP security. But the fact is that still thousands of incidents happen per year of route leaks and hijacks, where basically a network or a router originates in the BGP jargon, right? So basically claims to be responsible for a prefix or a set of IPs that is owned by a network, another network, that is owned by a network without the permission of that other network, right? And that in some cases is used by attackers to make packets, you know, go through specific networks that an attacker controls and can maybe read or tamper with packets. So in many cases, it's actually accidental. And in other cases, it potentially is, you know, an actual attack, right? Especially when countries or more riskier countries, let's say, are involved in this kind of activity. So traditional BGP security has to do mainly with filtering out this incorrect or malicious routing information, right? Doing origin validation, so verifying that a network that announces a route is actually authorized to do it. And path validation, right? Ensuring that no unauthorized network is actually diverting traffic via a false route. So there are many techniques, protocols, and ideas these days to do that. And I invite you to have a look at those specific techniques that you can use to do these things, like RPKI, BGP Sec, and so on. But again, most of BGP security until now, you know, like the typical discussion around BGP security is always this kind of routing security, right? But what about vulnerabilities in BGP implementations themselves? So when BGP fails because of software implementations, it has happened in the past also, specific incidents where because of different implementations and the way that some BGP implementations would parse messages, routers would actually crash and, you know, cause network outages and things like that. So specific example that happened in 2019 with the FR routing BGP implementation, and we're going to talk a little bit further about FR routing in the rest of this presentation, it led to some network outages around Asia and Australia that the fact was that some researchers were trying some new features, that we were trying some new things in the kind of an academic task, but the fact is that not every router was ready to parse those new types of messages. So why do we think it's important then to research these BGP implementations, right? So the latest systematized work that we found about testing BGP implementations was 20 years ago, actually, exactly 20 years ago in 2003. It was a presentation at Black Hat, a team at Cisco that looked at both implementation and configuration of BGP across, like, different vendors. They did a work that actually turned out in the end, we did, we kind of followed some of their paths. So they created a fuzzer, they analyzed seven implementations and they found four new CVs at that time, right? But they also concluded that at that time, misconfigurations were more dangerous than actual implementation issues. And again, that was 20 years ago. There has been a lot of improvement in BGP and in the actual implementation of BGP security features in those 20 years, right? Also in 2007, a team at Juniper analyzed specifically the update message handling across several vendors and they issued an advisory together with the CertCC and they saw that mishandling of those update messages could lead to the loss of service in several cases. So they saw seven vendors affected, 10 not affected, and 25 that never responded to the advisory. And in the meantime, between, you know, the two of them, there was a lot going on. And so, in the middle of that 2003 original research and now, those 20 years, we actually found 129 CVs on BGP implementation. We found meaning, those exist already, right? Those were well known. We found in the national vulnerability database. And some of them include remote code executions. So 95% of those vulnerabilities are actually because of message parsing issues. So definitely it is a big problem in BGP implementations as well. So if we drill down a little bit into this previous vulnerabilities, we see that there is a mix of CVs on open and closed implementations of BGP, right? So if you look, for instance, at Cisco and Juniper, the big networking vendors, of course, there have been CVs on equipment from those vendors. But there's also implementations like the project I mentioned before, FR routing, which in the figure there, we actually put Quaga and FR routing together because Quaga is the project that we're working on right now. And so, the project that originated FR routing, FR routing is a more recent fork of the Quaga project. And again, just to make sure that we're all on the same page, the fact that Juniper and Cisco are highlighted there with, you know, a higher number of vulnerabilities doesn't mean necessarily that they are the most vulnerable, right? It's just because they're vendors that actually issue CVs and they do their own research and from time to time publish issues and so, so, potentially they are the more transparent, not necessarily the more vulnerable. But if we look at the CVs, those, again, 120 something in the past 20 years per impact, we see that the vast majority of them allowed for denial of service. Some of them also allowed for information leaks or remote code executions, but the vast majority was denial of service. And if we look at the timeline of disclosure for those vulnerabilities, we see that there is an increasing interest starting more or less from 2017. So, from 2017 onwards, there is always at least around 15, 18, 20, 20, 30, 30, 20 vulnerabilities per year on BGP implementations, popular BGP implementations being discovered. So, going beyond the vulnerabilities and into kind of the threat landscape per se, right? So, okay, we know that vulnerabilities exist, but still, why does it even matter to look at these things? So, the first point is that threat actors are focusing on network infrastructure these days, right? This is something that, I mean, it always has happened, of course, but it has been intensifying. And there are examples of, you know, there's a lot of, you know, there's a lot of nation-state actors, but also ransomware groups, other cybercriminals, hacktivists. It's becoming more and more widespread and popular to go after network infrastructure, things like routers, things like switches, firewalls, and so on, that are kind of at the perimeters of networks, right? So, recently, a couple of months ago, actually, CISA released a Biden operational directive specifically about the risks of exposed management interfaces on network infrastructure devices, right? Partly because of this increased interest from threat actors into this kind of device. But still, there are several BGP implementations that were not systematically analyzed. And as I mentioned in the previous slide with some open implementations having vulnerabilities found, those open implementations are becoming very popular these days and gaining a lot of traction with a trend that is called network function disaggregation, NFT. And basically, network function disaggregation is the fact that network function disaggregation is the fact that network function disaggregation is the fact that network function disaggregation is the fact that network function disaggregation is the fact that network function disaggregation is the fact that network function disaggregation is the fact that network function disaggregation is the fact that network function disaggregation is the fact that network function disaggregation is the fact that network function disaggregation is the fact that network function disaggregation is the fact that network function disaggregation is the fact that network function disaggregation is the fact that network function disaggregation is the fact that network function disaggregation is the fact that network function disaggregation is the fact that network function disaggregation is the fact that network function disaggregation is the fact that network function disaggregation is the fact that network function disaggregation is the fact that network function disaggregation is the fact that network 52 routing protocols, 40 of those are open, 12 are closed protocols, 20 routing platforms, 17 of those were open, and 53 network operating systems, and 20 of those were open. So of course we had to narrow down the research, right? It's a lot, like we cannot look at 53 different network operating systems, so we kind of went after the most popular ones, and Simone is going to mention that in the methodology part later on. But going a little bit deeper even into the threat landscape and threat actors looking into network infrastructure, as I mentioned before. So CISA tracks, well, in May it was 925 non-exploited vulnerabilities, now it's probably a little bit closer to 1,000. And most of those affect traditional IT software, right, Windows, Linux, Mac, you know, Adobe and so on and so on. But 179. 179 of those vulnerabilities can actually be mapped to specific devices that you will have on your network. And out of those, 88, or almost 50%, 49% of those 179 target specifically routers. So they're the most popular type of device being actually attacked right now. And yeah, I'm referring to another presentation there at Virus Bulletin in 2019 that talks a little bit about this threat landscape for routers as well. Have a look at that. But the reasons are kind of obvious, right, why attackers would go after routers. They are at the perimeter. There are new vulnerabilities coming up all the time in routers, and they tend to be not that difficult to exploit as, you know, exploit mitigations and things like that are not always yet implemented in this type of device. But again, drilling even further down, non-exploited vulnerabilities on BGP, per se, right? Out of those 88 vulnerabilities that we saw exploited in routers, three of those are decades old CVEs affecting Cisco BGP devices that are being exploited in 2022. So even if a vulnerability is, you know, from 2010 or 2009 or 2017, as in the cases there, they are still being exploited up to this day, right? There were also other vulnerabilities. There were also other two denial-of-service vulnerabilities on Cisco IOS, but those are affecting a different protocol and not BGP. So we're focusing here on the BGP side. And the interesting thing is, keep it in mind, Simone will make the connections here later on, but keep it in mind that those vulnerabilities allow for denials of service. They are being exploited by threat actors, and they have to do mostly with the parsing of open messages in BGP implementations. So let's talk about the new research that we're doing. So first let's talk about our methodology. So as we said, we already did the prior work on vulnerability research, so we had already some ideas, so mainly to look at the message parsing. We also looked at the previous implementations where vulnerabilities were found. So we selected all these implementations. And alongside, we added the most popular ones. So this led us to have both open source and closed source targets. And so we tried to start with static analysis, but of course, for closed source software, it's a lot more difficult. So we decided to try to develop a fuzzer that will help us in analyzing these specific implementations. And in the end, we also used BGP. And we used the fuzzer for open source implementations. So first, the manual analysis we did led us to find multiple interesting things. First, we found some issues in the design of BGP, because it's a very old protocol. I think the first RFC about BGP is from 1989. So for example, there is a lot of type link failure. There are a few parameters inside BGP messages, which means that when doing parsing of BGP messages, you first need to extract some fields to get information on the next fields to extract. And it brings a lot of exception handling and parsing quirks that make everything more difficult. Also, optional parameters are RMS. And another thing is that there are a lot of parameters in BGP. And sometimes peer responds to any open messages. So the open messages are the messages used to first establish a BGP connection. So it's called the BGP peering. And sometimes we even have update messages that are accepted by peers without prior BGP connection establishment. So it's a big attack surface on the BGP. On the internet. And this is why we decided to focus mainly on open and update messages. So first, for open messages, we examined multiple implementations. We found two things. So first, most of the implementations, they have the BGP running in the user mode, which means that we first have the TCP connection established. Because TCP handshake is handled by the kernel. So we cannot have filtering on the connections before looking at the BGP messages themselves. But except for Cisco IOS, where the BGP is running in the kernel. And so for one implementation in particular, so FL routing, we found that some parameters are perfect. We passed before the origin of the messages is validated. So we only had to spoof the source IP address to trace some attacks. Now about the phasing. So first, to explain quickly what is a phaser, it's basically a program that will generate automatically malformed input to send to a target. And then we just pass it. wait for the target to crash at some point. And so in our case, we used the Bufuzz, which is an open source framework to make fuzzers. And so with this fuzzer, we only had to describe roughly what is BGP. Like, we did some test cases by explaining to the fuzzer what the BGP message looks like so that it's able to generate messages that look like BGP but are, in fact, malformed and contain possibly dangerous values. And we also implemented an RPC monitor. So the goal of the RPC monitor is to install it alongside of the BGP daemon. And so the goal is to wait, because as soon as the BGP daemon is installed, it will crash. The RPC monitor will report the crash to the fuzzer. So the fuzzer will know that a specific payload made the daemon crash, and will save the payload and restart automatically the BGP daemon. And it's open source, so if you want to contribute, you can look at the code. And so now for the demo of the fuzzer. So on the terminal on the right, you will have, the BGP daemon running. And on the left, you will have the fuzzer. So first, we launch the BGP daemon. It's now waiting for connections. Next, we launch the fuzzer. And the fuzzer will just generate many malformed messages attempting to crash the BGP daemon. And it will soon crash. So now the BGP daemon crashed. And we will see that the fuzzer generated the Python file, which contains the payload that made the BGP daemon crashed. And next, we just have to launch the BGP daemon again, but this time inside the debugger, so we can look at the specific issues that made the daemon crash. So now we launch the BGP daemon inside the debugger. Again, it's now waiting for connections. And now we will execute again the same payload that made it crash the first time. Now it crashed again. And we will look at the backtrace to see what happened. And we will see in which functions the problem is. And I don't know if you can see, but basically, there's a function called the BGP open receive, which is a function that takes care of the open message passing. So with this fuzzer, we found a total of three vulnerabilities, which are denial of service. They are all due to a problem. We were able to find a very good solution, is an optional parameter in BGP. There are quite easy to find, and they are similar to the Cisco iOS vulnerabilities that Daniel introduced previously. And also, we wanted to mention that the FRO team were really quick in fixing the issues. So it was a really good working with them. So for the first vulnerability, it's a very quick and very, very, very, very fast. So we have an if condition that will look if the optional parameters are activated, basically. And if they are activated, it will try to get the next byte in the packet, but without checking beforehand if this next byte exists. So we just have to send a packet that ends with the values that the if is looking for. And we'll get a readout of bound of one byte. And just below, in the same function, we have exactly the same issue two times. The second vulnerability is, again, very similar. But this time, we have a check to see if we can read two bytes more. But in case of optional parameter, we actually read three bytes instead of two, which is, again, a readout of bounds. And the third one is also the same. So it's a very similar code from the previous one. But it's in another function. Right. Thanks. So kind of summarizing the results, or the new results, besides the things that I mentioned before with previous vulnerabilities, so we do see that still there are some popular implementations that are too permissive, right? So in some cases. This is not necessarily filtering out correctly unwanted open messages. And in other cases, even parsing these messages before filtering them, before discarding them, before they actually realize whether it's coming from a wanted source or an unwanted source, right? And on the other hand, some of this parsing can lead to denial of service vulnerabilities, and can be abused by attackers to take down some routers. Sorry, some BGP implementations on the routers, and potentially the routing tables, and so on. So let's talk a little bit about the impact of these issues. So any of these three new CVs lead to denial of service on a vulnerable BGP peer, as I mentioned, dropping the BGP sessions and routing tables, and rendering the peer unresponsive for some time. BGP is typically a so it will restart after a certain timeout, but this denial of service can be prolonged by just repeatedly sending. It's one packet, right, that crashes the server. Two issues out of those three can be triggered before, as I was mentioning, FR routing validates BGP identifier and ASN fields, so even before knowing if it's coming from a trusted peer, in a way. So in this case, an attacker only needs to spoof a valid IP address to send this message. And beyond these vulnerabilities, if we look at typical IPv4 scans, like show them the figure that we have there, there are more than 330,000 hosts with BGP enabled on the internet, more than 200,000 hosts that are running Quagga, the predecessor of FR routing. Not all of those are running BGP, necessarily, because Quagga is a routing suite that has other protocol implementations, and there are also more than 1,000 hosts running FR routing directly, right? There are also implications of this type of vulnerability because it deals with an open source project and because it's a component that will be embedded in other components and so on. There are kind of supply chain issues and supply chain implications here, right? So if you take FR routing, it's an open source project that came from a previous project that is even older, and it currently has more than 1,000 forks on GitHub. So we work very well with the project developers to fix it on the main branch of the project, let's say. But downstream forks, it's difficult to know when, how they will actually apply those patches. Also, this type of component ends up in different network operating systems. So I have some examples there, Dan, Sonic, Cumulus. They are popular network operating systems that are also open source and use FR routing as a specific component. So again, it's difficult to know which one of those, when and which versions will actually apply those patches. Those operating systems, in turn, are used by networking vendors, and that is what ends up in the networks of end users, right? So between the patches on the original project and the end users, there's a long way to go before sometimes these patches are applied, right? So almost any kind of research in two or three years, we're still not sure. But I think the issue of vulnerabilities in open source these days has this kind of consideration, right? Supply chain is a big emerging issue, and we need to be aware of that. But if we talk about risk mitigation also, I want to go back to the beginning of the talk and say that routing security is still very important and still not solved. And specifically for internet service providers, or for people who are dealing with BGP on a day-to-day basis, there are several good guides of, security and basically good implementations of BGP out there, right? So Manners is a good project. There are specific RFCs for BGP operations and security. There are guidelines from NIST and several other agencies about implementing the proper routing security mechanisms. But threat actors, as we mentioned in the beginning, have been attacking network infrastructure devices directly. So don't forget software vulnerabilities, right? That is specifically for BGP. But also for other protocols, other implementations. Those devices can be vulnerable. So you need to identify those devices on your network that may be using BGP and assess those vulnerabilities and patch when possible, taking into account all the supply chain issues that we mentioned. Also, the fuzzer that we released, it's open on GitHub, and it comes with the prepared test cases for the CVEs that we found. So if we want to test that against any implementation that you have that is using FR routing for whatever reason, you can run those scripts directly. And if you want to test any new implementation, you're free and welcome to extend the fuzzer as well or to use it out of the box on the implementation that you are interested in. And we would really be glad to hear about results or ways to improve the fuzzer and so on. So going to takeaways and future work, right? So BGP is still crucial for the internet, and it's widely used beyond internet service providers. And internet exchanges, unlike embedded TCP IP stacks, which we looked at in another project, BGP implementations have matured very well and in general do not have obvious mistakes, right? But some popular BGP implementations still have vulnerabilities or are too permissive. That's the main conclusion here. Network function disaggregation will make some BGP implementations, some open implementations very popular that's already happening. So it's very important to keep the security of those projects in check. And keep doing research on those. Threat actors are exploiting these kinds of issues, and the mitigation should not only be about routing security and should not be only delegated to your ISP, right? It's everyone's responsibility, let's say, to make sure that things are running securely. In terms of future work, I think keep fuzzing new versions and new implementations, improving the fuzzer with new test cases and so on is very important. And exploring other parts of the routing infrastructure and the routing apps, and attack surface as well, like other routing protocols, looking glass servers, remote control functions and so on is important. And it would be very interesting to understand what specific for which campaigns these threat actors are leveraging these BGP denials of service. So that's it. Thank you very much for your time and happy to take some questions down.