Thank you for our second talk of the day. This is Mauro. He's going to be talking about owner Gluster VS. Make sure you ask him about the exploit he has. Hey, how are you? Well, this is a talk it's a really beginner friendly talk it's about exploiting Gluster CVE 2018-1088 it's an authenticated access to every shared storage. This is a talk that I wrote having in mind for those who are new to both worlds, exploit writing and data duplication in fact. So the entry point for many people into the world of data duplication is Gluster and I also found that it was really easy to write an exploit for this CVE so I wanted to share it to everyone who is interested in writing Gluster. Exploits in the future. So I want to ask for your pardon in advance for my pronunciation might not be the best so if something is not understood just raise your hand and I'll try to repeat it. So, let's start. A brief introduction of who am I and what I'm doing. I'm from Argentina. I was born in the 90s. I work all my life for government and office. I own a really small company related to infosec in Argentina. And well, let's get going. For this talk I wanted to build a lab on mirror machines but I decided Docker because a recommendation from a friend. So anybody here uses Docker? Fine. For the rest who doesn't, it's really easy going. It's really easy to understand. This talk is mainly a hands-on lab. So I understand many of you won't want to connect to the Wi-Fi network. Many of you won't feel comfortable downloading an exploit for a repo. Most of you won't feel comfortable using Docker here in this environment. So it's nice if you don't want to follow it, you can download it later. I tried to follow that lab here like a live demo. So okay. A quick start on Gloster for everybody who doesn't use it. Gloster is a scalable network file system. You can use any hardware, any cheap hardware you have to run it. It's as I said before, it's a really good starting point for those interested in data application. You can duplicate almost any data. We have almost any data on any hardware, I mean. We have succeeded using it on really, really humble hardware. Raspberry Pis and the like. All laptops and so. And even we have used some USB drives to clone, and it worked like a charm. It was acquired by Red Hat in 2011, but it's also available in the free world as an open source tool. So as I was saying before. Anything. anything can run Gloucester. It's really hard to see something that doesn't work with it. Call it FreeBSD, NeatBSD, OpenBSD, whatever, even Raspbian. Anything you want can run it. In this talk, we'll set up Gloucester as a simple replication service. We won't enter into that hassle of configuring complex things. The bug itself, the vulnerability, it's really, really silly, in fact. So we will build a simple lab, nothing complex. Our minimalistic setup will have two Gloucester nodes, a volume for each node, and a single brick for each volume, and a bunch of test files. What does a node mean? Any server or computer holds one or more bricks. The bricks are the basic unit of storage in Gloucester. And a volume, it's a logical collection of those. Every file resides inside bricks. You can think of them like a sort of shared directories. I know it's not the exact definition, but it's for having a simple idea of this. Bricks compose volumes. All operations will occur at node level, and will propagate accordingly. These basically everything I say before, you have a mountain, on your operating system, a replicator of volumen, volume, sorry, on the Ark, on the bricks. A bookstore on Docker, for those who haven't used it before. Docker is the company driving the container moments. A container platform provides all the pieces enterprise operation requires, including security, governance, automation, support, atomization, and certification. This is the definition provided by Docker itself. Let's suppose we have virtual machines. You can have an app like, okay, I will separate them in a VM for the app, a VM for the database, and if you want a VM for the file systems. If you want. Containers are different. As they are oriented for microservices, they may the target is to have a minimal functional unit. When a container-based infrastructure, your app the same as before may look like this. A backend app, just you'll have your custom built in, which you can do for any service. It will libraries and your app. Nothing else. The web server, you might have a container for Apache, for NGNX, for whatever you want. And the DB container might have just a DB engine. And even it might not hold the databases itself, the data files. Here we have a comparison. As you may see, you're just using your custom things, your custom application, your custom binaries, your custom libraries on your container. Everything else that you use on LAN is shared across all the containers. Okay. Common question is what are my configuration files? We won't use them in this case, but it's a thing that always troubled me when I was learning Docker. If you follow the database, you can see that you have a lot of files. You can see that you have a lot of files. And the best practice is you will store them in an external volume. And you can even share all your config files across all your containers. So you can have a better control of your configuration files. Say, okay, this instance is configured that way. Okay. Everyone, every instance will be following that policy, if we want to call it like that. Okay. The OS, Docker uses run C. You might remember a slip container with runs in the same operating system. They have also features layered file systems. Okay. The binaries, even if you're using custom ones, the classic unique user land is shared and available along all the containers. Okay. We'll build our hands-on slab. Once again, I know you may not be comfortable doing this right now. So, okay. No problem. I'll have a live demo here. The Docker containers. You can easily install. I love doing install APT, install Docker, Git, and client on that specific version. This obviously works for JOM or DNF-based distros. So no problem. Even for FreeBSD. Okay. I have set up my repo. Get my repo. I'm going to show you how it works. So, the first thing you need to do is to run the debug and on GitHub.com. You can simply build the image. Tag it whatever you want. The tag is the name you're giving to the image itself. Debug and cluster. It should be run in a privileged environment because cluster requires to do so. You can run most of the images or Docker files around there without any privileged user. So, that's a little bit more of a demo. Okay. Let's see how it works. Let's see how it works. We have This will give us an instance ID. Then you can use it to identify that container. The magic of Docker is that you can run as many instance as you like or as you can of the same product. So, if we run this command or docker run privilege true twice, we will have two instances of the lab. If we run it three times, we have three instances and so on. This is really useful when you need to have obviously configuring something at top like a file over or like a distribution. Using the command docker ps, you can see a lab. They're both running with different IDs obviously and what they are doing. I will have, I would like to share with you the docker file so you can see how easy it is, it is to build. Sorry. This is our docker file. As you might see, this is the base. From Debian stretch slim, so we are pulling an already made image. We just run app update, app install without prompting. Gloucester F server, the vulnerable version, 3.8.8.1. We purge everything that we don't need. Docker points to microservices, so we need to have a minimal set up of every container. And these are the custom configurations. To make the Gloucester volume directory, you have it, absolute access for this test. To run Gloucester and to change the ps1, just to look like the one I showed here. Sorry. The ps1 thing is something static, just to have that way here. Okay, as you might see, we have both containers running. Uh. We can enter the containers just doing that command, docker exec ti, it's for executing on interactive way, bash. So we have the IP address of every container. How do we set up Gloucester for this? As we have two containers, we'll call them server A and server B. We can enter server A and issue the following commands. Gloucester, peer proof, server B, this is for turning the server A, A, recognize that one, check if that one is running a Gloucester instance and pair with it. Gloucester peer status, and on the other side too, Gloucester peer status. We have something like this. As you might see, proof, yeah, it's working. Status, yeah, I have a peer, this is my new peer. From the other side, we don't have to pair it again. Status, number of peers, one, and a unit, two, three, four, unit, unit ID. So, they are recognized as partners. Remember, they are vulnerable versions. They are already patched up, so don't keep these containers for anything more than testing. Okay, let's keep going. We have to create volumes for this. Gloucester volume create defconvol, replica two, transport TCP, where server A on this bound point. Remember, in the Docker file, we stated to create this bound point. It won't create it if it doesn't exist. Then, on server A, again, Gloucester volume start defconvol. So start this volume. And Gloucester volume info from the other side, just to check if it found it. You might see, these are the output from the commands. Success, start the volume, we store it. And this one, without further interaction, knows where it is located, and starts to replicate here. This lab is already set up for replicating. So, on our client, on our desktop, laptop, or whatever we are using, outside the Docker, we make our mount point, get out down POC. So you do mount GloucesterFS, where on server A, defconvol, as you might see, we skip it. Any path, just defconvol. Where, mount it here, where we just make the there. Mount, get out down POC. This will create, this will, sorry, this will mount, or recently create volume. Then, on our desktop, echo data duplication village to mount, get out down, banner dot that. This will make the replication to happen. So, we'll cut the file on both nodes, and check it has replicated, in fact. As you may see, here we create the file. Cut, work it, cut, work it. No further interaction. It's really easy for people who are newcomers to this world. I am, in fact, a newcomer to this world, so I found it really easy to get myself involved in Gloucester. Now, if everything went the right way, our lab is replicated. But, it's not vulnerable, per se, still. So, let's destroy it. This, for everybody who's not into the container moment, or, it's the logic behind Docker, or behind any microservice. You run, it fails. Okay, we respawn, and we keep running. The main point in Gloucester is to be recycled. To be constantly, re-issued, for saying it in a certain way. Okay, let's use gbaodan to own Gloucester. First, I want you to understand what the CVE is about. This is a new CVE. This is from May. I wrote this talk in June. It was patched just some day before, I think two or three days after it was issued. It was a really silly bug. gbaodan, Gloucester, and Bluestack, and Vulnerable Authentication for Data Access and Nuke, it's an exploit for Gloucester FC 1088 and 1112. Written in Ruby. Basically, this vulnerability allows any Gloucester client to connect without any authentication to a shared storage volume. In that shared storage volume, it's Gloucester-owned, resides the task scheduler. And by modifying that specific file from the scheduler, a Chrome file, I think we all know how Chrome works. Okay, it's a Chrome file. You can schedule arbitrary commands and tasks, wherever you like. This allows many actions from the privilege escalation to total data compromise or nuke. As you may see, this is using the tool dev-ccn. It tells you what vulnerable packages you have, and what are those vulnerabilities that reside in your system. As you may see, these are the only ones we have, Gloucester. Both from the client and from the server, and from the common. In order to exploit this, the shared storage feature must be enabled. It is not enabled by default now. It was in the first versions. It was vulnerable historically. So, you should explicitly run in your server, Gloucester volume set all, Gloucester enable shared storage, enable. We checked it started running, Gloucester volume get, Gloucester shared storage, Gloucester enable shared storage. And then, the snap scheduler should be enabled. It is a Python script. Snap scheduler init. As you may see, this might seem like a complex configuration, but in fact, many enterprise sites already are using this. It might seem something complex for someone like me who doesn't use Gloucester for something bigger than a simple proof of concept lab. But every environment for a media and an app uses this feature. So, success. Here we see the option enable. We start the scheduler and it says, okay. The snapshot scheduler is running. The snapshot scheduler is running. But it doesn't only cron snapshots. You can cron wherever you want. In fact, if you use any interface or even the command line, you can pass any arbitrary task. It doesn't have to be a snapshot. This feature, to this day, works like this. You can pass wherever you want. So, what happens when I share the storage volume, that is totally meant, it's intended to be shared. It's architecture of Gloucester allows all clients to mount any volume, including the shared storage volume involved in this vulnerability. If at any point the Gloucester snapshot scheduler is enabled, running that Python script you run, you will create a symlink in X cron D, obviously owned by root. So, anyone who can mount this can scale cron jobs, again, passing wherever they want. This is the red hat advisory untouched. It's like they polished it. As you may see, doing another dash L, we see that it's a symlink to bar wrong Gloucester snap cron tasks. So, as I can interact with it, I could also attack it, using only nano, B, beam, whatever you like. EE, if you come from BSD. So, by issuing a given command, your lab is now vulnerable to get out of that. Okay, we'll use the exploit. The exploit, it's in fact something really simple. I wrote, commenting it line by line, so any newcomer to the exploit writing world, I'm no expert at all, but if someone wants to start from a point, it's commented line by line, so everybody understands what every line is doing at any time. You can easily, as I said before, try to hack this using your text, your preferred text editor. But, well, here we have the exploit. It comes as a stand-alone exploit, my preferred, or as a meta-exploit module. In most cases, the stand-alone will be enough, and it takes just a few seconds to exploit this. This is the meta-exploit version. As you may see, it's further custom-disabled than the stand-alone one. In order to use Gaba on stand-alone, you can simply run hem install colorize. Colorize is a gem for having a color output. You can leave it there. You can leave it outside if you want. And just sudo gaba-undone-rb, and the server you want to exploit, in my case, this one. It won't take more than five seconds, and we'll schedule a new task, bin-able-shell. You know, it's like a shell, but evil, and it's fictional. And then we can check the contents on the tampered cron file. As you may see, it croned something to run. This output, this is a failure in the line rigging, but it's well croned. Okay, now it's time to check the docker containers, and the result should be similar to this. This will be the output. Gaba-undone. Okay, I am with super-user. Blaster mount binary located. The server replied to ICMP request. It's a simple request, nothing really forged at all. Command, blaster ports are open. We're attempting to exploit. We have exploited successfully the blaster shared storage. We mounted it here. On the client side, this is automatic, so you don't have to set up anything unless you're using the Metasploit module. Okay, now we have access. This is everything we have in the volume. You have access to the kernel. any other compromising file, important file, whatever you have, it will be displayed here and will be fetched. The cron file was altered, and we injected enable Joe, or whatever you want to run. Okay. You can load the exploit at any time, check line by line, see how it works, the Metasploit module too. It's not pushed into the Metasploit official repo. Okay. We'll take our time to explain this if anyone has any question. It's really simple, it's really easy going, so it doesn't have any complexity behind running with super user. There's a little patch we made. It's Castle, another standalone Ruby script. Why I took the time to build this? That seems really overkill. We have really, really big farms of servers running this vulnerable version on many clients. In fact, it's my first time pentesting Gluster at all. A customer told me, hey, Red Hat issued something, some advisory about Gluster. Okay. We used this with Ansible. You know Ansible? Like Chef or Puppet, but for poor mans like me. It worked. Turned out okay. Vulnerable, vulnerable option, or the Snap Chrome task is assembling, can be exploited, so we have some report to show the customer. It's also in the repo. Also, you can find out the Docker file to build the image, some of these snapshots. Okay, how do I patch this? Like most vulnerabilities out there, the vendor issued its own patch. Simple update, upgrade, whatever you like. It's available across all platforms. Remember, Gluster is available from Windows to Linux to even BSD, so everybody has its patch already running. Okay, my conclusions and questions. Gluster is not vulnerable per se. It's not something like Adobe Flash Player. In a span of five years, it had less than 10 vulnerabilities. In fact, it had six. Two, the last two, are after Red Hat bought them. They were included before being bought by Red Hat, but Red Hat found them. And simple bugs like this can bring a great chaos. So, if you now feel like forking about that, modifying it, translating it, writing something, and taking something else, be my guest. It's free to use. And it's a nice starting point for teaching someone to write an exploit step by step, without having to learn assembler C, or memory positions. Something that could be hard to newcomers and could scare them off. Okay, special thanks to the Data Those portions will do that together, custom a word, working team. Anybody has any questions? Okay, thank you.