00:00:00.100-->00:00:06.440 >>I’m it’s time to, uh, y- yesterday if you were in here we saw uh Teddy Ruxpin get hacked. 00:00:06.440-->00:00:10.477 Um and t-today we’re gonna do uh something a little bit different, we’re gonna do uh 00:00:10.477-->00:00:16.617 power appliance. So uh, this is going to be very exciting. Let’s give Jos and Marina a big round 00:00:16.617-->00:00:21.622 of applause. [applause] Have a good time. >>Good morning thank you so much to all of you for 00:00:27.060-->00:00:33.133 coming here. So today we will be like, we will present you like what an effort it takes to 00:00:33.133-->00:00:37.905 design embedded exploits to actually cause physical damage in industrial facility from the 00:00:37.905-->00:00:42.910 beginning to the end. So briefly bout ourselves. I will let Jos present. >>Yeah so my name is uh 00:00:45.412-->00:00:49.016 Jos Wetvels, I’m an independent security researcher with Midnight Blue where I mainly 00:00:49.016-->00:00:53.453 focus on different kinds of embedded systems. Industrial culture systems, automotive, IOT 00:00:53.453-->00:00:57.157 and I previously worked as a researcher at the University of Twente with Critical 00:00:57.157-->00:01:03.597 Infrastructure Security. >>So and my name is Marina Krotofil, um I’ve been doing, uh my major 00:01:03.597-->00:01:09.403 f- uh specialization is physical damage and I’ve been doing it for 7, 8 years. Uh I presented 00:01:09.403-->00:01:15.309 to lot of folks at Black Hat and DefCon and so how this combination of a**es came 00:01:15.309-->00:01:21.448 together is on 1 hand Jos in reverse engineering and d- develop like exploits and 00:01:21.448-->00:01:27.621 implants for any embedded system in the world. Um, however like what exactly do you want to do 00:01:27.621-->00:01:32.726 on that device? And I am, my specialization is hey here’s a power plant, chemical plant or 00:01:32.726-->00:01:37.764 traffic light system, robotic system, how exactly you want to cause physical damage? So I will 00:01:37.764-->00:01:42.502 be designing engineer this exploitation scenario to cause physical damage and then in the 00:01:42.502-->00:01:46.606 end I will come up with a set of algorithms which need to be implemented and there is a long 00:01:46.606-->00:01:52.446 list of tasks which needs to be executed on that by that system. So with that wish list I would 00:01:52.446-->00:01:57.384 go to a guy like Jos and say, hey this is what I need to do on that device. And maybe that 00:01:57.384-->00:02:00.821 somewhere we will also meet in between when we would look at the design of the device like 00:02:00.821-->00:02:04.624 hey this specific first ch- uh design feature so the device could be probably due to 00:02:04.624-->00:02:09.997 accomplish like simple to several tasks. So this is where we would be working together. So 00:02:09.997-->00:02:16.870 this is h- how the combination came into place. Um, and so this how we will be presenting the 00:02:16.870-->00:02:21.675 presentation. So after the introduction and industrial control system and safety 00:02:21.675-->00:02:26.680 systems. By the way how many of you’ve heard, Triton? And I hope that everybody. Good. Because 00:02:29.950-->00:02:35.989 that was our motivation. We also wanted to show, like in the mass media they s- uh try to exploit 00:02:35.989-->00:02:41.795 wh- like describe us like so sophisticated, like only state sponsor, only few people and 00:02:41.795-->00:02:46.800 then we will show you if it’s really so. Um, so after the introduction we will go into the 00:02:46.800-->00:02:52.172 device exploitation because at the end you need to obtain called execution on the device. 00:02:52.172-->00:02:56.910 So after you had called execution then you start already developing for example implant 00:02:56.910-->00:03:03.750 like uh backdoors, like in a payload which actually uh, uh targeted like design for 00:03:03.750-->00:03:08.622 physical damage. And of course conclusions and the end. As you already probably know today I’m 00:03:08.622-->00:03:13.693 speaking very fast and there is reason for that. Because the topic which we are presenting to 00:03:13.693-->00:03:18.432 you extremely complex but we still wanted to show you the process from the beginning to 00:03:18.432-->00:03:24.404 the end and still of course with d- details and it’s already a lot. So it will be fast paced 00:03:24.404-->00:03:30.710 talk. Uh, h-however again the motivation was to show you the full process so that you could 00:03:30.710-->00:03:36.483 see it from the beginning to the end. And we will be posting even longer version of the slides 00:03:36.483-->00:03:41.154 a-after this talk because we have to cut out certain information and if you’re 00:03:41.154-->00:03:45.826 interested you can go and review it again. So introduction. So, wh-what are the industrial 00:03:45.826-->00:03:51.731 control systems? Well you all probably know but it’s important to set up a vocabulary so that 00:03:51.731-->00:03:57.771 all of us operate for this talk, operate on the same terms. So uh, industrial control systems? 00:03:57.771-->00:04:02.876 Those are computerized systems and network which control physical process. So typically 00:04:02.876-->00:04:07.013 if you talk about industrial organization there will be corporate network, there will be 00:04:07.013-->00:04:12.185 another network which called SCADA or control network and even though this is the same 00:04:12.185-->00:04:16.256 looking computer 1 will be called information technology and the another will be called 00:04:16.256-->00:04:22.662 operational technology or OT. Never the less that is still all computing devices and the guys 00:04:22.662-->00:04:27.834 who deal with those systems are study typically something like computer science. And as long as 00:04:27.834-->00:04:31.605 we’re moving towards physical processes that is already engineering science and it’s 00:04:31.605-->00:04:36.610 completely different. Um, so w- below uh the closer we come to the physical process the 00:04:39.246-->00:04:44.818 computing devices which actually monit- a- monitor and control physical process, they look 00:04:44.818-->00:04:49.990 already like this. And they called, we typically know them as em- embedded systems. So 00:04:49.990-->00:04:55.428 they don’t have uh, operating system as we know you. As, as we know it. So operating system uh 00:04:55.428-->00:05:01.735 which actually ehm, runs the deice and execute the programs is called firmware and since 00:05:01.735-->00:05:07.774 this system are real time systems the entire firmware must be loaded and executed in the 00:05:07.774-->00:05:12.779 memory at all times. So, ehm, uh, so on 1 head the attacked needs to, execute call so that 00:05:19.119-->00:05:23.590 attack will be executed on this embedded system so it’s still cyber domain. In order to cause 00:05:23.590-->00:05:28.461 the physical damage and basically uh damage for example the machinery, operating 00:05:28.461-->00:05:33.466 machinery ehm uh is needed. And so when for example when the attacker is like uh going into 00:05:35.502-->00:05:41.141 the like uh penetrating financial sector his goal is to steal money. In some form. So 00:05:41.141-->00:05:46.646 when the attackers penetrating the industrial network his goal is to call some sort of form of 00:05:46.646-->00:05:50.617 physical damage in the d- uh physical domain. It could be also economical damage, like 00:05:50.617-->00:05:55.655 spoiling the product. However, in the mass media typically this physical damage is depicted as a 00:05:55.655-->00:06:00.594 big explosion. Um, so ehm, I see a sli- so that landscape has changed in the past 8 years. So 00:06:02.729-->00:06:07.734 I started doing this type of security before it was fashionable and nobody knew 00:06:07.734-->00:06:12.772 about it. While like in 90, demand was like crazy amount of hacking happening all the time, 00:06:12.772-->00:06:19.079 like industrial control systems lived in bubbles, nobody knew about them. And then STUXNET has 00:06:19.079-->00:06:26.019 happened. So, uh it seem to be like STUXNET was kind of eh- trigger and tipping point 00:06:26.019-->00:06:31.057 because we started seeing more and more publicly known as peer known attacks. And somewhere, 00:06:31.057-->00:06:37.197 like we started seeing first publicly known, like um, activities related also already 00:06:37.197-->00:06:43.036 to recon. Uh, all their operational technology systems. So, and from 2015 it started to 00:06:43.036-->00:06:49.175 happen. And so there was to power grid attacks, in 15 and 16. And in 17 basically uh, uh 00:06:49.175-->00:06:55.515 it did, uh it was announced at the end of 2017 TRITON has happened. Uh what it was 00:06:55.515-->00:07:00.787 attacker tried to install backdoor or remote access to origin on a safety controller. 00:07:00.787-->00:07:07.594 Uh and it was a big thing because this uh, ehm. It was picked up by pretty much every 00:07:07.594-->00:07:12.599 mass media including Wall Street Journal's which said that was very, very, very alarming 00:07:12.599-->00:07:17.604 situation. And uh why was TRITON so special? Uh because it does targeted safety instrument 00:07:22.175-->00:07:28.948 system. So what does this mean exactly for us? Physical processes are inherently 00:07:28.948-->00:07:35.288 hazardous. So it means that there is like, like uh toxic flammable liquids um, f- fire 00:07:35.288-->00:07:39.526 and explosion, electrical hazards, moving parts in the machinery. So there’s a lot of 00:07:39.526-->00:07:44.531 layers of safety protections to prevent harm or maybe even uh, casualties to uh humans first of 00:07:47.067-->00:07:51.604 all. And secondly to pre-prevent environmental damage and also machinery. Because it’s 00:07:51.604-->00:07:56.810 expensive to kill uh, uh machinery. So there are uh layers of protections starting 00:07:56.810-->00:08:01.648 with the design of the process. Then we have a control loops then we have a human operation 00:08:01.648-->00:08:06.820 that contr- uh reacts to the alarm, but ehm as soon as like control system and human 00:08:06.820-->00:08:12.726 operator are no longer capable to control the process in the safety manner we have so called 00:08:12.726-->00:08:17.430 ehm safety instrument and system that is independent control system which reacts on the 00:08:17.430-->00:08:22.435 hazardous condition and tries to prevent it. So as you can see this is the last lane of line of 00:08:24.738-->00:08:29.743 defense before hazardous accident is already happening. So and the attacker was 00:08:31.778-->00:08:38.618 apparently uh, was trying to disab- uh to disable this system so that is actually attack on 00:08:38.618-->00:08:43.623 the civilian uh civilians which is not good. So, uh previously so safety instrument system are 00:08:45.959-->00:08:50.530 software systems. And because it is a line laying, line of defense typically i- it is r- 00:08:50.530-->00:08:55.535 m-, it is recommended that they be run on the uh, isolated and segmented network but for ease 00:09:00.140-->00:09:03.610 of design, and for ease of maintenance they are often connected together to the main 00:09:03.610-->00:09:08.615 control system. Uh and um, so and that allows the attacker to obtain remote access to safety 00:09:11.017-->00:09:17.457 instrumented systems so and they, that was a Triconex from Snyder and it is a very critical 00:09:17.457-->00:09:23.096 safety instrumented system of safety integrated level 3 which is only 2 percent of all 00:09:23.096-->00:09:28.101 hazardous situation. Uh for example an oil uh, ehm, ease of that, uh severity. So um, it, 00:09:30.737-->00:09:37.277 it’s very critical safety systems. Triconex is everywhere for example you could find it on 00:09:37.277-->00:09:42.282 the seamen ships and so on. So the attacker obtains remote access to the um engineering 00:09:44.484-->00:09:50.490 station which was connected to the safety controller so they got the ability to communicate 00:09:50.490-->00:09:56.930 to safety controllers. And what, eh, ehm, and attacker attempted to inject the passive back door 00:09:56.930-->00:10:01.935 or some people refer to it as a remote access trojan which would allow attacker to read er- 00:10:04.137-->00:10:09.342 arbitrary memory, write into the memory. For example, uh shell code for the attack and then the 00:10:09.342-->00:10:14.347 executed code. An- ehm. So um, now so, even if you have backdoor it really means nothing 00:10:18.551-->00:10:23.890 to you because I mean unless you know what you want to achieved in the plant that backdoor is 00:10:23.890-->00:10:29.062 actually absolutely useless and harmless. So attacks too now depend on the attackers goal and 00:10:29.062-->00:10:33.733 sometime it means explosion, sometime, but in most cases it does not. Because you don’t need 00:10:33.733-->00:10:38.438 to or engineer if you just want to a, send a warning sign to your enemy or what not. Ah and 00:10:38.438-->00:10:43.443 like s-some y- you can achieve some simple like, attacks like do not press, there are certain 00:10:46.746-->00:10:50.750 buttons on there that you might which have so descriptive like stop, start, you can press it 00:10:50.750-->00:10:55.755 and uh you achieve some in fact. But ya know, that is not the la- a long lasting effect. So, like 00:10:58.091-->00:11:01.294 yes the first that physical attacks were happening and the change their mind, then the 00:11:01.294-->00:11:05.732 attackers move their exploit for example, ehm in the destroyer crash over right they were 00:11:05.732-->00:11:09.402 executing the attach already at the level of the industrial protocols which now we have have 00:11:09.402-->00:11:15.308 TRITON which is already on the embedded system. So what’s going on? Why the attacker is already 00:11:15.308-->00:11:21.114 moving their exploits into the embedded systems and we will explain. So industrial processes 00:11:21.114-->00:11:27.220 are very complicated and they actually build inherently in design to be robust and 00:11:27.220-->00:11:33.960 recoverable. So eh, if the attacker wants to achieve and uh significant long lasting damage, 00:11:33.960-->00:11:39.966 uh they actually need to obtain very uh specific process uh like very detail process 00:11:39.966-->00:11:46.906 comprehensions, the design, um th- the naming behavior of the uh process and so on. So for 00:11:46.906-->00:11:53.479 example like what cause the pipe to explode? Well what causes the right pipe to explode? And then 00:11:53.479-->00:11:58.418 what causes the right pipe line to explode at the right time? And suddenly the complexities 00:11:58.418-->00:12:04.724 increasing. So industrial control systems operate on the control loop uh principles. So 00:12:04.724-->00:12:08.795 uh control systems and human operators they use sensors to observer the state of the 00:12:08.795-->00:12:13.633 process and then control system computes the commands to instruct operators to control 00:12:13.633-->00:12:19.305 the process and bring it into the right state. So ehm in a nutshell when the attacker is 00:12:19.305-->00:12:25.645 start designing or, uh engineering damage scenario th- huge number of tasks which he 00:12:25.645-->00:12:29.582 has to accomplish. While starting of course from manipulating the process but 00:12:29.582-->00:12:35.121 then the attacker needs to also obtain the feedback loop to know whether the process is moving 00:12:35.121-->00:12:41.661 into the right state and he is successful. Uh, I’ve been doing this for many, many years and 00:12:41.661-->00:12:46.499 I’ve designed a lot of damage scenarios and I can tell you that obtaining the back loop is 00:12:46.499-->00:12:52.071 where uh , 1 of the most hardest tasks to achieve because most sensors which are installed 00:12:52.071-->00:12:56.643 there, they’re in the plug they useful because the attack is something always weird and they 00:12:56.643-->00:13:01.981 not, the plant was not uh designed to measure something weird going on. So you have to 00:13:01.981-->00:13:07.120 do it indirectly and of course because you’re trying to bring the process into the wrong state 00:13:07.120-->00:13:10.923 and the harmful state the control system and human operator and safety system, they 00:13:10.923-->00:13:15.528 will try to fight you back and to bring process back into the normal state. So the attacker 00:13:15.528-->00:13:21.000 also have to prevent a response. And TRITON falls into this category. Preventing response 00:13:21.000-->00:13:25.838 because they wanted to uh prevent response from the safety systems. So in a nutshell the 00:13:25.838-->00:13:30.710 cyber physical attack or damaging attack that will be a collection of clandestine 00:13:30.710-->00:13:36.649 control loops because the c- the attacker is becoming a control system. And you have to have 00:13:36.649-->00:13:42.255 this cycle of observation and u- and manipulate to achieve in safe state. So attack timing is 00:13:42.255-->00:13:48.461 crucial, so because processes not vulnerable at all times so you have to find that vulnerable 00:13:48.461-->00:13:53.466 time. Uh and e- when the attack has to be executed, executed the attach coordination is critical, 00:13:55.668-->00:14:01.107 as you have seen there’ve been a lot of tasks and for example observation is of state 8 and 00:14:01.107-->00:14:07.246 component, b- uh component B needs to trigger payload x, y , z. So this requires very gradual 00:14:07.246-->00:14:14.120 control across the entire process and to manage the, uh like tasks quantity and timing. 00:14:14.120-->00:14:18.091 So there was a very nice presentation even though I’ve been presenting on that e- s- uh 00:14:18.091-->00:14:22.729 topic a lot of times, like many times. So there’ve been nice presentation from Jason Larson 00:14:22.729-->00:14:28.201 who decided to compare different uh damage scenarios and he came up with this timing, instead of 00:14:28.201-->00:14:33.206 that, state diagram he, divided all the control uh damage task and e- to d- uh damage scenario 00:14:35.942-->00:14:40.947 into different tasks where he also tried to map, like hey this is a set of tasks which I need 00:14:40.947-->00:14:47.587 to execute. How do I map them now to the different deice to different implants? And um, so 00:14:47.587-->00:14:53.493 basically as soon as you, as amount of tasks which you need to execute to achieve damages 00:14:53.493-->00:14:58.664 becomes large you need to have in plans. Because like to keep separate tasks you, you will not 00:14:58.664-->00:15:03.603 be able to coordinate them. So, and uh this also allows you uh, c- uh it allows you actually to 00:15:06.038-->00:15:11.811 coordinate so you can easily then install the coordination between the implant where the 00:15:11.811-->00:15:18.084 communication links or you can implement a routine 2D text specific state. So uh, and it’s 00:15:18.084-->00:15:23.556 also much more stealthy because you don’t have um, ehm, a, like a normalistic, do not create, 00:15:23.556-->00:15:28.561 create uh, a normalistic network traffic. Uh so but before like, in order actually achieve this 00:15:30.797-->00:15:35.802 to w- e- implement and implant you first have to ex- exploit the device. And you better enjoy 00:15:37.937-->00:15:41.641 extreme programming because those devices are extremely small, have very limited 00:15:41.641-->00:15:45.745 resources and are packed with the functionality so you first have to actually find something 00:15:45.745-->00:15:50.950 with device does not need. Eliminate it so that you could p- put your actual exploitation 00:15:50.950-->00:15:56.255 cord. So at the end Jason came up with this diagram where he has like put a score on 00:15:56.255-->00:16:01.160 different tasks and he compared it r- reliability because it’s not only the reliability of the 00:16:01.160-->00:16:07.934 attack scenario but it’s also reliability of your exploit or implant on the device. And so 00:16:07.934-->00:16:12.872 basically it’s kind of, you have to find this tradeoff like what is the most reliable attacks, uh 00:16:12.872-->00:16:17.877 implant and im- uh attack damage scenario and implant stability. So, now after this h- long th- 00:16:21.047-->00:16:26.285 introduction I am giving back to Jos and he will walk through the device exploitation and design 00:16:26.285-->00:16:30.756 and like basically implement and so now I have my wishlist of task and I’m giving it to him to 00:16:30.756-->00:16:35.761 implement. >>Alright thank you Marina. So before we can do all this [applause] so before we can 00:16:42.435-->00:16:46.639 get ya know to the cool stage where things are actually exploding we’ll have to get to 00:16:46.639-->00:16:50.843 another cool stage which is exploiting the device. And basically the process is as 00:16:50.843-->00:16:54.647 follows and I’ll walk through these steps and we start by obtaining the necessary 00:16:54.647-->00:16:59.819 materials so we need a couple of things before we can devise an exploit and an implant. And the 00:16:59.819-->00:17:04.557 first thing we’ll need is documentation and a lot of it. Ya know, developers guide 00:17:04.557-->00:17:10.997 planning and installing manuals, all that kind of stuff. And, yeah. In the case of Triconex it 00:17:10.997-->00:17:15.501 was very useful that these things are safety certified at a certain level and that means 00:17:15.501-->00:17:19.138 that all the documents were available on the website of the US Nuclear Regulatory 00:17:19.138-->00:17:23.776 Commission. So very detailed information was out there in other cases you might have to 00:17:23.776-->00:17:27.680 buy it but this is the first step you go about. And the second step is obtaining the 00:17:27.680-->00:17:31.651 engineering software so these devices are connected to a workstation running I don’t know 00:17:31.651-->00:17:36.522 Windows XP with some software that is used to program them. And this software usually 00:17:36.522-->00:17:40.159 contains the functionality for talking to this device and the protocols you want to take a 00:17:40.159-->00:17:45.565 look at. So you obtain this by just going to the vendor website or asking them nicely, which is 00:17:45.565-->00:17:51.270 the easiest route. Or if you’re of- already compromised as the owner networks you might take it 00:17:51.270-->00:17:56.075 from the network because you’re in there already so why not grab a souvenir? Um or you might go 00:17:56.075-->00:18:00.613 to the various sketchy sources on the internet like eBay or Alibaba or open directories 00:18:00.613-->00:18:05.518 hosting this kind of stuff. So you know it’s usually relatively easy to come by. In the case of 00:18:05.518-->00:18:09.655 Triconex uh itd be fun to try station software for the equivalent of 3 U.S. dollars on 00:18:09.655-->00:18:15.494 some Chinese website. So, yeah. That was relatively easy. Then we have to obtain the device and 00:18:15.494-->00:18:18.864 that’s a little trickeries because you’re not gonna find that kid of staff at a yard sale 00:18:18.864-->00:18:23.336 or at a corner shop or whatever. It’s very expensive you and you might have to buy multip- 00:18:23.336-->00:18:27.540 multiple copies. Because you might have to do a tear down or you might break a device 00:18:27.540-->00:18:32.678 etcetera, etcetera. So ideally you buy it directly from the vendor but if you’re a n-nation 00:18:32.678-->00:18:37.817 state sponsored attacker you maybe don’t want to directly do that so you need strawmen or buy 00:18:37.817-->00:18:43.789 it at a bankruptcy auction or again eBay or Alibaba are your friend. So, here you can see I’m 00:18:43.789-->00:18:48.461 not sure if it’s yeah, it’s all coming up, it, it’s relatively expensive in most cases uh 00:18:48.461-->00:18:52.598 couple of thousand bucks for, for 1 of these controllers and you need multiple parts to put 00:18:52.598-->00:18:56.702 the whole thing together so it’s, it’s not ya know very cheap. Then you need to obtain 00:18:56.702-->00:19:00.606 the device firmware the s- the stuff that runs on the device itself. So there’s various 00:19:00.606-->00:19:05.144 options here. You can sometimes download it from the vendor websites, uh or extract it from 00:19:05.144-->00:19:09.048 some update utility, that’s, that’s the easy approaches or you might have to extract it 00:19:09.048-->00:19:12.885 from the flash chip on the device itself. Go the hardware hacking route. And this can 00:19:12.885-->00:19:16.756 become very complicated because in the worst case scenario you’ll have encrypted firmware, 00:19:16.756-->00:19:20.459 you’ll have chip readout protection, you need to bypass and do side channel attacks and 00:19:20.459-->00:19:24.664 all kind of stuff. But for track and XL it was not necessary because there was no read out 00:19:24.664-->00:19:28.267 protection on the flash you could just de-solder it, put it into an adapter and use a 00:19:28.267-->00:19:33.439 universal util program ran, you’d be good. Or, you could just get it from the firmware 00:19:33.439-->00:19:39.578 update utility which also holds it all too ya know. Um, the second step you have to do is 00:19:39.578-->00:19:45.084 usually device teardown and PCB analysis so we need info on what kind of microcontroller is on 00:19:45.084-->00:19:49.155 this decide. Uh we need the device functional domains so what is happening where on this 00:19:49.155-->00:19:53.793 device? Uh we ne4ed to know about interesting interfaces, like UART, JTAG, what have you. 00:19:53.793-->00:19:59.198 And sometimes we’re lucky if its an FCC certified device, you can an FCC ID and you get like 00:19:59.198-->00:20:03.102 internal photos and documentation on the FCC website. Sometimes other people 00:20:03.102-->00:20:07.406 have done your job for you and you have public teardowns and that’s very nice. Um in the case 00:20:07.406-->00:20:11.544 of Triconex the planning and Installation guide has very uh detailed internal block 00:20:11.544-->00:20:15.915 diagrams. And that helps a lot because you know, that, that prevents you from or um, saves 00:20:15.915-->00:20:20.286 you the effort of, of opening it up. But in some cases we’re not so lucky and we will have to do 00:20:20.286-->00:20:24.390 teardowns. Now people who do not come from an hardware hacking background are usually terrified 00:20:24.390-->00:20:30.096 of it. But it’s not that complicated in most cases. Um, ya know like the picture shows, 00:20:30.096-->00:20:35.634 it’s RAM, flash or you google it. Um and and there is this, this persistent narrative that 00:20:35.634-->00:20:40.506 ya know especially among some OT people that ya know ICS devices, they’re all different and 00:20:40.506-->00:20:44.810 operational technology it’s not like the uh embedded devices you’re used to but for our 00:20:44.810-->00:20:49.081 purposes it’s like all the IOT devices out there that are getting hacked by the billions 00:20:49.081-->00:20:55.354 every days. For example, take these twee-, these 2 uh PLCs by Schneider Electric, the Modicon 00:20:55.354-->00:21:00.292 M238 and M33, M340. Um usually you have a central processor module which does all the heavy 00:21:02.328-->00:21:07.032 lifting and you have a couple of input output modules which you stitch onto it, on the side as 00:21:07.032-->00:21:11.704 you can see on the right of the slide. Uh, you might have an integrated uh, ethernet uh 00:21:11.704-->00:21:16.609 connector as you can see on the right example or maybe you have a dedicated module uh that do 00:21:16.609-->00:21:20.946 the ethernet stuff and then connecters to the main module over serial link. And internally 00:21:20.946-->00:21:25.584 they typically look something like this, as you have a couple of I/O pins you have serial link 00:21:25.584-->00:21:30.656 or ethernet link or whatever. Then you have a microcontroller. Um in the middle. And typically 00:21:30.656-->00:21:35.127 this microcontroller will run the main firmware which has the operating system and some of the 00:21:35.127-->00:21:39.999 application stuff, like maybe a web server, ftp server or whatever. Um and then you 00:21:39.999-->00:21:44.603 typically have a logic handling chip. Uh which might be an FPGA or another micro controller 00:21:44.603-->00:21:49.708 executing the actual programs that this thing is uh, is configurative program thing. No 00:21:49.708-->00:21:53.979 this might differ between PLC because you know this is a generalization but it roughly 00:21:53.979-->00:21:58.450 comes down to something like this. And for Triconex it looks like this. So you have 3 main 00:21:58.450-->00:22:02.922 processors and they communication over TriBus which is an internal bus that does 00:22:02.922-->00:22:08.160 some voting on input values for consistency. It has a triple module redundancy architecture 00:22:08.160-->00:22:13.799 to ensure ya know uh a vote of the 2 of the 3 overrides uh any errors that are introduced them. 00:22:13.799-->00:22:18.037 Um yeah, that’s, that’s basically what it looks like, the main processor. Um, and, 00:22:18.037-->00:22:23.876 there you have it, it, it runs a PowerPC chip and you have a dedicated other chip for in, 00:22:23.876-->00:22:28.814 input output and communication stuff. And we’ll delve into this a little bit later when it 00:22:28.814-->00:22:33.786 becomes relevant. So the first thing you want to look at for ICS stuff is reverse engineering 00:22:33.786-->00:22:40.059 of all the protocols they talk to um because in many cases um these are legacy and proprietary 00:22:40.059-->00:22:44.930 protocols, usually ports of old serial protocols that have been retrofitted onto ethernet. They 00:22:44.930-->00:22:48.701 control very sensitive functionality like starting and stopping a POC, updating the 00:22:48.701-->00:22:53.739 firmware and so on. Eh, and you might uh find a way to get into a device itself by remote code 00:22:53.739-->00:22:58.143 execution uh here and that’s what we want. So the first thing we need to know when 00:22:58.143-->00:23:01.113 encountering a protocol we didn’t know is knowing the packet structure and the 00:23:01.113-->00:23:06.285 semantics. So we can do this in a couple of ways and ya know this is, this is a very quick 00:23:06.285-->00:23:10.322 generalization but usually you go about comparing it to functionally similar protocols 00:23:10.322-->00:23:14.593 that have been document so if it’s apart of an old serial protocol maybe take a look at ya 00:23:14.593-->00:23:19.598 know what that look like and, and what you can recognize uh in there. Uh test for common 00:23:19.598-->00:23:24.837 encoding structures like TLV, sequential identifiers, uh check sums, any entropic analysis for 00:23:24.837-->00:23:29.708 uh fields that integrate and indicate cryptographic functionality. Uh or you might 00:23:29.708-->00:23:33.479 want to do differential analysis of functional batches of packets. SO you have like 1 00:23:33.479-->00:23:37.783 packet that corresponds to starting the PLC, 1 that corresponds to stopping the PLC 00:23:37.783-->00:23:42.054 in different kind of conditions and then see what kind of uh bit fields in the packets change 00:23:42.054-->00:23:46.125 and, and what you can make of that. And like Rob Savoye said, believe it or not, if you stare 00:23:46.125-->00:23:50.896 at the hex dumps long enough, you start to see the patterns. And that is definitely try for 00:23:50.896-->00:23:55.901 PCAP-Only analysis as you can see here, it’s basically like looking at the Matrix. Now 00:23:55.901-->00:24:00.172 ideally you want to assist this, this traffic only analysis with binary reverse engineering 00:24:00.172-->00:24:03.676 because you want your reconstruction to be complete and sound. You want to write a 00:24:03.676-->00:24:07.346 reliable exploit. Not because you don’t want to f**k things up but because you don’t want to 00:24:07.346-->00:24:13.018 f**k things up for yourself. Um, so a PCAP-only analysis can be incomplete, inaccurate or 00:24:13.018-->00:24:16.955 opaque, ya know you can have undocumented for rare behavior that you don’t see in the field 00:24:16.955-->00:24:20.592 but that’s in there and you’re interested in. Uh you might guess at semantics that you 00:24:20.592-->00:24:23.829 might not actually be what you think it is. There might be encryption, compression, blah, 00:24:23.829-->00:24:28.133 blah, blah, blah blah. And most importantly PCAP-only analysis damages your sanity so you want 00:24:28.133-->00:24:33.339 to do some binary reverse engineering. Which does that to a lesser extent. Um, so in the 00:24:33.339-->00:24:38.077 case of Triconex the Tristation software has a communication DLL, um, uh this has all the 00:24:38.077-->00:24:42.214 juicy stuff we need. It’s a dingle DLL and the engineering software and it has debug 00:24:42.214-->00:24:46.552 symbols so that greatly eases our life. And as you can see on, on the slide I hope it’s uh, 00:24:46.552-->00:24:52.424 it’s, its visible um basically all these functions they have a good semantic mapping between 00:24:52.424-->00:24:56.662 the functionality it does, like starting the PLC stopping the PLC, downloading the control 00:24:56.662-->00:25:01.133 logic and the function code within the protocol itself so you can relatively easily 00:25:01.133-->00:25:05.137 identify all that functionality and you can see the attacker probably went about it this way. 00:25:05.137-->00:25:10.909 Now the, the benefit for attackers is that you don’t need to fully reverse engineer the 00:25:10.909-->00:25:14.747 protocol you only need to understand a few interesting pack types because we don’t want 00:25:14.747-->00:25:19.418 to craft a full protocol parsers we want to craft an exploit. So I don’t care about all, all the 00:25:19.418-->00:25:24.423 rest, I care about like that, that 1 packet type that does the, the good stuff. Now when it 00:25:24.423-->00:25:29.528 comes to vulnerability discovery which is typically the step that, that comes after this. Um 00:25:29.528-->00:25:33.265 the next step is getting good execution right? And ideally this is a pre-authentication 00:25:33.265-->00:25:38.771 vulnerability. As we’ll see pre-auth is a relative concept in the ICS world. Um and in many 00:25:38.771-->00:25:43.976 cases ICS vulnerabilities are often a byproduct of the reverse engineering so you, you wont 00:25:43.976-->00:25:48.981 need to go about in most cases about fuzzing or, or static analysis of the firmware. In 00:25:48.981-->00:25:53.218 many cases it’s insecure by default there’s anc- ancient legacy s**t everywhere and you 00:25:53.218-->00:25:58.223 shake a stick at it and vulnerabilities fall out. So, let me briefly drink something. 00:26:00.459-->00:26:06.565 So ehm, an example of this for example, is the um , Moxa NPort serial-to-ethernet WIFI 00:26:06.565-->00:26:11.136 converter, uh you plug a serial cable and coverts it to ethernet. Um it has a web 00:26:11.136-->00:26:16.241 interface with broken authentication so it hashes on the client side. That’s good. Um 00:26:16.241-->00:26:19.845 once you’re in you can do command injection in the pen test form, so you get your code 00:26:19.845-->00:26:25.050 execution right there. And uh, another example the Opto energy monitoring and control device 00:26:25.050-->00:26:29.588 used in fairly sensitive environments. It’s got FTP it’s got a proprietary protocol 00:26:29.588-->00:26:34.293 without authentication. Now the thing is you can configure FTP with a password you can enable 00:26:34.293-->00:26:38.997 uh IP filtering all that kind of stuff but then you can use this unauthenticated proprietary 00:26:38.997-->00:26:43.969 protocol to disable IP filtering enable FTP and ask the credentials nicely, ya know then 00:26:43.969-->00:26:49.341 you get them and you can use the FTP to unload a new p- piece of firmware and re-flash the device 00:26:49.341-->00:26:53.612 over FTP and there’s no firmware signing. So again that’s easy code execution right there. 00:26:53.612-->00:26:58.984 Another example in case you- you’re not believing me. Uh the Modicon Quantum PLC, uh that’s a 00:26:58.984-->00:27:03.222 large PLC for process applications. It has FTP with hardcoded credentials which 00:27:03.222-->00:27:07.826 allows you to read, write configuration, firmware what, what have you. It has a telnet 00:27:07.826-->00:27:13.098 with a hard coded backdoor and that’s actually a C interpreter which ya know, is nice. Um it 00:27:13.098-->00:27:17.503 also has an unauthenticated proprietary Modbus execution for starting and stopping the PLC, 00:27:17.503-->00:27:21.406 overwriting the program logic there’s basically a zillion ways to get code execution on this 00:27:21.406-->00:27:26.111 way. And finally to drive the point home, another serial-to-ethernet converter. Uh 00:27:26.111-->00:27:30.816 by Advantech. Uh it has a web interface again, and, and the nice thing is that if anybody 00:27:30.816-->00:27:34.820 unlocks the web interface on 1 PC, let’s say a legitimate operator, it’s disabled for 00:27:34.820-->00:27:40.893 everyone. So ya know. Uh then you have the command injection in the email set up, uh email 00:27:40.893-->00:27:45.264 alerts set up form and again easy code execution right there. I mean you get the idea, it’s 00:27:45.264-->00:27:49.468 like shooting fish in the barrel, right? And um, for Triton it was basically the same 00:27:49.468-->00:27:53.038 thing it was an, execute my packet please vulnerability so the vulnerability was the 00:27:53.038-->00:27:57.009 freebie of the protocol reverse engineering. You have this safety program download 00:27:57.009-->00:28:01.647 functionality, which is how the engineers put like the actual logic on the thing. And it has 00:28:01.647-->00:28:06.118 no authentication and the safety logic that gets downloaded to the device has no secure 00:28:06.118-->00:28:10.656 signing, right. So you can basically skip all the way from reverse engineering to exploit 00:28:10.656-->00:28:15.494 development and that’s neat from an attacker point of view. Not so neat from the vendor point of 00:28:15.494-->00:28:20.499 view. And then that brings us to exploit development. So after we find a suitable vulnerability uh 00:28:20.499-->00:28:26.104 and we get our code execution we need to craft an exploit to, to actually ya know, not execute 00:28:26.104-->00:28:30.809 just the logic we want but execute ya know the instructions on the microcontroller we want. 00:28:30.809-->00:28:36.081 Um, and how, how, how would this look like in the case of Triton? Well, Triton has safety and 00:28:36.081-->00:28:41.119 control applications which are developed in one of these uh IEC languages. Um, many of them look 00:28:41.119-->00:28:45.057 like graphical language like you can see on the, the bottom of the slide. And they typically 00:28:45.057-->00:28:50.495 get compiled and downloaded and executed on the main processor there. And that’s nice because 00:28:50.495-->00:28:53.999 that gives you another exploit development freebie because you don’t need to break out of any 00:28:53.999-->00:28:58.670 sandboxes you don’t need to exploit any run times and because in the case of the 00:28:58.670-->00:29:03.241 Triconex controller the logic was executed on the same chip that the operating system was 00:29:03.241-->00:29:06.979 execute on, you don’t need to hop across any chip parameters, you’re right where you want to 00:29:06.979-->00:29:12.851 be. So Triton did have to, to add some additional functionalities so it doesn’t 00:29:12.851-->00:29:16.788 overwrite your original programming but it appends to it, and the reason why it did 00:29:16.788-->00:29:21.360 this is because it allows the safety logic to continue running without interruption because 00:29:21.360-->00:29:25.130 once you’re implanting this device you don’t want everything to stop and potentially already 00:29:25.130-->00:29:30.369 cause a process shut down. You want to be stealthy at least at that point. Another complication 00:29:30.369-->00:29:33.839 is the key switch on the Triconex controllers. So these devices have a physical key 00:29:33.839-->00:29:37.776 switch that allows you to, to set it to a certain mode and only if it’s set into a 00:29:37.776-->00:29:41.913 programming mode then you can actually download new logic to it and this is something that 00:29:41.913-->00:29:47.252 will be relevant later when we discus is uh, uh the payloads. Another complication of, of 00:29:47.252-->00:29:51.957 embedded exploitation in general is the heterogeneity. Um so embedded devices are far more 00:29:51.957-->00:29:56.395 heterogeneous that general purpose ones. You deal with a billion architectures from ARM 00:29:56.395-->00:30:01.933 to, to MIPS to PowerPC to whatever. A billion kind of operating systems like VxWorks, 00:30:01.933-->00:30:07.105 or QNX or even custom operating systems. And in the case of Triconex that means that you 00:30:07.105-->00:30:12.144 have different architectures and operating systems between different versions. So uh, 00:30:12.144-->00:30:16.982 version 9 had a national semiconductor chip, version 10 and 11 had PowerPC and for the 00:30:16.982-->00:30:21.920 attacker this means that scaling the attack requires writing a modified payloads and implants 00:30:21.920-->00:30:26.525 for each different version so there’s some effort involved there. That brings us to the 00:30:26.525-->00:30:30.896 development of the implant and the OT payload, and a- ya know that’s, that’s, th-that’s the 00:30:30.896-->00:30:36.134 stage that’s close to what Marina mentioned of mapping like the TSD to the implants on the 00:30:36.134-->00:30:41.106 devices. Then we get to this stage now we have code execution, we can run arbitrary 00:30:41.106-->00:30:46.978 PowerPC shellcode, so now what? Well e- e- exploitation is just 1 step among many. So us for 00:30:46.978-->00:30:51.616 complicated OT payload we will need to develop this implant and then after that craft the OT 00:30:51.616-->00:30:57.522 payload. Um we have different kind of strategies here so we can directly implant the OT 00:30:57.522-->00:31:02.094 payload straight away uh after exploiting the device or we can implant a back door which would 00:31:02.094-->00:31:07.599 allow us to keep the, the OT payload a secret until ya know zero hour and basically provide 00:31:07.599-->00:31:11.603 you with kill switch capabilities or in, in that jargon of some people a dormant 00:31:11.603-->00:31:16.708 cyber pathogen. Um, that basically would allow you at a later stage to execute any kind 00:31:16.708-->00:31:20.912 of payload you’d want. Um the second thing we’ll have to decide on is whether we go for 00:31:20.912-->00:31:25.250 cross-boot persistence um which would require modifying the flash and we need enough space 00:31:25.250-->00:31:30.822 there to, to insert uh the implant. Or which is what Triton did we just go fully memory 00:31:30.822-->00:31:36.161 resident uh and that requires executable RAM um but it does mean that on reboot the implant 00:31:36.161-->00:31:39.798 is gone. Now for safety controls, this is not that relevant because these have an 00:31:39.798-->00:31:45.403 extremely high up time. So then if it would be gone upon reboot, ya know it’s probably gonna be 00:31:45.403-->00:31:49.174 there all the time anyway. Uh this has the added benefit for the attacker that it does 00:31:49.174-->00:31:54.312 complicate forensics. Um, this, the other thing you want to think about when designing an 00:31:54.312-->00:31:58.550 implant is the scalability of the implant. So you want to target devices that are common 00:31:58.550-->00:32:03.789 throughout ICS. So not only for 1 particular facility, you might be interested in but across 00:32:03.789-->00:32:08.193 different kind of facilities, different kind of industries and Triconex fits this bill so there 00:32:08.193-->00:32:14.599 are 80-->000 or more than 80-->000 um Triconex systems in over 80 countries. So having these kind 00:32:14.599-->00:32:19.471 of capabilities is, is very interesting from a strategic point of view. Um you also want 00:32:19.471-->00:32:24.142 to target if you’re targeting software instead of controllers you want to target the software 00:32:24.142-->00:32:28.446 that is common throughout ICS so use the cross multiple vendors. So, protocol and connectivity 00:32:28.446-->00:32:33.451 stacks are usually reused by multiple vendors so ya know having exploits for that kind of 00:32:33.451-->00:32:38.256 stuff really scales well and same goes for cultural run times or, or the operating systems in 00:32:38.256-->00:32:44.296 question. Um you basically want to construct an arsenal of exploits and implants against 00:32:44.296-->00:32:48.600 common devices and software stacks. Because that means that it is a 1 time up front 00:32:48.600-->00:32:53.705 investment and now there is no huge turnover in these devices, these, these have an extremely 00:32:53.705-->00:32:58.944 long uh field life. They, they get deployed for 10, 20 years. They don’t get updated very 00:32:58.944-->00:33:04.149 often, ya know i-if there are even updates out there so if you invest once in an arsenal for 00:33:04.149-->00:33:08.887 let's say all safety controllers that are relevant in the market right now, it’s gonna be an 00:33:08.887-->00:33:12.724 investment that’s gonna be paying off for a long time. So Triton makes more sense as a 00:33:12.724-->00:33:17.028 tool in such an arsenal than a very expensive 1 off that’s engineered for this particular 00:33:17.028-->00:33:23.001 attack. So that brings us to the reverse engineering of the ICS firmware. Uh the first thing 00:33:23.001-->00:33:26.905 you’ll have to do is extracting the firmware. So you’ll have to determine the firmware format 00:33:26.905-->00:33:31.309 and the back, uh sometimes there will be firmware for multiple chips on the board or data 00:33:31.309-->00:33:34.713 blocks and they’re glued together and you’ll have to get them out of the firmware and 00:33:34.713-->00:33:38.817 then you’ll have to do the decompression and the decryption if, if there is uh any of that 00:33:38.817-->00:33:42.821 present. Uh this might be simple ya know, keys might be present in the firmware uh loading 00:33:42.821-->00:33:46.491 utility or you might have to actually do side channel attacks. In the case of Triconex 00:33:46.491-->00:33:50.962 this was very easy because the firmware was unencrypted so ya know basically this step could 00:33:50.962-->00:33:55.533 be skipped. Uh the step that you do after that is preprocessing the firmware. So you need to 00:33:55.533-->00:33:59.437 obtain a memory map you need to know where on this chip does the ROM live, where does the RAM 00:33:59.437-->00:34:03.508 live, where does the external memory live the special purpose registers for interacting with 00:34:03.508-->00:34:08.013 peripherals. All that kind of stuff and you typically get this from the data sheet. So very 00:34:08.013-->00:34:13.685 important if you do that kind of stuff you need to learn to love data sheets. So after you know 00:34:13.685-->00:34:18.690 basically the lay of land here um you go about identifying the base address. So you need to 00:34:21.860-->00:34:28.500 know where are this particular firmware image is loaded into memory. Now there are many 00:34:28.500-->00:34:32.971 approaches here and, and this is a gross o- over implication but we simply don’t have the time to 00:34:32.971-->00:34:37.842 go into all the details but this could be as simple as you know being loaded as a chip fixed 00:34:37.842-->00:34:42.580 address. Uh you can reverse engineer the update utility and uh, see where it places it or 00:34:42.580-->00:34:46.785 you can extract it from something like the inter-vector table or the bootloader, or self 00:34:46.785-->00:34:52.390 relocating coding, code jump tables, string tables, all that. Let’s consider for example uh 00:34:52.390-->00:34:57.128 this RTC firmware uh piece. This is uh piece of firmware for remote terminal unit that’s 00:34:57.128-->00:35:01.800 deployed somewhere in the field. Uh its’ ARM based and we have this piece of firmware, we don’t 00:35:01.800-->00:35:07.305 know what the base address is so we loaded at just address zero. And we see all these, these 00:35:07.305-->00:35:13.979 different, um, umm basically branches. Does anybody recognize what this is? Yeah a couple of 00:35:13.979-->00:35:20.251 people. Well yeah, that’s the inter-vector table of, of, of an ARM chip so the first uh, the 00:35:20.251-->00:35:26.691 first entry is uh, a branch to the reset handler and basically if we look at the offset we have 00:35:26.691-->00:35:32.097 100 as an offset here and here we have 102. If we look at that offset we see a lot of toggling 00:35:32.097-->00:35:36.401 with like these, these special purpose registers and that’s very typical behavior of a rest 00:35:36.401-->00:35:43.108 handler. So if we then deduct uh, uh the, the, the 1-->000 basically that becomes the base 00:35:43.108-->00:35:47.178 address, we re-base the firmware image and we can see that it cleans up nicely. Now we know 00:35:47.178-->00:35:52.617 how to load it into memory. So after you’ve done this ya know where to load it, you know where 00:35:52.617-->00:35:56.855 everything is, is laid out. You have to reconstruct the complete code and data topology of the 00:35:56.855-->00:36:01.760 firmware. Uh firmware images are not neat executable formats like, like PE, or ELG, or 00:36:01.760-->00:36:06.765 Mach-O. I mean your mileage might vary for what qualifies as a neat executable format but 00:36:06.765-->00:36:12.370 this definitely not it. Um, we will have to heuristically identify the functions in there, 00:36:12.370-->00:36:17.842 the strings, the jump tables the structs and all that kind of stuff. Um on the up side, this 00:36:17.842-->00:36:21.446 is, this is usually the bulk of the work, doing lal the reverse engineering. The upside is we 00:36:21.446-->00:36:25.550 don’t have to reverse engineer the full front row, only up until readiness for this next 00:36:25.550-->00:36:29.454 step. You because we want to hunt for interesting functionality we want to reverse 00:36:29.454-->00:36:34.325 engineer in a sniper like fashion. Uh so we want to know, how, how does the control 00:36:34.325-->00:36:38.596 runtime work? That actually interprets and handles this, this safety logic. Where are the 00:36:38.596-->00:36:43.201 protocol parsers, um where are the, the communication and peripheral IO handlers. Where is 00:36:43.201-->00:36:47.872 any security and safety related functionality there? So what, what would this look like for 00:36:47.872-->00:36:52.877 the Triconex 3008 which was targeted by the Triton a-attack? Well um, it, e- it’s firmware 00:36:54.913-->00:36:59.751 that’s PowerPC based which is nice because the Hex-Rays decompile is available for that 00:36:59.751-->00:37:03.688 and that saves you uh a lot of work. It’s not a subsite of reading the disassembly but it 00:37:03.688-->00:37:09.127 eases your navigation uh across this firmware. Uh it uses a custom uh operating system with 00:37:09.127-->00:37:15.667 27 system syscalls and some sparse documentation uh exists. Thank you NRC. Um basically this 00:37:15.667-->00:37:19.237 is what the operating system looks like. You have a scan task a communication task and a 00:37:19.237-->00:37:24.342 background task and we’re really only interested in a scan task which fetches inputs from shared 00:37:24.342-->00:37:30.415 memory which is where all the, the uh analog and digital IO uh gets put. Then we do a TriBus 00:37:30.415-->00:37:35.520 transfer for the voting on, on consistency. Um and then we run the actual control logic and 00:37:35.520-->00:37:39.691 then we send the outputs again, to the, to the uh shared memory and basically just implement all 00:37:39.691-->00:37:45.029 these control loops. Um so the targets here would have been the memory layout and management 00:37:45.029-->00:37:49.667 because we want to ya know achieve this memory residency so we need to know how to do that. 00:37:49.667-->00:37:53.338 Then we need to look for consistency checks and diagnostic functionality for 00:37:53.338-->00:37:57.108 implant stability. We don’t want anything um messing with our implant while we’re running. Um 00:37:57.108-->00:38:01.379 we need to know where the network command dispatcher functionality is because we want 00:38:01.379-->00:38:06.017 to be able to communicate with it over the network and achieved that. Um we want to be able to 00:38:06.017-->00:38:10.522 know if there is any privilege mode management. We want to do anything we can in this device 00:38:10.522-->00:38:15.293 so if there is privilege management we want to escalate them. Yeah. Um so and possibly 00:38:15.293-->00:38:20.298 finally we need to know the scan task and, and I/O transfer stuff. So that’s basically what 00:38:22.734-->00:38:28.406 the Triton implant looks like and does so it has 4 stages. It has an argument center, uh an 00:38:28.406-->00:38:32.644 implant installer, the backdoor implant and then the missing OT payload. Uh so the argument 00:38:32.644-->00:38:37.715 center it’s not that interesting but it basically controls the, the finite state machine of this 00:38:37.715-->00:38:43.288 thing. Which does at first if you can see that properly uh it does uh an exploit for privilege 00:38:43.288-->00:38:47.892 escalation and then basically it relocates the, uh the implant, the third stage. So the 00:38:47.892-->00:38:52.430 privilege escalation exploit it looks complicated but it’s not, it’s basically a write for any 00:38:52.430-->00:38:57.735 because of um improper uh handling of, of memory privileges. Um that allows you 00:38:57.735-->00:39:03.007 to write this address to, uh this, this value to this address. What does this mean? Um 00:39:03.007-->00:39:07.946 bascially what happens is that once you invoke a system call on this particular firmware, uh it 00:39:07.946-->00:39:12.483 saves the machine state register and when it returns it restores it and it is stored at this 00:39:12.483-->00:39:16.855 particular address that anyone can write to regardless of privileges so if we overwrite it 00:39:16.855-->00:39:22.760 with this value we set bit 17 to supervisor privileges and escalate it. And that allows us 00:39:22.760-->00:39:27.298 to do this next step to install the implant. The first of which his copying the payload into the 00:39:27.298-->00:39:31.836 firmware area of memory which allows us to have residence even if they wipe all the safety 00:39:31.836-->00:39:38.476 logic on the controller. Then we batch uh, uh an entry in the jump table which uh allows us to 00:39:38.476-->00:39:43.581 uh, to hook a natural command and then invoke our uh our implants when this particular 00:39:43.581-->00:39:48.886 network command is um, is called. And finally we patch a certain RAM check which was used 00:39:48.886-->00:39:53.091 for consistency between the firmware and ROM and in RAM which would otherwise mess with 00:39:53.091-->00:39:58.930 our, uh our stuff. And this basically the backdoor implant like Marina mention uh it allows 00:39:58.930-->00:40:05.169 for reading, write and executing arbitrary memory and basically allows you to overwrite this, uh 00:40:05.169-->00:40:08.873 this key switch so once you implant it, it doesn’t’ matter what, what position they turn 00:40:08.873-->00:40:13.144 the key switch into it allows you to uh execute anything you want in memory. So we have 00:40:13.144-->00:40:19.851 persistence uh on this device. So the, the 4th stage which is, which is uh the most engineering 00:40:19.851-->00:40:25.056 related is the OT payload. And this was missing um because this carries out the meat of the 00:40:25.056-->00:40:30.928 attack and we can only speculate what this might have looked like. Uh and that’s something 00:40:30.928-->00:40:36.134 we’ll do. So because Triton is, is positioned here in the, the attack tree, the control and 00:40:36.134-->00:40:41.139 safety system this is what the OT payload would’ve been related to. So basically um, it could 00:40:43.608-->00:40:49.113 have been for example an I/O spoofing scenario and that would have been a scenario that Marina 00:40:49.113-->00:40:53.484 would have uh given to me and said ya know we want to do spoofing of input and output 00:40:53.484-->00:40:57.655 values. As you can see for example here I have measurement values they come as an input 00:40:57.655-->00:41:01.259 signal to the controller and as an output signal go to the instrumentation. And then we 00:41:01.259-->00:41:05.496 want to mess with either the input or the output to cause some unsafe state. Now 00:41:05.496-->00:41:09.600 internally this looks like this on these devices. So you have the physical I/O you have the 00:41:09.600-->00:41:14.672 logic and there is an intermediary variable table that, that manages this. On the 00:41:14.672-->00:41:20.144 Triconex this is handled by an I/O processor that has shared memory connection to the main 00:41:20.144-->00:41:25.483 microcontroller and that’s where it places this variable table. So we didn’t have a Triconex 00:41:25.483-->00:41:29.954 controller but we did have a Wago PLC and I mean i- it basically comes down to the same 00:41:29.954-->00:41:35.960 thing. Uh it’s an ARM Cortex uh PLC running Realtime l- uh Linux it has a vulnerability CODESYS 00:41:35.960-->00:41:41.032 runtime on TCP that you can explode uh remotely and gain root. And basically, what we do 00:41:41.032-->00:41:46.504 in our attack is we use the CPU debug registers to catch any access to this memory mapped 00:41:46.504-->00:41:51.642 I/O. And that we write a custom exception handler that gets invoked when this, this uh debug 00:41:51.642-->00:41:56.614 trap is invoked and we change the pin mode for example from output to input. So any writes 00:41:56.614-->00:42:01.352 that would have been going to an actuator like closing a valve are now going to an input bin 00:42:01.352-->00:42:06.557 and they don’t actually go out. And we have a little demo of this, uh that should be coming 00:42:06.557-->00:42:13.197 up. I’ll we don’t have a lot of time but. Alright so what you can see here is you have the 00:42:13.197-->00:42:18.936 Wago PLC on the right and then you have LET, which is our stand in for ya know both valve and 00:42:18.936-->00:42:23.941 it’s supposed to be blinking every couple of seconds and now you can see it, yeah now you can 00:42:28.913-->00:42:35.019 see basically on the engineering uh software and the attacker will soon yeah I can’t really 00:42:35.019-->00:42:40.024 skip anything here but um, there should pop up like a shell at some point. There you can see 00:42:56.941-->00:43:01.879 light blinking there. Alright, yeah so ya know this is a root shell on the PLC, we execute our 00:43:07.819-->00:43:11.956 payload which is basically a line ex-kernel module that does this uh thing I just mentioned 00:43:11.956-->00:43:17.361 about the CPU debugger registers and then we stop it and you can see the light will stop blinking 00:43:17.361-->00:43:23.334 while it should be consistently blinking because it, ya know it now thinks its an input bin. And 00:43:23.334-->00:43:28.539 then at some point ya know we’ll change it back again to an output bin then you can see it 00:43:28.539-->00:43:33.544 starting blinking again. Right if this was a valve it would have been have it had an impact 00:43:38.216-->00:43:43.221 it’s a light and ya know it’s just a demo. So that brings us to the second possible payload 00:43:46.757-->00:43:52.897 which is alarm suppression. So let's say we want to mask for example wi-with a chemical 00:43:52.897-->00:43:58.836 process like this and our goal is catalyst deactivation. Now, um industrial processes they 00:43:58.836-->00:44:03.174 have alarms so if, if something is about to go into an unsafe state or something is, is out of 00:44:03.174-->00:44:06.944 bounds an alarm is raised somewhere in the process and these are propagated trial 00:44:06.944-->00:44:11.215 process and eventually leads to a safety shut down. And as an attacker we want to prevent this 00:44:11.215-->00:44:16.554 because we want the attack to continue. So how do we go about this? We can hide the alarms by 00:44:16.554-->00:44:23.227 compromising like the safety view or the uh TCS uh, uh view or some local HMI’s and this is 00:44:23.227-->00:44:27.398 the benefit of, of ya know hiding them centrally but still these alarms go out as network 00:44:27.398-->00:44:31.736 traffic right? And we don’t want any kind of, of network inspection to see this alarms. 00:44:31.736-->00:44:36.841 So we want to suppress them either at the field level, level of the field devices or at level 00:44:36.841-->00:44:41.679 of the safety controller itself. Which is what Triconex is. So for Triconex you have safety 00:44:41.679-->00:44:47.185 view which is a PC based HMI uh solution, at least management and bypasses of all these alarms 00:44:47.185-->00:44:51.889 and each HMI function is mapped to Triconex logic function block. And that looks somewhat 00:44:51.889-->00:44:56.627 like, whoop that was a little bit too quick. That looks something like this. So you have 00:44:56.627-->00:45:01.699 uh for example a water tank level alarm here. You have water high, water low signal and and 00:45:01.699-->00:45:06.704 all of them raises an alarm. So, as an attacker, these, these safety programs reside in memory 00:45:09.073-->00:45:14.045 as code. Which is how we got ya know code execution in the first place. So the OT payload here 00:45:14.045-->00:45:19.850 could modify the instructions to set the alarm to a fixed false regardless of the water levels 00:45:19.850-->00:45:24.155 that are coming as inputs to this alarm function. Uh the attacker needs to know of course 00:45:24.155-->00:45:28.826 first where the program lives in memory and which instructions of the program to madi- modify. Now 00:45:28.826-->00:45:32.863 luckily for Triconex these programs are stored as a circular linked list in memory 00:45:32.863-->00:45:37.401 as you can see here. This is actually our implant living in memory and then you can walk to 00:45:37.401-->00:45:42.406 link list and find the target program you want to modify, and this is what basically, the, the 00:45:42.406-->00:45:46.711 alarm looks like, the, the core of the logic is a simple orange instructions which the attacker 00:45:46.711-->00:45:51.349 can then ya know hot batch, it’s, it’s uh PowerPC it’s a risk architecture with a fixed 00:45:51.349-->00:45:56.053 instruction size so just set it to a fixed false there. It’s relatively easy and this is the 00:45:56.053-->00:45:59.624 result that comes out of it. On the left you have normal functionality, ya know water is 00:45:59.624-->00:46:03.461 getting dangerously high, the alarm is going off. On the right you have the exploited 00:46:03.461-->00:46:08.132 functionality, water is getting dangerously high, alarm is sleeping. Alright, so some more 00:46:08.132-->00:46:14.005 speculation, why did this attack fail? Uh I don’t think we mentioned that but uh the attack 00:46:14.005-->00:46:19.110 was discovered because it failed uh in the um in the actual field. It caused a safety shut 00:46:19.110-->00:46:23.547 down of the process. Um, there are couple of, of, of possibilities. You could have 00:46:23.547-->00:46:27.685 had a b0rked payload. Ya know, d- the privilege escalation could have failed. It could have 00:46:27.685-->00:46:31.989 targeted different firmware version than they actually had, had developed the exploit for 00:46:31.989-->00:46:37.395 which could have caused um, uh an access violation. I mean the backdoor allows for raw reading, 00:46:37.395-->00:46:40.731 writing and executing of memory. Uh they could have caused some memory corruption by uh, uh, ya 00:46:40.731-->00:46:46.637 know, uh, a payload that was written wrongly. Uh they could have gotten into a fight with 00:46:46.637-->00:46:50.908 the watchdog. So very common on the embedded system you have a watchdog timer and you need to 00:46:50.908-->00:46:55.846 periodically kick it to, to keep the counter high because if the counter expires it resets the 00:46:55.846-->00:46:59.517 CPU. Uh or they could have missed some additional diagnostics. I mean there’s a 00:46:59.517-->00:47:04.088 ton of diagnostics functionality in here and just because the batched uh the RAM and uh ROM 00:47:04.088-->00:47:08.459 check doesn’t mean that they, they batched everything rightly. These are all options. Another 00:47:08.459-->00:47:12.997 option is that they got into a fight with a triple module redundancy. I meant this, this 00:47:12.997-->00:47:18.502 is just a floating on the inputs and the outputs but it’s a very complicated uh patent uh that 00:47:18.502-->00:47:24.075 has a lot that covers a lot of ground and it could have been that the OT payload violated uh 00:47:24.075-->00:47:28.813 something in the triple modular redundancy that in turn led to uh safety shutdown. That brings 00:47:28.813-->00:47:33.851 us to the conclusions which I’ll give to Marina again. >>Well we probably have just like couple 00:47:33.851-->00:47:38.956 of minutes for conclusions so just to summarize like so, ehm, again the purpose was also to go 00:47:38.956-->00:47:44.028 through this process of develop implants for embedded systems to see if it really is complicated 00:47:44.028-->00:47:49.233 so what is the actual uh, real threat? Is it also only for a lit and we should not expect 00:47:49.233-->00:47:54.371 this type of attack or implant on a mass scale or not? And apparently it is not. Not only 00:47:54.371-->00:47:59.944 that exploitation and implanting of uh industrial control systems relatively easy uh like it’s 00:47:59.944-->00:48:04.315 cheap because there is no any exploit mitigations but also obtaining the equipment 00:48:04.315-->00:48:08.786 relatively easy. We went through the process, obtaining the equipment was relatively easy so 00:48:08.786-->00:48:15.392 you kind of have all the need components to, uh quickly obtain code execution and be able to 00:48:15.392-->00:48:20.397 backdoor this type of devices. So ehm, exploit development again uh easy if I will just go 00:48:22.933-->00:48:28.139 quickly so there is, implant development, relatively easy so for example in case of Triton, 00:48:28.139-->00:48:31.342 that attack already had privileges. Typically on industrial control system you 00:48:31.342-->00:48:36.447 would not have p- uh separation of privileges so that attacker had privileges to escalate his 00:48:36.447-->00:48:41.452 privileges. Neat. So how probably. For example in case uh safety system you typically have 00:48:44.922-->00:48:48.959 this triple uh redundancy sometimes it quadruple redundancy which makes things a 00:48:48.959-->00:48:53.664 little complicated because you have to uh reverse engineer more. So the most difficult part 00:48:53.664-->00:48:59.403 which we were able to establish is actually developing OT payloads so basically my task is 00:48:59.403-->00:49:05.943 harder. Um, and especially but never we come together like for example Jos and I come together, 00:49:05.943-->00:49:12.349 this is my wishlist and he already has the implant. This is where reverse engineering 00:49:12.349-->00:49:17.354 started g- going further and that is becoming more difficult. So ehm, um so uh, basically yes, 00:49:19.657-->00:49:24.662 s-so the open questions which we have and this is I, I think Jos has covered it very nicely that 00:49:28.199-->00:49:33.204 it probably just what we’ve seen is just 1 tool among uh, uh many. Um ehm, uh so basically 00:49:36.340-->00:49:41.345 development cost should be seen as relatively low. Uh and, um I think we should work with, 00:49:43.647-->00:49:48.752 definitely should expand relatively uh soon is copycat. Security is a fashionable 00:49:48.752-->00:49:55.025 industry so as soon as you like for example somebody will release a first like a malware, 00:49:55.025-->00:49:58.162 everybody will be designing in somewhere, malware. So this is what we going probably to see so 00:49:58.162-->00:50:03.167 many more other like s-state sponsored uh threat actors will join this basically game and in 00:50:05.202-->00:50:09.907 the game it’s not necessarily so this is what like people online yes it’s easy to exploit and why 00:50:09.907-->00:50:13.878 don’t we see lot of those attacks. Because first of all you have to have a motive, why 00:50:13.878-->00:50:19.483 would you do that? And secondly of course like crossing the s- red line. So 1 hand it will 00:50:19.483-->00:50:23.220 probably be something like the nuclear weapons you’ll have the arsenal and maybe you’ll be 00:50:23.220-->00:50:28.125 showing the capability just in the slight manner like it’s happened in power grid attacks 00:50:28.125-->00:50:34.531 in Ukraine. You show you’re capable but you do not cause mass like damage which hurts. So 00:50:34.531-->00:50:39.737 you basically will be having it as a like uh, uh economical and political negotiation. So we 00:50:39.737-->00:50:44.909 wanted to thank a couple of people included Felix Lindner, he was like a frequent DefCon 00:50:44.909-->00:50:51.715 speaker who ehm, kindly uh, helped us to review this slides. Uh we have a slight was it 00:50:51.715-->00:50:55.486 toolkit which you will need and with that we are at the end and thank you very much for your 00:50:55.486-->00:50:59.523 attention. [applause]