1 00:00:03,140 --> 00:00:08,020 All right. Thank you, everyone. Yeah, as he mentioned, we're going to be talking about some 2 00:00:08,020 --> 00:00:14,460 hacking of data center power equipment and components. So let's dive right in. My name is Sam 3 00:00:14,460 --> 00:00:20,740 Quinn. I'm a lead senior security researcher at Trellix. You can find me at Twitter or X or 4 00:00:20,740 --> 00:00:25,940 whatever they're going to call it next week at EIP. My core technical interests include 5 00:00:25,940 --> 00:00:33,980 exploitation, hardware hacking and embedded systems and IOT devices. And I'm Jesse Chick. I'm a 6 00:00:33,980 --> 00:00:38,780 security researcher who does not have a company, Amex. And you can find me on Twitter at 7 00:00:38,780 --> 00:00:44,740 Ravenous Bytes. And I'm really into full system emulation, reverse engineering of all kinds, and 8 00:00:45,200 --> 00:00:52,060 Sam and I share a passion for hacking IOT and embedded systems. All right. So let's dive into 9 00:00:52,060 --> 00:00:55,920 what is a data center. Of course, this is the ideal picture. I'm going to be talking about 10 00:00:55,920 --> 00:01:00,840 what everyone sees in their mind. However, it really actually just looks like a sterile 11 00:01:00,840 --> 00:01:07,420 environment with servers. The term data center kind of referred to multiple things. It could be 12 00:01:07,420 --> 00:01:12,560 the facility itself that houses a lot of these servers and cage spaces like this or an 13 00:01:12,560 --> 00:01:18,140 individual cage space kind of shown in this picture or a co-located server rack that 14 00:01:18,140 --> 00:01:25,200 companies call their data center. For the context of this talk, both utilize similar power 15 00:01:25,200 --> 00:01:31,260 equipment, so it's kind of interchangeable there, but it's something to bring up. The next is why 16 00:01:31,260 --> 00:01:36,360 we chose to even hack data centers in the first place. For one, there's a lot of company 17 00:01:36,360 --> 00:01:41,940 initiatives to go full cloud. Trellix, my company, is one of those. There's also some 18 00:01:41,940 --> 00:01:49,640 national interest to improve cyber security. It's the number one item in this national cyber 19 00:01:49,640 --> 00:01:55,000 security strategy. And then last year, I guess, there was some, like, bipartisan bill 20 00:01:55,000 --> 00:02:00,160 even, and I thought it was funny because they, in quotes, keep our data safe. They're trying to 21 00:02:00,160 --> 00:02:06,500 get more money to do that. So we wanted to check out how they're really doing in that respect. So 22 00:02:06,500 --> 00:02:13,900 our approach was to actually, like, ask some industry experts in data center configuration and, 23 00:02:13,980 --> 00:02:19,440 like, the people that actually run data centers, like, what would be good attack vectors for us to 24 00:02:19,440 --> 00:02:23,700 research? And we asked them, like, what keeps them up at night? And one of the things that they 25 00:02:23,700 --> 00:02:28,280 always mentioned was when there's no power, you really can't do anything. So power is a big 26 00:02:28,280 --> 00:02:34,260 equipment or a big component of data centers that we definitely wanted to look at. So that was kind 27 00:02:34,260 --> 00:02:43,080 of some inspiration for us. There's also quite a few brands and unique devices that people use in 28 00:02:43,080 --> 00:02:49,000 their data centers. They have quite a variety there. But they're all controlling critical stuff 29 00:02:49,000 --> 00:02:53,680 if you kind of think back to the data center itself. And then lastly, we wanted to do some 30 00:02:53,700 --> 00:02:58,200 research. There's little to none end-to-end vulnerability research that we found in the field. 31 00:02:58,320 --> 00:03:04,160 So this is kind of the first step that our team is doing into trying to figure out a kind of a 32 00:03:04,160 --> 00:03:10,000 holistic audit of data center security. And, of course, we started with that power one from those 33 00:03:10,000 --> 00:03:16,700 industry experts. The first product or target, I should say, that we looked at is this DSIM. It's 34 00:03:16,700 --> 00:03:22,180 a data center infrastructure management. I'll be saying DSIM from here on out because that's quite 35 00:03:22,180 --> 00:03:23,680 a mouthful. It's a data center infrastructure management. I'll be saying DSIM from here on out 36 00:03:23,700 --> 00:03:23,720 because that's quite a mouthful. It's a data center infrastructure management. I'll be saying 37 00:03:23,720 --> 00:03:24,380 It's a data center infrastructure management. It's a data center infrastructure management. A DSIM, though, 38 00:03:24,440 --> 00:03:31,440 is used by IT administrators to, like, manage, configure, and monitor all of the components inside 39 00:03:31,440 --> 00:03:38,460 of a data center, even including, like, capacity planning or even, like, logging and, of course, 40 00:03:38,500 --> 00:03:44,420 controlling some of the critical components like PDUs or power that is used in that data center. 41 00:03:45,400 --> 00:03:51,020 This is, in a way, like a single pane of glass for a lot of these administrators to manage the 42 00:03:51,020 --> 00:03:53,680 data center components. And, of course, we started using PDFs, which are very microcontinuous 43 00:03:53,680 --> 00:03:58,840 because no one goes into data centers, no one wants to at least, this also allows for remote 44 00:03:58,840 --> 00:04:06,500 management, which is what we kind of thought that this was juicy for. The kind of scenario we 45 00:04:06,500 --> 00:04:13,820 want to portray for the kind of our talk here is how we envisioned this attack being like 46 00:04:13,820 --> 00:04:18,960 chained together and multiple vulnerabilities of how you can as an attacker get into a data 47 00:04:18,960 --> 00:04:24,560 center. So if you can imagine this DSIM software is running either on in the cloud or even on 48 00:04:24,560 --> 00:04:33,560 a on-prem server, some on the network, somewhere on that. From talking to like the experts in data 49 00:04:33,560 --> 00:04:37,380 center configuration, they mentioned that a lot of the critical stuff that's inside the cage 50 00:04:37,380 --> 00:04:43,360 space or data center itself would be on particular VLANs or fired while off from the greater 51 00:04:43,360 --> 00:04:48,940 network. However, if you can imagine via this like blue arrow here, that the data center 52 00:04:48,960 --> 00:04:54,520 is already set up to manage those and get logs back and forth, that there are those 53 00:04:54,520 --> 00:04:59,280 communication channels already in place, meaning that if we can attack this DSIM, we could 54 00:04:59,280 --> 00:05:04,860 potentially utilize those communication channels through those firewalls and management VLANs and 55 00:05:04,860 --> 00:05:10,540 whatnot and gain access to the devices inside the data center. The software that we ended up 56 00:05:10,540 --> 00:05:18,940 looking at first was this CyberPower PowerPanel Enterprise, which is quite a mouthful there. This is one of the software 57 00:05:18,960 --> 00:05:25,940 that would be able to manage the infrastructure in the data center. One reason that we thought it was a 58 00:05:25,940 --> 00:05:32,440 good target was for one, it's free. Second, it has both Windows and Linux support, but also that 59 00:05:32,440 --> 00:05:38,920 Enterprise really caught our attention. At a glance, it's a typical web application, meaning that 60 00:05:38,920 --> 00:05:45,600 it's all of the good stuff is hidden behind a login page and there's no other unauthenticated 61 00:05:45,600 --> 00:05:48,820 endpoint that you can get to without first getting past this. 62 00:05:48,960 --> 00:05:59,340 It runs HTTP by default, so there's that, but it also uses C-sharp as the server that runs the 63 00:05:59,340 --> 00:06:04,220 application, and then a SQL database backend. And those will kind of make more sense a little bit 64 00:06:04,220 --> 00:06:11,340 further as we go through this initial recon stage. What we ended up doing right off the bat is 65 00:06:11,340 --> 00:06:17,100 actually looking how the software sets up its database initially through the installer scripts. 66 00:06:17,460 --> 00:06:18,820 And one thing we noticed here 67 00:06:18,960 --> 00:06:24,780 highlighted in red is these two users that are actually kind of in there by default, they don't 68 00:06:24,780 --> 00:06:30,520 change later. So these are like default users, CyberPower and SI. And they have these encrypted 69 00:06:30,520 --> 00:06:35,580 passwords right next to them and then the salts for that encryption here. At first, I 70 00:06:35,580 --> 00:06:41,740 definitely thought it was Base64, but it is actually indeed an AES encrypted password and not 71 00:06:41,740 --> 00:06:46,680 even a hash of the password, meaning that the password can be fully extracted out if those AES 72 00:06:46,680 --> 00:06:48,940 passwords are ‑‑ or that AES password is not fully extracted out. So that's a little bit of a 73 00:06:48,940 --> 00:06:52,520 mystery. But we found that the password is found. So that's exactly what we ended up trying to do. 74 00:06:52,680 --> 00:06:58,220 And C-sharp, if you don't compile it with extra protections, is practically open source if you use 75 00:06:58,220 --> 00:07:04,200 the right tools. So we used DN spy and actually got this amount of detail out of just the 76 00:07:04,200 --> 00:07:10,360 disassembly here. And looking through that, we found this decrypt AES function that had the AES 77 00:07:10,360 --> 00:07:16,740 password, it seems like here, but it slightly obfuscated. I'm sure we could have figured out how 78 00:07:16,740 --> 00:07:18,920 to do it. But DN spy has a handwritten code. So we're going to try to find out how to do that. 79 00:07:18,920 --> 00:07:23,900 It's a handy feature of being a debugger as well. So just setting a break point on something that 80 00:07:23,900 --> 00:07:31,060 calls that, you can get the AES password out in plain text, which is weutech for some reason. The 81 00:07:31,700 --> 00:07:39,740 next bit is because the decompiled representation of the application is so good, you can actually 82 00:07:39,740 --> 00:07:44,920 just copy it out and then run it in its own C-sharp function. So that's what I did. I just 83 00:07:44,920 --> 00:07:51,160 copied that decrypt AES function out into its own file, passed in those encrypted values plus the 84 00:07:51,160 --> 00:07:57,060 salt, and we're able to get these default credentials in plain text. So this was our first 85 00:07:57,060 --> 00:08:03,140 CVE that we filed against the cyber power here. However, it wasn't all the sunshines and 86 00:08:03,140 --> 00:08:09,820 rainbows for using that as a means to bypass authentication. When we passed those in, we 87 00:08:09,820 --> 00:08:14,620 actually were greeted with a login failed. And looking deeper into why that happened, 88 00:08:14,920 --> 00:08:24,080 was they have checks for that default user and eventually will hit this failed to log in result. 89 00:08:24,880 --> 00:08:32,360 But kind of looking at that, one of our researchers was kind of interested in seeing how strong 90 00:08:32,360 --> 00:08:38,160 that check is. And actually supplying a non-ASCII value like hex 01 here, was able to 91 00:08:38,160 --> 00:08:44,740 actually, for the C-sharp server, those are indeed different strings. So that code block didn't get 92 00:08:44,740 --> 00:08:49,860 hit. However, when the user name eventually gets passed down to the SQL database, somewhere in 93 00:08:49,860 --> 00:08:55,800 the line, that got stripped out and we were actually able to log in through that login page 94 00:08:55,800 --> 00:09:04,340 using these default credentials. And during that, we actually found an even cooler way. So 95 00:09:04,920 --> 00:09:10,520 we'll kind of dive into the second authentication bypass here now. So as I mentioned, there is 96 00:09:10,520 --> 00:09:14,720 this user name and password method of logging in to this DSIM software. And we're going to 97 00:09:14,740 --> 00:09:17,200 talk about that in a little bit. There's also an active directory component, as it makes sense. 98 00:09:17,320 --> 00:09:24,200 It's an enterprise-managed application. But also there was this LDAP function that kind of 99 00:09:24,200 --> 00:09:27,920 caught our eye. And of course, this is probably way too small to see, so I'll blow it up here. 100 00:09:28,340 --> 00:09:36,180 The LDAP function, when you supply an LDAP user, uses this validate user function block here. And 101 00:09:36,180 --> 00:09:42,180 you can see that it is checking if the function returns the string exception. For a long time, I 102 00:09:42,180 --> 00:09:44,720 was actually reading that as returning an exception. No, it's not returning an exception. 103 00:09:44,720 --> 00:09:51,240 No, it's the string exception from this validate user. And if it doesn't return an exception, then 104 00:09:51,240 --> 00:10:00,120 the status equals true and then you're logged in. However, looking at the code, LDAP must have 105 00:10:00,120 --> 00:10:06,600 meant like lazily disabled access protocol because it actually shows this function here, all it 106 00:10:06,600 --> 00:10:14,360 does is returns a blank string. And of course, that does not actually equal exception. So any 107 00:10:14,720 --> 00:10:21,280 person that tries to log in using this LDAP method just automatically gets authenticated. Which 108 00:10:21,280 --> 00:10:27,740 is pretty cool. So I'll go ahead and show that in a live demo here. Using the elite hacker tool of 109 00:10:27,740 --> 00:10:35,160 Firefox only. So you can see this is the login page. What we'll do next is just right click and 110 00:10:35,160 --> 00:10:41,420 open the hacker menu. Which is, and then you search for LDAP. You see that it says display none. 111 00:10:41,680 --> 00:10:44,700 We can go ahead and change that to block. And now we're going to go ahead and change that to block. 112 00:10:44,720 --> 00:10:50,560 Now just type in admin. No password necessary. Choose LDAP as the authentication method. And 113 00:10:50,560 --> 00:11:02,420 now you're fully logged in as admin. So at this point that's actually quite a big thing. 114 00:11:02,560 --> 00:11:09,400 Now you can actually read those logs. Manage the data center infrastructure. You know, that's 115 00:11:09,400 --> 00:11:14,520 one step that we really thought that was pretty impactful. However, I'm going to pass it over to 116 00:11:14,520 --> 00:11:23,840 Jesse to see how he took it even further. There we go. How's that? All right. So even though we 117 00:11:23,840 --> 00:11:30,000 were able to now carry out actions on the admin console with administrator privileges, that 118 00:11:30,000 --> 00:11:34,960 wasn't enough for us. We wanted to be able to go beneath the surface and start executing commands on 119 00:11:34,960 --> 00:11:42,420 the underlying Windows or Linux operating system. So why might we want to do that? Well, as Sam 120 00:11:42,420 --> 00:11:44,500 mentioned, once we compromise a DSIM, we can't do anything else. We can't do anything else. We can't do 121 00:11:44,500 --> 00:11:48,760 anything else. We now have the ability to, at least in theory, control things like power 122 00:11:48,760 --> 00:11:54,800 management and, you know, network switches and that kind of thing using the DSIM as an admin 123 00:11:54,800 --> 00:12:01,140 would. But we don't yet have the ability to pivot to that data center environment and start 124 00:12:01,140 --> 00:12:09,480 executing our own code on other devices potentially. So that's our next step is to be able to 125 00:12:09,480 --> 00:12:14,320 launch those kinds of attacks and we need operating system privileges for that. So let's see 126 00:12:14,320 --> 00:12:21,080 how we went about doing that. Well, we were able to get a near perfect decompilation from the 127 00:12:21,080 --> 00:12:26,100 end spy. So we started searching through for dangerous function calls, things like the 128 00:12:26,100 --> 00:12:30,840 equivalent of system and C or exec or something like that. In this case, it's this execute 129 00:12:30,840 --> 00:12:36,180 command function that you'll see at the bottom of that region boxed in red. And what's being 130 00:12:36,180 --> 00:12:41,120 passed to it is this command that begins with net use, which is how you add a new networking 131 00:12:41,120 --> 00:12:48,060 device in the Windows environment. So it looks like this command is being constructed using 132 00:12:48,060 --> 00:12:53,400 several variables that are clearly assigned elsewhere. So our first thought is could this be a 133 00:12:53,400 --> 00:12:59,040 good spot for a command injection? Are these values user controlled? And it turns out the 134 00:12:59,040 --> 00:13:04,460 three of them are. So when we traced back through the X refs all the way back to the front 135 00:13:04,460 --> 00:13:11,000 end, we realized that this particular block of code is invoked when somebody tries to 136 00:13:11,000 --> 00:13:17,220 add a remote network storage device for backup purposes or something like that. And so in order 137 00:13:17,220 --> 00:13:22,380 to test this hypothesis, we tried to inject our own PowerShell command via the user name 138 00:13:22,380 --> 00:13:29,140 parameter. And sure enough, as you can see, from this process explore output here, not only 139 00:13:29,140 --> 00:13:35,940 did PowerShell spawn but is running with system privileges. So this was the fourth CVE that we 140 00:13:35,940 --> 00:13:40,980 discovered on this device which is just your classic OS command injection. So the value is now 141 00:13:41,000 --> 00:13:44,900 So now we'll demonstrate how we can change the first authentication bypass that Sam 142 00:13:44,900 --> 00:13:51,560 mentioned with this command injection to achieve unauthenticated code execution. So in the top 143 00:13:51,560 --> 00:13:56,860 left there you'll see that we have a Python server that's going to be serving a text file that 144 00:13:56,860 --> 00:14:03,040 contains our reverse shell in PowerShell of course and in the top right we have a Netcat 145 00:14:03,040 --> 00:14:08,500 listener that's going to catch that excuse me reverse shell and we'll be executing our 146 00:14:08,500 --> 00:14:18,180 exploit from at the bottom. So first off there's the auth bypass, it's the first of the two 147 00:14:18,180 --> 00:14:26,060 that Sam mentioned with that X01 metacharacter and it's just going to save off the session ID into a 148 00:14:26,060 --> 00:14:35,120 local file called cookie.txt. So there you go, now we have our cookie. You can see what it 149 00:14:35,120 --> 00:14:36,740 looks like, it's long and disgusting. 150 00:14:41,480 --> 00:14:47,740 And now here is our exploit. So as I said before we're injecting by the user name 151 00:14:47,740 --> 00:14:53,160 parameter, others would have worked but we chose to stick with that one. And all we're doing here 152 00:14:53,160 --> 00:15:00,380 is instructing PowerShell to query our Python server, download hack.txt and then execute its 153 00:15:00,380 --> 00:15:08,480 contents as PowerShell. So clearly Sam's run it there, perfect and we can see that hack.txt is 154 00:15:08,500 --> 00:15:13,400 successfully downloaded, the command worked and now we have an interactive session on the 155 00:15:13,400 --> 00:15:18,540 underlying Windows operating system and are executing commands with the highest possible privileges. 156 00:15:26,400 --> 00:15:38,460 Which brings us to our second target which is a power distribution unit or PDU for the remainder of this talk. You can think of this as just a glorified power strip for a 157 00:15:38,500 --> 00:15:44,940 network. So we're plugging in your rack servers or network switches, that kind of thing. And the 158 00:15:44,940 --> 00:15:53,060 fancier ones actually get an IP on that local network and have a nice web based management interface for remote 159 00:15:53,060 --> 00:16:08,240 administration. So why might we want to target a PDU? Well, if we're able to access it directly and start executing attacks against it as we now are able to, having compromised, the 160 00:16:08,500 --> 00:16:16,260 data center network, we can do all sorts of things. We can for example cut power to core business resources. Or if we're able to fully 161 00:16:16,260 --> 00:16:27,820 pwn the device, we can establish persistence within that data center network and attempt to compromise other core services inside of that data center. So now I'll just 162 00:16:27,820 --> 00:16:38,480 introduce you to the particular product that we hacked which is the Dataprobe iBoot PDU. This is most likely to be found either on prem or in like small to mid 163 00:16:38,500 --> 00:16:48,420 sized data centers. Maybe used for some niche purposes in another setup. We discovered that ATMs are often hooked up to them, for example, interestingly enough. 164 00:16:49,520 --> 00:16:59,680 But one other thing that we found really intriguing about this product in particular is that Dataprobe offers this free cloud service which acts as a reverse proxy 165 00:17:00,160 --> 00:17:08,480 directly to the hardware device, meaning that if a user decided to enroll their device in the service, they would be able to access their management 166 00:17:08,500 --> 00:17:19,640 interface from anywhere in the world without having to have a VPN access or be within some secure intranet at a randomly generated subdomain under the iBoot 167 00:17:19,640 --> 00:17:29,260 web page, website rather. Another thing that made this a particularly attractive target to us is that all of the models, and there are 168 00:17:29,260 --> 00:17:38,480 about 20 of them for the U.S. and international markets, use the exact same publicly available firmware image. So right off the bat we were able to download it, 169 00:17:38,500 --> 00:17:44,760 unpack it and have a look around. And although static analysis got us a long way, we really 170 00:17:44,760 --> 00:17:50,340 wanted to have the ability to interact with the device at the process level and really see 171 00:17:50,340 --> 00:17:54,840 what's going on, read from memory and stuff like that. So that led us to full system 172 00:17:54,840 --> 00:18:00,160 emulation. And this wound up being a very powerful technique for us in the course of 173 00:18:00,160 --> 00:18:04,680 researching this product. And in fact all of the vulnerabilities that we are going to be 174 00:18:04,680 --> 00:18:11,040 disclosing today were discovered and verified hand wavily in this emulated environment. I 175 00:18:11,040 --> 00:18:16,780 should mention that eventually we did actually buy an iBoot PDU to make sure that they worked on 176 00:18:17,130 --> 00:18:23,540 the bare metal. But we already knew that that was almost a sure bet from the emulation. And so 177 00:18:23,930 --> 00:18:28,660 just for posterity's sake I'm going to do a quick run through of how we were able to get that 178 00:18:29,340 --> 00:18:34,340 emulated device set up. So let's just run through it really quickly. So we decided to use 179 00:18:34,340 --> 00:18:40,780 Kimu and given that there's an ARM chip on the device we installed the full system emulator for 180 00:18:40,780 --> 00:18:48,480 ARM and grabbed a fresh 32 bit VM off of the Debian web page. It was just hosted, already set up 181 00:18:48,480 --> 00:18:54,080 and configured on somebody's personal file space. So that was easy enough. And then we got it 182 00:18:54,080 --> 00:18:59,920 spun up using the following arguments. You'll notice this will appear in subsequent slides. 183 00:19:00,060 --> 00:19:04,320 That we mapped port 80 which is what they're serving the, what they're serving the 184 00:19:04,340 --> 00:19:13,480 website on to port 8080. Now once we were inside the VM we first of all pulled down a fresh 185 00:19:14,220 --> 00:19:20,520 firmware image which turns out just to be a tar file and extracted it and then decompressed the 186 00:19:20,520 --> 00:19:26,040 root file system. This was the only component that was necessary to be able to spin up all of the 187 00:19:26,040 --> 00:19:32,380 core services on the device. We then went through the rigmarole of setting up the appropriate mount 188 00:19:32,380 --> 00:19:36,920 points in order to get this to work properly. That took a little while. And finally, 189 00:19:37,020 --> 00:19:44,000 cherooted into that root file system using the onboard bash instance. At that point we tried to 190 00:19:44,000 --> 00:19:49,040 mimic the sequence of commands that are actually executed as the device is first booting up. 191 00:19:49,560 --> 00:19:55,000 Obviously some of them didn't work. This is emulation. It's not a perfect science. But we were 192 00:19:55,000 --> 00:20:01,080 able to eventually run that RCS script and have all of the core services up and running. And I 193 00:20:01,080 --> 00:20:05,420 should also mention that there were a ton of them. We wound up targeting the web page exclusively 194 00:20:05,420 --> 00:20:11,700 because that got us what we needed. But there were nearly ten I believe distinct attack vectors 195 00:20:11,700 --> 00:20:16,240 that we also could have looked at. But they all seemed to support the functionality available 196 00:20:16,240 --> 00:20:22,320 from the web page anyway. So that's where we started. And just to prove it to you all that we 197 00:20:22,320 --> 00:20:30,880 got this to work, here's the log in page running on local host which made us very happy. And so now 198 00:20:31,080 --> 00:20:36,680 we're going to talk about how we were able to get past that log in page. But before we can 199 00:20:36,680 --> 00:20:42,420 understand the root cause of the following vulnerability, we need to go over briefly what the 200 00:20:42,420 --> 00:20:49,320 normal authentication process on this device looks like. So under normal circumstances, the 201 00:20:49,320 --> 00:20:55,760 client will send their user name and a shoddily obfuscated password to the device. And 202 00:20:56,340 --> 00:21:01,060 assuming that it matches what the device has saved in its database, the client will send a 203 00:21:01,080 --> 00:21:06,960 message to the user that this set cookie header will be returned. Instructing the client to 204 00:21:06,960 --> 00:21:13,760 set a cookie called iBootPDU site off, which is just a URL encoded string that has two 205 00:21:13,760 --> 00:21:22,300 parameters. One is USR, which in this case actually is an abbreviation for user. And an MD5 hash 206 00:21:22,300 --> 00:21:29,800 of the corresponding password. So for any subsequent request made to one of those privileged web 207 00:21:29,800 --> 00:21:36,380 pages, the client will include this cookie and the device will then verify that those 208 00:21:36,380 --> 00:21:42,360 credentials are valid and assuming that they are, restricted content is returned. But we still 209 00:21:42,360 --> 00:21:47,980 need to zoom in a little bit further on what's going on here between steps three and four. So 210 00:21:48,470 --> 00:21:54,580 under normal circumstances, the client will issue their request, including the cookie, and the 211 00:21:54,580 --> 00:21:59,780 PDU will query its own onboard Postgres database, which contains all of the data that the client's 212 00:21:59,780 --> 00:22:05,260 using, including all of the user credential information. So assuming that the credentials it 213 00:22:05,260 --> 00:22:10,980 finds in the cookie match what it has on the database, privileged content is returned, no 214 00:22:10,980 --> 00:22:17,040 problem. However, in a malicious use case, and this is something of a spoiler, but I think that 215 00:22:17,040 --> 00:22:22,280 the 30,000 foot view here of what's happening is useful before we dive into the technical 216 00:22:22,280 --> 00:22:29,760 details. An attacker can supply a malicious cookie to the device and send a message to the user 217 00:22:29,780 --> 00:22:36,840 directly, direct it to query not its own trusted database, but an arbitrary database at any IPV4 218 00:22:37,320 --> 00:22:42,960 address of the attacker's choice. And assuming that that attacker has set up their rogue database 219 00:22:42,960 --> 00:22:51,500 correctly, then the passwords will match and that privileged content is returned. So before we get 220 00:22:51,500 --> 00:22:56,120 to looking at the root cause of the vulnerability, we have to do a quick review of the PHP 221 00:22:56,120 --> 00:22:59,760 function parser. I don't know about you, but I had never heard of parser. It's a little bit of a 222 00:22:59,760 --> 00:23:07,320 game. I'm not a PHP programmer, so I'm sure that this won't be a review for everybody. So here's the 223 00:23:07,320 --> 00:23:14,820 function signature. It takes two parameters. The first is called string. This is a URL parameter 224 00:23:14,820 --> 00:23:20,240 string basically. Just key value pairs separated by ampersands. And there's a second argument 225 00:23:20,240 --> 00:23:26,760 called result, which is just an associated array to store those key value pairs. However, in 226 00:23:26,760 --> 00:23:29,740 older versions of PHP, including the one that's now called the PHP file, which is the one that's 227 00:23:29,740 --> 00:23:36,160 that is used in the iBootPU product line to this day, you don't have to give that result 228 00:23:36,160 --> 00:23:42,720 parameter. And if you don't, then all of those key value pairs are instantiated as local 229 00:23:42,720 --> 00:23:48,740 variables in the current scope. So I'm sure I don't have to tell an audience like this that 230 00:23:48,740 --> 00:23:57,080 that's rather dangerous. And as such, there is a huge warning that appears on the PHP man 231 00:23:57,080 --> 00:24:04,340 page for this function that says, don't do this. Always put that result parameter in there. And, 232 00:24:04,480 --> 00:24:14,780 in fact, we're going to mandate that pretty soon. So problem solved, right? No. So this is 233 00:24:14,780 --> 00:24:19,420 that automatic log in mechanism that I talked about between steps three and four in a previous 234 00:24:19,420 --> 00:24:24,680 slide. And this is the entirety of that file. So let's just go through it line by line. After 235 00:24:24,680 --> 00:24:26,740 doing a couple of checks to make sure that the 236 00:24:27,080 --> 00:24:33,920 cookie is actually there, it then drops it straight into parser without that result 237 00:24:33,920 --> 00:24:39,860 parameter. Which means that all of these variables that I boxed here in yellow can be user 238 00:24:39,860 --> 00:24:45,600 controlled if they are included in that malicious cookie, including the IP address of the 239 00:24:45,600 --> 00:24:51,780 database to which the device establishes a session. Just for the record, get new link is 240 00:24:51,780 --> 00:24:57,060 simply a wrapper for PG connect, which is a library function for establishing a 241 00:24:57,080 --> 00:25:06,600 connection between a PHP server and a Postgres database. Next, we construct a SQL query, or the 242 00:25:06,600 --> 00:25:12,460 developers did, rather, to grab the user name or rather the password and the role associated 243 00:25:12,460 --> 00:25:21,420 with the provided user. And once that's run against the database of our choice, the resulting 244 00:25:21,420 --> 00:25:27,060 password is then MD5 hashed, which struck us as odd when we went to school. We didn't want to do a 245 00:25:27,060 --> 00:25:27,080 whole lot with this. So we have a couple of things to look at. We have a method called 246 00:25:27,080 --> 00:25:28,060 unhash password or unhash password. This is a cool tool we were told that you are never 247 00:25:28,060 --> 00:25:34,220 supposed to store unhashed passwords under any circumstances, but two weeks their own. And it's 248 00:25:34,220 --> 00:25:41,000 compared against the hash that's provided in the cookie. And assuming that those match, which they 249 00:25:41,000 --> 00:25:46,340 should if the attacker has set this up correctly, then the user is logged in with whatever 250 00:25:46,340 --> 00:25:52,440 privileges they gave themselves. Why not admin? So now let's pick apart the payload just a little 251 00:25:52,440 --> 00:25:57,040 bit for those interested. I have included the URL encoded version up there at the top of my web site. 252 00:25:57,040 --> 00:26:05,540 at the top and also a breakdown of all of these different keys and values that are required to do 253 00:26:05,540 --> 00:26:11,260 this properly. So the IP of the database and the credentials for that database, those are 254 00:26:11,260 --> 00:26:17,980 arbitrary. I mean they must match the attacker's setup but those can vary. And then the USR 255 00:26:17,980 --> 00:26:25,520 value has to be this hard coded user that was already included on the device and the hash just 256 00:26:25,520 --> 00:26:32,600 simply has to match the password for that user. So this was our first CVE which is 257 00:26:32,600 --> 00:26:37,940 deserialization of untrusted data leading to authentication bypass. So now we're going to 258 00:26:37,940 --> 00:26:43,920 demonstrate how we can use this to dump the entire contents of the database that exists on the 259 00:26:43,920 --> 00:26:49,700 device and including plain text passwords, emails that are used for alerts and that kind of 260 00:26:49,700 --> 00:26:55,400 thing. So normally if an administrator wanted to do this, they would go to the 261 00:26:55,520 --> 00:27:02,140 import export page on the management interface. They would select export as their action and 262 00:27:02,140 --> 00:27:10,340 then hit run. When they do this, under the hood, this export.sh script is executed which goes 263 00:27:10,340 --> 00:27:17,640 through and does a select star on all of the tables in the device's onboard database and stores 264 00:27:17,640 --> 00:27:24,140 them in CSV files with names corresponding to the table name. Once it's done this, it then 265 00:27:24,140 --> 00:27:25,500 tars them all up and gives them a name. And then it takes the name of the device and puts it in the 266 00:27:25,520 --> 00:27:32,840 file. And then it gives that tar file the file extension PDU dat un which in context we figured 267 00:27:32,840 --> 00:27:41,220 out means PDU data unencrypted. Because very shortly thereafter this secure PDU dat binary is run 268 00:27:41,220 --> 00:27:50,580 to encrypt that tar file. However, you'll notice that the unencrypted version is never deleted. 269 00:27:51,240 --> 00:27:55,500 So when the client goes to download their PDU data unencrypted file, they're not going to be able to 270 00:27:56,960 --> 00:28:02,960 put it in their database dump. So all they have to do is put un to the file name that they want and 271 00:28:03,720 --> 00:28:09,260 they're able to get the unencrypted tar file back. As a matter of fact, this mechanism could be used 272 00:28:09,260 --> 00:28:18,100 to download any file in the temp directory. That's another story. So now let's see, excuse me, 273 00:28:18,140 --> 00:28:25,480 this exploit in action. So we're executing this via the cloud interface. So we don't have to be, we don't have to be using the 274 00:28:25,480 --> 00:28:30,900 adjacent on the network at this point. Now we're going to generate that database dump and 275 00:28:30,900 --> 00:28:37,340 download it. So as you can see this is just a normal unencrypted tar file containing a bunch 276 00:28:37,340 --> 00:28:44,640 of CSV files and now we can dump them and we get plain text user names, passwords, emails, the 277 00:28:44,640 --> 00:28:50,040 whole nine yards. Including the credentials for emails that are used for automatic 278 00:28:50,040 --> 00:28:56,680 notifications and that kind of thing. So basically everything that the device has on it saved we 279 00:28:56,680 --> 00:29:01,540 now have access to. So now I'm going to turn this back over to Sam to tell us all about how we 280 00:29:01,540 --> 00:29:09,240 were able to pwn this thing. All right. Thanks, Jesse. So for one we wanted to take it a 281 00:29:09,240 --> 00:29:14,760 little bit further as we always do as hackers. So I'm going to start with a process that has 282 00:29:14,760 --> 00:29:19,880 worked for me very much in the past. So this is kind of my idea of how I 283 00:29:19,880 --> 00:29:24,560 triage a lot of these embedded systems for command injection opportunities here. The first 284 00:29:24,560 --> 00:29:28,760 thing I like to do is actually look for like custom binaries that the vendor is writing 285 00:29:28,760 --> 00:29:35,380 themselves. And for the data probe they were stored in the user bin folder. And a lot of them 286 00:29:35,380 --> 00:29:41,420 had a D at the end probably for Damon. So that is why I'm searching through the star dot D and 287 00:29:41,420 --> 00:29:47,340 then running strings on each of those files. Then I'm searching like using just grep for shell 288 00:29:47,340 --> 00:29:49,860 scripts. And so you can see there's quite a few different ways to do this. So I'm going to start 289 00:29:49,860 --> 00:29:58,440 here. And then the next step I like to do is look for potentially injectable format strings here. 290 00:29:58,580 --> 00:30:06,300 So a lot, everything in red is fully command injectable. We have to verify that later. But just 291 00:30:06,300 --> 00:30:12,460 from this initial triage all of these look really promising. The yellow is injectable as well but 292 00:30:12,460 --> 00:30:18,300 it's a numerical value which kind of goes only so far. And then there is that single green one 293 00:30:18,300 --> 00:30:25,200 there that is not susceptible to command injection. A single quotes in a shell program does 294 00:30:25,200 --> 00:30:32,380 not expand any variables or subprocesses. So this was a good sign for us. And then the next step 295 00:30:32,380 --> 00:30:37,560 that you that I like to do when I'm trying to triage these command injection opportunities is 296 00:30:38,180 --> 00:30:45,900 now open up those binaries and decompiler like IDA and look for calls to system to see how those 297 00:30:45,900 --> 00:30:48,280 format strings are being injected into the system. But then there's a little bit of a lot of 298 00:30:48,300 --> 00:30:53,400 generated and then how they are being run. Sometimes people or developers will add 299 00:30:54,540 --> 00:30:58,860 sanitization and things like that. This is where you check for that. So you can see here that 300 00:30:58,860 --> 00:31:07,220 there is none, this whole update Linux SNMP v3 user function doesn't really have much 301 00:31:07,220 --> 00:31:13,720 sanitization. And then you kind of have to imagine what values an attacker can control 302 00:31:13,720 --> 00:31:19,440 here. So if you can imagine updating your user, you can probably control the user name and 303 00:31:19,440 --> 00:31:25,700 probably the password, too. So the next step is to relate that back to, like, really validate 304 00:31:25,700 --> 00:31:31,620 that you actually do control those as malicious data. So looking at the add new user, you can see 305 00:31:31,620 --> 00:31:38,500 the user name there as well as the SNMP v3 password. The last step, if you're doing a blind 306 00:31:38,500 --> 00:31:43,700 command injection, is to always try to keep it as simple as possible. You know, if you're 307 00:31:43,720 --> 00:31:47,240 running an emulator, luckily enough, Jesse set up the emulator so I was able to run PS down there 308 00:31:47,240 --> 00:31:52,500 on the bottom. But sleep is always a really good step to actually figure out if your command 309 00:31:52,500 --> 00:31:57,740 injection is running properly. If the web page hangs for however long you told it to sleep for, 310 00:31:58,420 --> 00:32:03,100 that's probably because it's executing in the background. So this was the second CVE that we 311 00:32:03,100 --> 00:32:11,000 found on the PDU. And it also had its caveats. So the user name that we were able to inject into 312 00:32:11,000 --> 00:32:16,940 there was limited to 20 characters. And during that, you know, initial triaging stage, we 313 00:32:16,940 --> 00:32:21,540 realized that it's probably a database schema or something, because every time we'd pass in 21 or 314 00:32:21,540 --> 00:32:28,660 more characters, it would return this unknown database error. So this is where the initial 315 00:32:28,660 --> 00:32:35,820 triaging and trying to dive into all of the device's components is really useful. As we 316 00:32:35,820 --> 00:32:40,820 remembered, we saw there was a pretty interesting endpoint really on in the 317 00:32:41,000 --> 00:32:45,380 stage at this firmware upload endpoint. And the reason it stood out to us that we had to 318 00:32:45,380 --> 00:32:49,960 remember to use it potentially for this was that it was unauthenticated. So this is the entire 319 00:32:49,960 --> 00:32:57,440 PHP file here. And the thing that really caught our eye was up here on the top, it's taking post 320 00:32:57,440 --> 00:33:04,660 parameters as input and then directly writing them to this file in temp. And it will do this until 321 00:33:04,660 --> 00:33:10,560 it reaches an EOF, which is kind of a perfect script drop option with an unlimited character count, 322 00:33:10,660 --> 00:33:10,980 really. So it's a really good way to do that. And it's a really good way to do that. And it's a 323 00:33:10,980 --> 00:33:13,640 really good way to do that. And it's another great tool. So at this point, all we had to do is send 324 00:33:13,640 --> 00:33:20,060 whatever code we wanted to execute to this endpoint. And then change our user name to this kind 325 00:33:20,060 --> 00:33:25,160 of gross looking function here. But what it's really doing is just catting out everything in other 326 00:33:25,160 --> 00:33:32,660 file contents, and then running them as shell commands. So this was under 20 characters, and was 327 00:33:32,660 --> 00:33:38,740 able to run all of those commands that we wanted to pass into that file in temp. So I'll go ahead 328 00:33:38,740 --> 00:33:40,960 and show this in action. It's kind of a little bit of a sneak peak. This is one of the things there 329 00:33:40,960 --> 00:33:45,560 cool. The right side of the screen will be a Netcat listener and then the left is where we're 330 00:33:45,560 --> 00:33:50,100 going to be executing the commands from. So we'll go ahead and start off that Netcat 331 00:33:50,100 --> 00:33:55,620 listener. On the left here we actually are using that like cloud connection because it was 332 00:33:55,620 --> 00:34:00,080 actually running at Jesse's house for this. But we're using the legit credentials that we 333 00:34:00,080 --> 00:34:05,500 just showed previously that we could dump and adding that malicious user and now you can see 334 00:34:05,500 --> 00:34:10,620 our Netcat is already connected. We can run things as root and really have full access to 335 00:34:10,620 --> 00:34:22,580 the Linux operating system on that PDU. All right. So now what? Okay. We've hacked 336 00:34:22,580 --> 00:34:28,040 both of these devices. Let's zoom back out and kind of just reenvision our scenario here. So 337 00:34:28,840 --> 00:34:35,280 there are potentially two devices in the cloud now. So there's the cyber power which is our 338 00:34:35,280 --> 00:34:40,600 initial idea of using it as a pivot point. However, there is that data probe that we're 339 00:34:40,600 --> 00:34:46,020 using to try to do the cloud connection thing. But yeah, we'll kind of just ignore that for 340 00:34:46,020 --> 00:34:52,160 now. The attacker can now get access to either of those but we'll just kind of focus on the 341 00:34:52,160 --> 00:34:56,940 cyber power for here. And now can actually even get access to the operating system 342 00:34:56,940 --> 00:35:03,200 underneath that software. They can kind of hang out on that network, wait for a good time to use 343 00:35:03,200 --> 00:35:09,060 the connections set up in place to actually gain access to some of the devices in the data center 344 00:35:10,600 --> 00:35:15,600 and now of course we can use the admin panel because we actually can bypass that authentication 345 00:35:16,340 --> 00:35:22,800 of the PDU to already just turn off power, do a DDoS or whatever. But as Jesse mentioned earlier, 346 00:35:23,000 --> 00:35:28,040 this is a perfect spot to be as an attacker to pivot to other devices inside the data center. 347 00:35:28,180 --> 00:35:34,720 Now we have a practically, you know, Linux machine that we control inside of this restricted 348 00:35:34,720 --> 00:35:40,580 environment that clearly would never run antivirus or any sort of detections really. So we're going to 349 00:35:40,580 --> 00:35:47,560 try to do that. And of course after that we cause havoc. So, you know, you can switch over, you can 350 00:35:47,560 --> 00:35:53,000 turn on and off power quite rapidly. That is known to cause hardware issues, you know, so you 351 00:35:53,000 --> 00:35:57,600 really can kind of take this as far as you want. I'll pass it back on over to Jesse to do some 352 00:35:57,600 --> 00:36:10,460 final takeaways but yeah. So what are our takeaways here? What have we learned? Well, the first 353 00:36:10,580 --> 00:36:16,060 thing that stood out to us as we washed our hands of both of these products was that hard coded 354 00:36:16,060 --> 00:36:21,380 credentials are still everywhere. And this kind of makes sense from a developer's perspective. Like 355 00:36:21,380 --> 00:36:26,440 if you're working with a Postgres database, for example, which kind of require that admin 356 00:36:26,440 --> 00:36:31,640 username and password in the initial setup phase, it can be quite expeditious, particularly if 357 00:36:31,640 --> 00:36:36,760 you're under a deadline to just hard code those credentials. But even if they don't constitute 358 00:36:36,760 --> 00:36:40,500 vulnerabilities in and of themselves because you've written some 359 00:36:40,580 --> 00:36:46,720 logic around them or something like that, they can be still leveraged in addition to other 360 00:36:46,720 --> 00:36:54,320 vulnerabilities to enhance the impact of an attacker's exploit. So they're still dangerous and 361 00:36:54,320 --> 00:36:59,200 from an attacker's perspective, from the offensive point of view, it's always a good idea to 362 00:36:59,200 --> 00:37:04,940 check those database initialization scripts or to go through the binaries for interesting 363 00:37:04,940 --> 00:37:10,560 looking strings that might be some kind of special hard coded user and see if it's 364 00:37:10,560 --> 00:37:16,700 useful if you can leverage those to enhance your exploit. Our second takeaway is that much 365 00:37:16,700 --> 00:37:25,460 to our delight, we were able to find and achieve code execution through the results of our, like, 366 00:37:25,460 --> 00:37:32,140 first pass looking for low hanging fruit when we went after both of these different products. Like, 367 00:37:32,160 --> 00:37:40,360 as you can see, there was no unprecedented or particularly difficult exploitation techniques in play here. It was just command 368 00:37:40,560 --> 00:37:48,540 injections. So it's always worth it, no matter what, to go through those products and look for 369 00:37:48,540 --> 00:37:56,120 strings that might represent some kind of operating system level command, particularly if 370 00:37:56,120 --> 00:38:03,180 they have format strings, those percent S's, and to look for those process spawning function 371 00:38:03,180 --> 00:38:09,860 calls, like your systems, your execs, or execute command if you're in a Windows-y environment. 372 00:38:12,020 --> 00:38:17,320 The other thing that kind of surprised us, and it was a very pleasant surprise, all things 373 00:38:17,320 --> 00:38:23,220 considered, is that research doesn't have to be expensive. We were able to download and set up 374 00:38:23,220 --> 00:38:29,440 the power panel enterprise, our DSIM, without having to ever enter any kind of license key or 375 00:38:29,440 --> 00:38:33,160 pay for anything other than the VM in which we hosted it. It was a very, very expensive 376 00:38:33,160 --> 00:38:38,100 product. And similarly, with the PDU, we were able to conduct, you know, end-to-end 377 00:38:38,100 --> 00:38:44,160 vuln research just by downloading the publicly available firmware and then emulating it. So in 378 00:38:44,160 --> 00:38:50,260 that case, emulation turned out to really be our friend and is a nice thing to try, especially if 379 00:38:50,260 --> 00:38:56,680 you're hacking on a budget. Moreover, there's this tremendous discrepancy that we've 380 00:38:56,680 --> 00:39:03,140 observed across these products and others between the criticality of these products and the 381 00:39:03,160 --> 00:39:08,040 quality of these applications to business operations, let's say, and the quality of the 382 00:39:08,040 --> 00:39:13,680 software that backs them. So you might think that given that these are the kinds of devices that 383 00:39:13,680 --> 00:39:19,680 are going to end up in data centers and trusted with the security of our information, that they 384 00:39:19,680 --> 00:39:24,200 might be a little bit more locked down and the developers might have adhered to slightly better 385 00:39:24,200 --> 00:39:31,580 secure design principles. But we find time and time again that this is simply not the case. So I 386 00:39:31,580 --> 00:39:37,500 guess our final takeaway is something of a call to action to all of the talent here in the room, 387 00:39:37,580 --> 00:39:44,000 which is to help us keep this industry accountable. So go for it. We won't take the 388 00:39:44,000 --> 00:39:51,700 vulns from you. All right. So let's just close off by giving a huge thanks to a friend and a 389 00:39:51,700 --> 00:39:57,720 colleague who's sitting right here, Philippe Lal Horay. He was in this research with us from the 390 00:39:57,720 --> 00:40:01,560 start and made some huge contributions early on. And, in fact, he's credited us with a number of 391 00:40:01,580 --> 00:40:06,620 things. He credited with, I don't know about most, but all, probably, yeah, most. Let's go with 392 00:40:06,620 --> 00:40:13,560 most of the CVEs that we talked about in this talk. And he's just overall a great guy. So come 393 00:40:13,560 --> 00:40:19,240 find him, say hi, buy him a beer. We love you, Philippe. And we'll just finish off by also 394 00:40:19,240 --> 00:40:24,540 giving a shout out to Clarity's Team 82 who first turned us on to the iBoot PDU as a 395 00:40:24,540 --> 00:40:30,500 potentially valuable target. They wrote an interesting blog that tipped us off called Jumping Nat, 396 00:40:30,580 --> 00:40:31,560 The Shutdown. And I think it's a great blog. And I think it's a great blog. And I think it's a 397 00:40:36,320 --> 00:40:44,120 great blog. And I think it's a great blog. And you know, fried, Team 82 is an even better 398 00:40:44,120 --> 00:40:44,540 dog, right? So good job either way. It depends, doesn't it? Maybe a Dale from Los 399 00:40:44,540 --> 00:40:47,180 trouble. You'd fall in love with progressive cel dominating your 400 00:40:47,180 --> 00:40:53,980 house, and that's willing to jump in. So we'll let Saleem know later this week if we get 401 00:40:53,980 --> 00:40:55,340 an update on our plan, and If you do, I can get more updates here and always looking forward to 402 00:40:55,340 --> 00:40:59,660 having some yourself as well. So thanks so much, guys. We'll be seeing you guys next week on our 403 00:40:59,660 --> 00:41:04,460 our blog for some more information about the vulnerabilities including the two that we had to 404 00:41:04,460 --> 00:41:09,080 gloss over just due to time constraints. That's going to be dropping in the next couple of days 405 00:41:09,080 --> 00:41:15,880 if it hasn't already. And I'll just close here by saying that this research is just part of a 406 00:41:15,880 --> 00:41:22,080 smaller or rather larger effort on behalf of the vulnerable research team at Trellix to 407 00:41:22,760 --> 00:41:28,580 investigate the security of data center products of all kinds and we have a couple more 408 00:41:29,220 --> 00:41:34,360 disclosures that are still in that 90 day period that we'll be hoping to drop before the end of 409 00:41:34,360 --> 00:41:41,980 the year. So stay tuned for that. And well, comrades and friends, thank you very much for 410 00:41:41,980 --> 00:41:45,160 coming. We'll be hanging around afterward if you want to come say hi.