1 00:00:00,000 --> 00:00:03,780 Thank you for our second talk of the day. This is Mauro. He's going to be talking about owner 2 00:00:03,780 --> 00:00:06,660 Gluster VS. Make sure you ask him about the exploit he has. 3 00:00:07,720 --> 00:00:12,100 Hey, how are you? Well, this is a talk 4 00:00:12,900 --> 00:00:15,840 it's a really beginner friendly talk 5 00:00:16,740 --> 00:00:19,140 it's about exploiting Gluster 6 00:00:19,140 --> 00:00:24,180 CVE 2018-1088 7 00:00:24,180 --> 00:00:27,500 it's an authenticated access to every 8 00:00:27,500 --> 00:00:31,280 shared storage. This is a talk that 9 00:00:31,280 --> 00:00:35,660 I wrote having in mind for those who are new 10 00:00:35,660 --> 00:00:38,440 to both worlds, exploit writing and 11 00:00:39,160 --> 00:00:43,400 data duplication in fact. So the entry point 12 00:00:43,400 --> 00:00:47,500 for many people into the world of data duplication 13 00:00:47,500 --> 00:00:51,340 is Gluster and I also found that it was really easy 14 00:00:51,340 --> 00:00:55,500 to write an exploit for this CVE so I wanted to share it 15 00:00:55,500 --> 00:00:57,280 to everyone who is interested in writing 16 00:00:57,280 --> 00:00:57,480 Gluster. 17 00:00:57,500 --> 00:01:01,280 Exploits in the future. So I 18 00:01:01,280 --> 00:01:04,680 want to ask for your pardon in advance for my pronunciation 19 00:01:04,680 --> 00:01:08,640 might not be the best so if something is not understood 20 00:01:08,640 --> 00:01:13,020 just raise your hand and I'll try to repeat it. 21 00:01:13,940 --> 00:01:15,280 So, let's start. 22 00:01:16,910 --> 00:01:19,760 A brief introduction of who am I and what I'm doing. 23 00:01:21,060 --> 00:01:25,500 I'm from Argentina. I was born in the 90s. I work all my life for government 24 00:01:25,500 --> 00:01:26,480 and office. 25 00:01:27,960 --> 00:01:33,620 I own a really small company related to infosec in Argentina. 26 00:01:34,380 --> 00:01:36,200 And well, let's get going. 27 00:01:38,260 --> 00:01:41,280 For this talk I wanted to build a lab on 28 00:01:41,280 --> 00:01:46,760 mirror machines but I decided Docker because a recommendation from a friend. 29 00:01:47,060 --> 00:01:49,160 So anybody here uses Docker? 30 00:01:50,680 --> 00:01:56,520 Fine. For the rest who doesn't, it's really easy going. It's really easy to understand. 31 00:01:58,140 --> 00:02:05,280 This talk is mainly a hands-on lab. So I understand many of you won't want to connect 32 00:02:05,280 --> 00:02:12,780 to the Wi-Fi network. Many of you won't feel comfortable downloading an exploit for a repo. 33 00:02:13,400 --> 00:02:20,220 Most of you won't feel comfortable using Docker here in this environment. So it's nice 34 00:02:20,220 --> 00:02:27,340 if you don't want to follow it, you can download it later. I tried to follow that lab here 35 00:02:27,340 --> 00:02:28,520 like a live demo. 36 00:02:29,060 --> 00:02:29,880 So okay. 37 00:02:31,600 --> 00:02:35,260 A quick start on Gloster for everybody who doesn't use it. 38 00:02:36,080 --> 00:02:41,500 Gloster is a scalable network file system. You can use any hardware, any cheap hardware 39 00:02:41,500 --> 00:02:42,520 you have to run it. 40 00:02:43,360 --> 00:02:48,520 It's as I said before, it's a really good starting point for those interested in data 41 00:02:48,520 --> 00:02:48,800 application. 42 00:02:49,500 --> 00:02:56,860 You can duplicate almost any data. We have almost any data on any hardware, I mean. 43 00:02:58,520 --> 00:03:07,080 We have succeeded using it on really, really humble hardware. Raspberry Pis and the like. 44 00:03:07,240 --> 00:03:13,820 All laptops and so. And even we have used some USB drives to clone, and it worked like 45 00:03:13,820 --> 00:03:14,220 a charm. 46 00:03:14,820 --> 00:03:21,920 It was acquired by Red Hat in 2011, but it's also available in the free world as an open 47 00:03:21,920 --> 00:03:22,520 source tool. 48 00:03:24,760 --> 00:03:26,240 So as I was saying before. 49 00:03:26,520 --> 00:03:27,120 Anything. 50 00:03:27,120 --> 00:03:29,440 anything can run Gloucester. 51 00:03:29,640 --> 00:03:33,420 It's really hard to see something that doesn't work with it. 52 00:03:34,000 --> 00:03:39,940 Call it FreeBSD, NeatBSD, OpenBSD, whatever, even Raspbian. 53 00:03:40,450 --> 00:03:42,600 Anything you want can run it. 54 00:03:44,680 --> 00:03:46,640 In this talk, we'll set up Gloucester 55 00:03:46,640 --> 00:03:48,240 as a simple replication service. 56 00:03:48,600 --> 00:03:51,040 We won't enter into that hassle 57 00:03:51,040 --> 00:03:53,380 of configuring complex things. 58 00:03:55,700 --> 00:03:59,020 The bug itself, the vulnerability, 59 00:03:59,440 --> 00:04:01,480 it's really, really silly, in fact. 60 00:04:02,340 --> 00:04:05,960 So we will build a simple lab, nothing complex. 61 00:04:07,260 --> 00:04:10,720 Our minimalistic setup will have two Gloucester nodes, 62 00:04:11,040 --> 00:04:15,360 a volume for each node, and a single brick for each volume, 63 00:04:15,580 --> 00:04:17,320 and a bunch of test files. 64 00:04:19,000 --> 00:04:20,800 What does a node mean? 65 00:04:21,000 --> 00:04:22,420 Any server or computer 66 00:04:23,380 --> 00:04:24,300 holds one or more bricks. 67 00:04:24,920 --> 00:04:28,920 The bricks are the basic unit of storage in Gloucester. 68 00:04:29,620 --> 00:04:32,380 And a volume, it's a logical collection of those. 69 00:04:33,100 --> 00:04:35,180 Every file resides inside bricks. 70 00:04:35,460 --> 00:04:39,100 You can think of them like a sort of shared directories. 71 00:04:39,160 --> 00:04:41,640 I know it's not the exact definition, 72 00:04:41,800 --> 00:04:44,860 but it's for having a simple idea of this. 73 00:04:45,800 --> 00:04:46,900 Bricks compose volumes. 74 00:04:47,520 --> 00:04:50,120 All operations will occur at node level, 75 00:04:50,280 --> 00:04:52,720 and will propagate accordingly. 76 00:04:55,560 --> 00:04:56,080 These 77 00:04:56,080 --> 00:04:58,480 basically everything I say before, 78 00:04:58,700 --> 00:05:01,180 you have a mountain, on your operating system, 79 00:05:01,400 --> 00:05:04,020 a replicator of volumen, volume, sorry, 80 00:05:04,700 --> 00:05:06,120 on the Ark, on the bricks. 81 00:05:08,860 --> 00:05:11,920 A bookstore on Docker, for those who haven't used it before. 82 00:05:13,660 --> 00:05:16,160 Docker is the company driving the container moments. 83 00:05:17,280 --> 00:05:18,480 A container platform 84 00:05:18,480 --> 00:05:21,860 provides all the pieces enterprise operation requires, 85 00:05:22,200 --> 00:05:23,140 including security, 86 00:05:23,380 --> 00:05:30,980 governance, automation, support, atomization, and certification. This is the definition 87 00:05:31,560 --> 00:05:37,760 provided by Docker itself. Let's suppose we have virtual machines. You can have an app 88 00:05:37,760 --> 00:05:44,860 like, okay, I will separate them in a VM for the app, a VM for the database, and if you 89 00:05:44,860 --> 00:05:55,260 want a VM for the file systems. If you want. Containers are different. As they are oriented 90 00:05:55,260 --> 00:06:05,800 for microservices, they may the target is to have a minimal functional unit. When a 91 00:06:05,800 --> 00:06:10,700 container-based infrastructure, your app the same as before may look like this. A backend 92 00:06:10,700 --> 00:06:14,840 app, just you'll have your custom built in, which you can do for any service. It will 93 00:06:14,840 --> 00:06:21,260 libraries and your app. Nothing else. The web server, you might have a container for Apache, 94 00:06:21,460 --> 00:06:30,060 for NGNX, for whatever you want. And the DB container might have just a DB engine. And even 95 00:06:30,060 --> 00:06:38,560 it might not hold the databases itself, the data files. Here we have a comparison. As you 96 00:06:38,560 --> 00:06:45,880 may see, you're just using your custom things, your custom application, your custom binaries, 97 00:06:45,880 --> 00:06:51,520 your custom libraries on your container. Everything else that you use on LAN is shared across 98 00:06:52,280 --> 00:07:01,060 all the containers. Okay. Common question is what are my configuration files? We won't use 99 00:07:01,060 --> 00:07:07,940 them in this case, but it's a thing that always troubled me when I was learning Docker. If you 100 00:07:07,940 --> 00:07:08,540 follow the database, you can see that you have a lot of files. You can see that you have a lot 101 00:07:08,540 --> 00:07:12,480 of files. And the best practice is you will store them in an external volume. And you can even 102 00:07:12,480 --> 00:07:18,540 share all your config files across all your containers. So you can have a better control of 103 00:07:18,540 --> 00:07:24,320 your configuration files. Say, okay, this instance is configured that way. Okay. Everyone, 104 00:07:24,640 --> 00:07:32,420 every instance will be following that policy, if we want to call it like that. Okay. The OS, 105 00:07:33,140 --> 00:07:38,340 Docker uses run C. You might remember a slip container with runs in the same operating system. 106 00:07:39,500 --> 00:07:46,340 They have also features layered file systems. Okay. The binaries, even if you're using custom 107 00:07:46,340 --> 00:07:56,420 ones, the classic unique user land is shared and available along all the containers. Okay. We'll 108 00:07:56,420 --> 00:08:03,980 build our hands-on slab. Once again, I know you may not be comfortable doing this right now. So, 109 00:08:04,040 --> 00:08:07,920 okay. No problem. I'll have a live demo here. 110 00:08:09,480 --> 00:08:20,180 The Docker containers. You can easily install. I love doing install APT, install Docker, Git, and 111 00:08:20,180 --> 00:08:32,780 client on that specific version. This obviously works for JOM or DNF-based distros. So no problem. 112 00:08:32,880 --> 00:08:38,320 Even for FreeBSD. Okay. I have set up my repo. Get my repo. I'm going to show you how it works. 113 00:08:38,320 --> 00:08:44,680 So, the first thing you need to do is to run the debug and on GitHub.com. You can simply build the 114 00:08:44,680 --> 00:08:50,000 image. Tag it whatever you want. The tag is the name you're giving to the image itself. 115 00:08:50,420 --> 00:08:57,120 Debug and cluster. It should be run in a privileged environment because cluster requires to do so. 116 00:08:58,540 --> 00:09:07,720 You can run most of the images or Docker files around there without any privileged user. So, 117 00:09:07,840 --> 00:09:08,300 that's a little bit more of a demo. Okay. Let's see how it works. Let's see how it works. We have 118 00:09:08,300 --> 00:09:10,880 This will give us an instance ID. 119 00:09:11,380 --> 00:09:15,000 Then you can use it to identify that container. 120 00:09:16,640 --> 00:09:19,040 The magic of Docker is that you can run 121 00:09:19,440 --> 00:09:22,620 as many instance as you like or as you can 122 00:09:23,940 --> 00:09:24,900 of the same product. 123 00:09:25,160 --> 00:09:30,200 So, if we run this command or docker run privilege true 124 00:09:31,380 --> 00:09:34,500 twice, we will have two instances of the lab. 125 00:09:35,160 --> 00:09:37,900 If we run it three times, we have three instances 126 00:09:37,900 --> 00:09:38,580 and so on. 127 00:09:39,620 --> 00:09:42,240 This is really useful when you need to have 128 00:09:43,640 --> 00:09:45,460 obviously configuring something at top 129 00:09:46,040 --> 00:09:49,380 like a file over or like a distribution. 130 00:09:52,740 --> 00:09:55,840 Using the command docker ps, you can see a lab. 131 00:09:56,340 --> 00:09:58,940 They're both running with different IDs obviously 132 00:09:58,940 --> 00:10:00,520 and what they are doing. 133 00:10:01,900 --> 00:10:05,600 I will have, I would like to share with you the docker file 134 00:10:06,540 --> 00:10:13,900 so you can see how easy it is, it is to build. 135 00:10:20,200 --> 00:10:20,760 Sorry. 136 00:10:23,700 --> 00:10:25,280 This is our docker file. 137 00:10:26,600 --> 00:10:28,200 As you might see, this is the base. 138 00:10:28,380 --> 00:10:30,760 From Debian stretch slim, so we are pulling 139 00:10:30,760 --> 00:10:32,600 an already made image. 140 00:10:32,600 --> 00:10:37,720 We just run app update, app install without prompting. 141 00:10:37,740 --> 00:10:41,920 Gloucester F server, the vulnerable version, 3.8.8.1. 142 00:10:43,010 --> 00:10:45,420 We purge everything that we don't need. 143 00:10:45,840 --> 00:10:49,520 Docker points to microservices, so we need to have 144 00:10:49,520 --> 00:10:51,440 a minimal set up of every container. 145 00:10:52,830 --> 00:10:56,380 And these are the custom configurations. 146 00:10:57,980 --> 00:11:00,920 To make the Gloucester volume directory, you have it, 147 00:11:00,920 --> 00:11:03,560 absolute access for this test. 148 00:11:03,940 --> 00:11:06,860 To run Gloucester and to change the ps1, 149 00:11:07,100 --> 00:11:09,580 just to look like the one I showed here. 150 00:11:13,040 --> 00:11:13,560 Sorry. 151 00:11:18,700 --> 00:11:20,580 The ps1 thing is something static, 152 00:11:20,760 --> 00:11:21,760 just to have that way here. 153 00:11:23,660 --> 00:11:26,400 Okay, as you might see, we have both containers running. 154 00:11:28,300 --> 00:11:28,820 Uh. 155 00:11:29,700 --> 00:11:33,640 We can enter the containers just doing that command, 156 00:11:33,800 --> 00:11:37,940 docker exec ti, it's for executing on interactive way, 157 00:11:38,640 --> 00:11:38,900 bash. 158 00:11:40,720 --> 00:11:42,920 So we have the IP address of every container. 159 00:11:45,280 --> 00:11:47,480 How do we set up Gloucester for this? 160 00:11:48,520 --> 00:11:50,840 As we have two containers, we'll call them 161 00:11:50,840 --> 00:11:52,320 server A and server B. 162 00:11:53,680 --> 00:11:56,320 We can enter server A and issue the following commands. 163 00:11:57,140 --> 00:11:58,340 Gloucester, peer proof, 164 00:11:58,820 --> 00:12:01,300 server B, this is for turning the server A, 165 00:12:01,340 --> 00:12:05,320 A, recognize that one, check if that one is running 166 00:12:05,320 --> 00:12:07,100 a Gloucester instance and pair with it. 167 00:12:08,320 --> 00:12:11,100 Gloucester peer status, and on the other side too, 168 00:12:11,260 --> 00:12:12,020 Gloucester peer status. 169 00:12:12,280 --> 00:12:13,340 We have something like this. 170 00:12:14,720 --> 00:12:18,340 As you might see, proof, yeah, it's working. 171 00:12:18,760 --> 00:12:21,600 Status, yeah, I have a peer, this is my new peer. 172 00:12:22,260 --> 00:12:24,520 From the other side, we don't have to pair it again. 173 00:12:25,760 --> 00:12:28,800 Status, number of peers, one, and a unit, two, three, four, 174 00:12:28,820 --> 00:12:29,520 unit, unit ID. 175 00:12:31,000 --> 00:12:32,980 So, they are recognized as partners. 176 00:12:33,900 --> 00:12:35,880 Remember, they are vulnerable versions. 177 00:12:36,260 --> 00:12:39,520 They are already patched up, so don't keep these containers 178 00:12:39,520 --> 00:12:42,400 for anything more than testing. 179 00:12:44,000 --> 00:12:44,840 Okay, let's keep going. 180 00:12:46,480 --> 00:12:49,100 We have to create volumes for this. 181 00:12:50,560 --> 00:12:53,480 Gloucester volume create defconvol, replica two, 182 00:12:54,360 --> 00:12:58,740 transport TCP, where server A on this bound point. 183 00:12:58,820 --> 00:13:01,640 Remember, in the Docker file, we stated to create 184 00:13:01,640 --> 00:13:02,500 this bound point. 185 00:13:02,840 --> 00:13:05,100 It won't create it if it doesn't exist. 186 00:13:06,420 --> 00:13:10,620 Then, on server A, again, Gloucester volume start defconvol. 187 00:13:10,760 --> 00:13:12,200 So start this volume. 188 00:13:13,900 --> 00:13:16,340 And Gloucester volume info from the other side, 189 00:13:16,460 --> 00:13:17,840 just to check if it found it. 190 00:13:18,940 --> 00:13:21,060 You might see, these are the output from the commands. 191 00:13:21,980 --> 00:13:24,540 Success, start the volume, we store it. 192 00:13:25,440 --> 00:13:28,340 And this one, without further interaction, 193 00:13:28,340 --> 00:13:33,080 knows where it is located, and starts to replicate here. 194 00:13:33,680 --> 00:13:36,180 This lab is already set up for replicating. 195 00:13:38,920 --> 00:13:42,020 So, on our client, on our desktop, laptop, 196 00:13:42,160 --> 00:13:44,740 or whatever we are using, outside the Docker, 197 00:13:45,900 --> 00:13:49,080 we make our mount point, get out down POC. 198 00:13:51,080 --> 00:13:55,680 So you do mount GloucesterFS, where on server A, 199 00:13:55,840 --> 00:13:58,320 defconvol, as you might see, we skip it. 200 00:13:59,480 --> 00:14:01,620 Any path, just defconvol. 201 00:14:03,000 --> 00:14:06,000 Where, mount it here, where we just make the there. 202 00:14:06,160 --> 00:14:07,400 Mount, get out down POC. 203 00:14:08,240 --> 00:14:10,260 This will create, this will, sorry, 204 00:14:10,360 --> 00:14:12,100 this will mount, or recently create volume. 205 00:14:12,820 --> 00:14:16,560 Then, on our desktop, echo data duplication village 206 00:14:17,180 --> 00:14:19,920 to mount, get out down, banner dot that. 207 00:14:21,380 --> 00:14:23,800 This will make the replication to happen. 208 00:14:25,320 --> 00:14:27,980 So, we'll cut the file on both nodes, 209 00:14:27,980 --> 00:14:30,800 and check it has replicated, in fact. 210 00:14:31,100 --> 00:14:34,280 As you may see, here we create the file. 211 00:14:35,260 --> 00:14:38,500 Cut, work it, cut, work it. 212 00:14:38,580 --> 00:14:39,440 No further interaction. 213 00:14:39,820 --> 00:14:43,960 It's really easy for people who are newcomers to this world. 214 00:14:44,420 --> 00:14:46,640 I am, in fact, a newcomer to this world, 215 00:14:46,700 --> 00:14:52,280 so I found it really easy to get myself involved in Gloucester. 216 00:14:54,140 --> 00:14:55,960 Now, if everything went the right way, 217 00:14:56,100 --> 00:14:56,940 our lab is replicated. 218 00:14:58,580 --> 00:15:01,000 But, it's not vulnerable, per se, still. 219 00:15:01,240 --> 00:15:02,280 So, let's destroy it. 220 00:15:03,240 --> 00:15:08,400 This, for everybody who's not into the container moment, 221 00:15:08,660 --> 00:15:13,860 or, it's the logic behind Docker, 222 00:15:14,060 --> 00:15:15,880 or behind any microservice. 223 00:15:16,660 --> 00:15:18,000 You run, it fails. 224 00:15:18,280 --> 00:15:21,140 Okay, we respawn, and we keep running. 225 00:15:22,420 --> 00:15:25,140 The main point in Gloucester is to be recycled. 226 00:15:25,500 --> 00:15:26,560 To be constantly, 227 00:15:28,960 --> 00:15:31,960 re-issued, for saying it in a certain way. 228 00:15:34,660 --> 00:15:37,020 Okay, let's use gbaodan to own Gloucester. 229 00:15:38,180 --> 00:15:41,560 First, I want you to understand what the CVE is about. 230 00:15:41,880 --> 00:15:42,720 This is a new CVE. 231 00:15:42,840 --> 00:15:43,800 This is from May. 232 00:15:44,360 --> 00:15:45,740 I wrote this talk in June. 233 00:15:46,760 --> 00:15:48,880 It was patched just some day before, 234 00:15:50,220 --> 00:15:54,200 I think two or three days after it was issued. 235 00:15:54,360 --> 00:15:55,580 It was a really silly bug. 236 00:15:56,820 --> 00:15:57,960 gbaodan, Gloucester, and Bluestack, 237 00:15:57,960 --> 00:16:01,080 and Vulnerable Authentication for Data Access and Nuke, 238 00:16:01,160 --> 00:16:08,480 it's an exploit for Gloucester FC 1088 and 1112. 239 00:16:08,700 --> 00:16:09,640 Written in Ruby. 240 00:16:10,500 --> 00:16:13,520 Basically, this vulnerability allows any Gloucester client 241 00:16:14,150 --> 00:16:16,140 to connect without any authentication 242 00:16:16,140 --> 00:16:17,720 to a shared storage volume. 243 00:16:19,050 --> 00:16:22,760 In that shared storage volume, it's Gloucester-owned, 244 00:16:23,860 --> 00:16:26,300 resides the task scheduler. 245 00:16:26,940 --> 00:16:30,880 And by modifying that specific file from the scheduler, 246 00:16:30,940 --> 00:16:34,100 a Chrome file, I think we all know how Chrome works. 247 00:16:34,740 --> 00:16:36,040 Okay, it's a Chrome file. 248 00:16:36,800 --> 00:16:40,040 You can schedule arbitrary commands and tasks, 249 00:16:40,660 --> 00:16:41,420 wherever you like. 250 00:16:42,320 --> 00:16:45,500 This allows many actions from the privilege escalation 251 00:16:45,500 --> 00:16:47,580 to total data compromise or nuke. 252 00:16:48,960 --> 00:16:52,920 As you may see, this is using the tool dev-ccn. 253 00:16:53,200 --> 00:16:54,300 It tells you 254 00:16:56,440 --> 00:16:58,620 what vulnerable packages you have, 255 00:16:59,160 --> 00:17:01,360 and what are those vulnerabilities 256 00:17:01,360 --> 00:17:02,860 that reside in your system. 257 00:17:03,060 --> 00:17:05,380 As you may see, these are the only ones we have, Gloucester. 258 00:17:06,020 --> 00:17:08,580 Both from the client and from the server, 259 00:17:08,700 --> 00:17:09,240 and from the common. 260 00:17:11,540 --> 00:17:12,860 In order to exploit this, 261 00:17:13,000 --> 00:17:15,180 the shared storage feature must be enabled. 262 00:17:15,440 --> 00:17:17,260 It is not enabled by default now. 263 00:17:17,440 --> 00:17:18,660 It was in the first versions. 264 00:17:19,880 --> 00:17:21,620 It was vulnerable historically. 265 00:17:23,120 --> 00:17:26,020 So, you should explicitly run in your server, 266 00:17:26,020 --> 00:17:27,480 Gloucester volume set all, 267 00:17:27,660 --> 00:17:30,700 Gloucester enable shared storage, enable. 268 00:17:31,960 --> 00:17:33,360 We checked it started running, 269 00:17:33,660 --> 00:17:35,780 Gloucester volume get, Gloucester shared storage, 270 00:17:36,180 --> 00:17:37,520 Gloucester enable shared storage. 271 00:17:38,820 --> 00:17:41,420 And then, the snap scheduler should be enabled. 272 00:17:41,600 --> 00:17:42,700 It is a Python script. 273 00:17:43,020 --> 00:17:44,320 Snap scheduler init. 274 00:17:45,480 --> 00:17:49,880 As you may see, this might seem like a complex configuration, 275 00:17:50,280 --> 00:17:53,880 but in fact, many enterprise sites already are using this. 276 00:17:53,880 --> 00:17:58,340 It might seem something complex for someone like me 277 00:17:58,340 --> 00:18:01,240 who doesn't use Gloucester for something bigger 278 00:18:01,240 --> 00:18:03,460 than a simple proof of concept lab. 279 00:18:04,140 --> 00:18:08,140 But every environment for a media and an app 280 00:18:08,620 --> 00:18:09,520 uses this feature. 281 00:18:10,860 --> 00:18:11,960 So, success. 282 00:18:13,480 --> 00:18:15,740 Here we see the option enable. 283 00:18:17,540 --> 00:18:19,940 We start the scheduler and it says, okay. 284 00:18:20,440 --> 00:18:23,280 The snapshot scheduler is running. 285 00:18:23,400 --> 00:18:23,860 The snapshot scheduler is running. 286 00:18:23,860 --> 00:18:28,020 But it doesn't only cron snapshots. 287 00:18:28,120 --> 00:18:30,080 You can cron wherever you want. 288 00:18:30,700 --> 00:18:35,320 In fact, if you use any interface or even the command line, 289 00:18:36,260 --> 00:18:39,580 you can pass any arbitrary task. 290 00:18:40,180 --> 00:18:42,000 It doesn't have to be a snapshot. 291 00:18:44,100 --> 00:18:48,260 This feature, to this day, works like this. 292 00:18:48,360 --> 00:18:50,040 You can pass wherever you want. 293 00:18:51,580 --> 00:18:53,720 So, what happens when I share the storage volume, 294 00:18:53,860 --> 00:18:57,200 that is totally meant, it's intended to be shared. 295 00:18:58,140 --> 00:19:01,220 It's architecture of Gloucester allows all clients 296 00:19:01,220 --> 00:19:04,260 to mount any volume, including the shared storage volume 297 00:19:04,260 --> 00:19:05,660 involved in this vulnerability. 298 00:19:06,700 --> 00:19:09,080 If at any point the Gloucester snapshot scheduler 299 00:19:09,080 --> 00:19:12,300 is enabled, running that Python script you run, 300 00:19:12,880 --> 00:19:15,420 you will create a symlink in X cron D, 301 00:19:15,560 --> 00:19:17,480 obviously owned by root. 302 00:19:18,340 --> 00:19:22,880 So, anyone who can mount this can scale cron jobs, again, 303 00:19:22,880 --> 00:19:24,820 passing wherever they want. 304 00:19:25,470 --> 00:19:28,480 This is the red hat advisory untouched. 305 00:19:28,640 --> 00:19:29,720 It's like they polished it. 306 00:19:31,380 --> 00:19:34,220 As you may see, doing another dash L, 307 00:19:34,860 --> 00:19:38,020 we see that it's a symlink to bar 308 00:19:38,020 --> 00:19:41,080 wrong Gloucester snap cron tasks. 309 00:19:42,980 --> 00:19:46,720 So, as I can interact with it, 310 00:19:47,000 --> 00:19:51,280 I could also attack it, 311 00:19:51,880 --> 00:19:55,840 using only nano, B, beam, whatever you like. 312 00:19:56,000 --> 00:19:57,920 EE, if you come from BSD. 313 00:20:01,140 --> 00:20:03,140 So, by issuing a given command, 314 00:20:03,300 --> 00:20:05,340 your lab is now vulnerable to get out of that. 315 00:20:08,500 --> 00:20:10,280 Okay, we'll use the exploit. 316 00:20:10,500 --> 00:20:14,620 The exploit, it's in fact something really simple. 317 00:20:14,840 --> 00:20:17,680 I wrote, commenting it line by line, 318 00:20:17,800 --> 00:20:20,260 so any newcomer to the exploit writing world, 319 00:20:20,260 --> 00:20:21,980 I'm no expert at all, 320 00:20:22,140 --> 00:20:26,100 but if someone wants to start from a point, 321 00:20:27,840 --> 00:20:29,260 it's commented line by line, 322 00:20:29,360 --> 00:20:32,780 so everybody understands what every line is doing 323 00:20:33,250 --> 00:20:34,120 at any time. 324 00:20:35,260 --> 00:20:37,660 You can easily, as I said before, 325 00:20:38,330 --> 00:20:41,360 try to hack this using your text, 326 00:20:41,420 --> 00:20:42,760 your preferred text editor. 327 00:20:43,960 --> 00:20:46,640 But, well, here we have the exploit. 328 00:20:47,310 --> 00:20:50,080 It comes as a stand-alone exploit, my preferred, 329 00:20:50,080 --> 00:20:52,380 or as a meta-exploit module. 330 00:20:52,900 --> 00:20:55,140 In most cases, the stand-alone will be enough, 331 00:20:55,360 --> 00:20:57,920 and it takes just a few seconds to exploit this. 332 00:21:00,160 --> 00:21:02,260 This is the meta-exploit version. 333 00:21:02,980 --> 00:21:06,600 As you may see, it's further custom-disabled 334 00:21:06,600 --> 00:21:08,520 than the stand-alone one. 335 00:21:10,420 --> 00:21:12,480 In order to use Gaba on stand-alone, 336 00:21:12,640 --> 00:21:15,980 you can simply run hem install colorize. 337 00:21:16,040 --> 00:21:18,400 Colorize is a gem for having a color output. 338 00:21:19,000 --> 00:21:20,040 You can leave it there. 339 00:21:20,040 --> 00:21:21,780 You can leave it outside if you want. 340 00:21:22,440 --> 00:21:24,980 And just sudo gaba-undone-rb, 341 00:21:25,620 --> 00:21:27,240 and the server you want to exploit, 342 00:21:27,360 --> 00:21:28,580 in my case, this one. 343 00:21:29,100 --> 00:21:31,380 It won't take more than five seconds, 344 00:21:31,400 --> 00:21:32,760 and we'll schedule a new task, 345 00:21:32,900 --> 00:21:33,840 bin-able-shell. 346 00:21:34,140 --> 00:21:36,380 You know, it's like a shell, but evil, 347 00:21:36,940 --> 00:21:38,240 and it's fictional. 348 00:21:39,280 --> 00:21:40,960 And then we can check the contents 349 00:21:40,960 --> 00:21:42,420 on the tampered cron file. 350 00:21:43,960 --> 00:21:48,460 As you may see, it croned something to run. 351 00:21:50,040 --> 00:21:55,340 This output, this is a failure in the line rigging, 352 00:21:56,340 --> 00:21:57,760 but it's well croned. 353 00:21:58,280 --> 00:22:01,700 Okay, now it's time to check the docker containers, 354 00:22:02,120 --> 00:22:04,360 and the result should be similar to this. 355 00:22:04,560 --> 00:22:05,620 This will be the output. 356 00:22:05,860 --> 00:22:06,500 Gaba-undone. 357 00:22:07,120 --> 00:22:08,900 Okay, I am with super-user. 358 00:22:09,440 --> 00:22:11,040 Blaster mount binary located. 359 00:22:12,680 --> 00:22:15,820 The server replied to ICMP request. 360 00:22:16,060 --> 00:22:18,980 It's a simple request, nothing really forged at all. 361 00:22:20,740 --> 00:22:23,080 Command, blaster ports are open. 362 00:22:23,940 --> 00:22:25,020 We're attempting to exploit. 363 00:22:27,080 --> 00:22:31,140 We have exploited successfully the blaster shared storage. 364 00:22:31,920 --> 00:22:33,160 We mounted it here. 365 00:22:35,040 --> 00:22:37,200 On the client side, this is automatic, 366 00:22:37,560 --> 00:22:39,240 so you don't have to set up anything 367 00:22:39,240 --> 00:22:40,880 unless you're using the Metasploit module. 368 00:22:41,700 --> 00:22:43,680 Okay, now we have access. 369 00:22:44,820 --> 00:22:48,820 This is everything we have in the volume. 370 00:22:49,060 --> 00:22:50,020 You have access to the kernel. 371 00:22:50,040 --> 00:22:53,560 any other compromising file, important file, 372 00:22:53,800 --> 00:22:55,580 whatever you have, it will be displayed here 373 00:22:55,580 --> 00:22:57,080 and will be fetched. 374 00:22:57,880 --> 00:23:00,000 The cron file was altered, 375 00:23:00,840 --> 00:23:02,600 and we injected enable Joe, 376 00:23:03,760 --> 00:23:05,200 or whatever you want to run. 377 00:23:06,800 --> 00:23:07,360 Okay. 378 00:23:09,660 --> 00:23:11,960 You can load the exploit at any time, 379 00:23:13,100 --> 00:23:16,300 check line by line, see how it works, 380 00:23:16,420 --> 00:23:17,540 the Metasploit module too. 381 00:23:17,540 --> 00:23:22,680 It's not pushed into the Metasploit official repo. 382 00:23:24,000 --> 00:23:24,620 Okay. 383 00:23:26,980 --> 00:23:29,400 We'll take our time to explain this 384 00:23:29,400 --> 00:23:30,620 if anyone has any question. 385 00:23:32,160 --> 00:23:34,920 It's really simple, it's really easy going, 386 00:23:35,040 --> 00:23:37,100 so it doesn't have any complexity behind 387 00:23:37,970 --> 00:23:39,600 running with super user. 388 00:23:40,720 --> 00:23:43,000 There's a little patch we made. 389 00:23:43,670 --> 00:23:46,540 It's Castle, another standalone Ruby script. 390 00:23:47,740 --> 00:23:49,780 Why I took the time to build this? 391 00:23:50,000 --> 00:23:51,840 That seems really overkill. 392 00:23:53,380 --> 00:23:58,300 We have really, really big farms of servers 393 00:23:58,300 --> 00:24:01,160 running this vulnerable version on many clients. 394 00:24:01,600 --> 00:24:05,000 In fact, it's my first time pentesting Gluster at all. 395 00:24:05,640 --> 00:24:09,960 A customer told me, hey, Red Hat issued something, 396 00:24:10,080 --> 00:24:11,820 some advisory about Gluster. 397 00:24:12,600 --> 00:24:13,240 Okay. 398 00:24:14,900 --> 00:24:16,740 We used this with Ansible. 399 00:24:17,540 --> 00:24:18,340 You know Ansible? 400 00:24:18,840 --> 00:24:21,840 Like Chef or Puppet, but for poor mans like me. 401 00:24:23,020 --> 00:24:23,580 It worked. 402 00:24:24,120 --> 00:24:25,020 Turned out okay. 403 00:24:25,460 --> 00:24:27,260 Vulnerable, vulnerable option, 404 00:24:28,320 --> 00:24:31,300 or the Snap Chrome task is assembling, can be exploited, 405 00:24:31,560 --> 00:24:34,040 so we have some report to show the customer. 406 00:24:34,600 --> 00:24:36,680 It's also in the repo. 407 00:24:37,520 --> 00:24:40,440 Also, you can find out the Docker file to build the image, 408 00:24:41,580 --> 00:24:42,900 some of these snapshots. 409 00:24:44,400 --> 00:24:45,840 Okay, how do I patch this? 410 00:24:45,840 --> 00:24:48,200 Like most vulnerabilities out there, 411 00:24:48,340 --> 00:24:50,060 the vendor issued its own patch. 412 00:24:50,540 --> 00:24:54,000 Simple update, upgrade, whatever you like. 413 00:24:54,420 --> 00:24:56,440 It's available across all platforms. 414 00:24:57,720 --> 00:25:00,880 Remember, Gluster is available from Windows to Linux 415 00:25:01,440 --> 00:25:05,760 to even BSD, so everybody has its patch already running. 416 00:25:07,540 --> 00:25:09,220 Okay, my conclusions and questions. 417 00:25:09,620 --> 00:25:11,740 Gluster is not vulnerable per se. 418 00:25:11,820 --> 00:25:13,800 It's not something like Adobe Flash Player. 419 00:25:16,060 --> 00:25:18,080 In a span of five years, 420 00:25:18,180 --> 00:25:20,480 it had less than 10 vulnerabilities. 421 00:25:21,020 --> 00:25:22,300 In fact, it had six. 422 00:25:23,680 --> 00:25:28,900 Two, the last two, are after Red Hat bought them. 423 00:25:29,040 --> 00:25:33,100 They were included before being bought by Red Hat, 424 00:25:33,160 --> 00:25:34,120 but Red Hat found them. 425 00:25:34,740 --> 00:25:37,840 And simple bugs like this can bring a great chaos. 426 00:25:38,860 --> 00:25:42,840 So, if you now feel like forking about that, 427 00:25:42,900 --> 00:25:45,620 modifying it, translating it, writing something, 428 00:25:45,840 --> 00:25:46,800 and taking something else, be my guest. 429 00:25:47,760 --> 00:25:48,900 It's free to use. 430 00:25:50,240 --> 00:25:52,340 And it's a nice starting point 431 00:25:52,820 --> 00:25:57,240 for teaching someone to write an exploit 432 00:25:57,240 --> 00:25:58,560 step by step, 433 00:25:59,560 --> 00:26:02,520 without having to learn assembler C, 434 00:26:02,920 --> 00:26:04,660 or memory positions. 435 00:26:04,860 --> 00:26:07,280 Something that could be hard to newcomers 436 00:26:07,280 --> 00:26:08,320 and could scare them off. 437 00:26:10,280 --> 00:26:13,180 Okay, special thanks to the Data Those portions 438 00:26:13,180 --> 00:26:13,960 will do that together, 439 00:26:13,960 --> 00:26:15,340 custom a word, 440 00:26:15,820 --> 00:26:24,260 working team. Anybody has any questions? Okay, thank you.