Hi, everybody. My name is Isaac Levy. Everybody calls me Ike. This lecture is on the topic of FreeBSD Jail, which last year got some interest here at DEF CON because it was used for Capture the Flag, part of why I'm here today. Quick Ike context so you guys know who I am. I've used jails extensively for a long time. I am not a jail author, no commit bit, none of that fun. And, you know, throughout the lecture, I'm going to say a lot of stuff. I'm not religious with operating systems and other, you know, bashing other ways of doing things. Every tool's got a purpose. But some of my arguments are based on specific threat models. If they're not real clear, if you feel like I'm being a jerk about something, talk to me about it afterwards. It's always interesting to argue in a constructive manner. Warranty. It's a lot of information. I'm going to be moving really fast through a lot of material. I will be around if anyone has questions. And I will be trying to stick to really classic stock Unix processes and ideals, stuff that is 30 years and older. So there's no real, what do I got to do? Oh, hold it up here? Okay. So I'm not going to present any, like, Ike-specific magic. Oh, my God. Thank you. This is what the BSD user group, really. Thank you, guys. So I'm not, and I'm assuming you know your way around Unix, so I'm not going to spend a lot of time on simple things. Starting with a quick exercise. Scale, patterns, and complexity. Has anybody in the room seen the Eames film, Powers of Ten, 1977? Really great, great piece. It's up on YouTube. URLs in here, URLs in the notes. It's just great. It's a great film where they zoom through the galaxy, and they start with this guy sleeping, which you can kind of see over here. The whole film is just about a guy sleeping. And they zoom way out of the galaxy at these distance intervals of Powers of Ten, and then they zoom back in, into the guy's hand, and into, you know, down to quarks, get really teeny. Do you need some? Okay. And throughout it, there's this really cool situation where you have all these patterns that keep re-emerging, visually, and I find them really interesting, these patterns, patterns. Okay, you get the idea. Well, this is the little Ike universe for the day, the Ike's internet universe. And, you know, we start at the outside, and we've got, like, you know, satellites, and all kinds of telecommunications equipment and gear. We zoom in. There's a map from the Opti project. Thanks, Dan Kaminski, who just spoke. And, you know, we zoom into the east coast, and zoom into my home. In New York City, and you slide past a nice bug meeting, and into a building, and we're in the bowels of a data center. And in the basement, you'll find the last bug meeting, and we all know what data centers look like in the room, right? You get down to the cables, and the network infrastructure, and at that scale, you find another guy sleeping, conferences, the, we all know what's inside a server. We all know what's inside a computer. And then we get down to the ethernet port, and we'll jump over into, you know, what's listening on those ports. In this case, we have Apache and SSH listening. And here's what we're here to talk about is the UNIX system, and they're the gateway into the UNIX system over the network. And then we've got our daemons, our processes running, and applications behind that. And down at the bottom, we found these little things, really small scale, climbing around the data center, and we think the NSA made them. And then we get down to the ethernet port, and we'll jump over into, you know, what's listening on those ports. And all of that complexity, all of that mind-boggling stuff, just to pull up a web page, right? Pretty wild. You know, this stuff can be more formally referenced in other ways, like OSI model, but I like my little idea of this. Yeah, and we all know about hardware, not worth talking about. Hardware is getting smaller, faster, cheaper, like those little things next to the match head are embedded web servers. Stuff gets small and cheap. So, in all of this, let's focus in on the UNIX. This is my diagram of UNIX for the day. And it looks wild and complicated when you first stare at it, but then after a second, it looks kind of familiar. See a bunch of familiar UNIX stuff. And it can be broken down into something even simpler. You know, your system ends up being your user land kernel devices, at least in the way I'm talking about it today. And those things, though, break down into... Stuff that we're familiar with. User bin, user local, you know, home directories, that kind of stuff. Devices, nodes. So, you know, our world is complex. And you can do a lot with it. System administrators tend to think of stuff at scale where a given system is just one unit. So let's think of it as a simple thing. You know, when we look at all this... There's some fun stuff, too. There's some fun stuff. This is one other little part of this exercise. Trip out for a second for the math heads in the room. Mandelbrot fractal, Julia set. And as we scale through stuff, again, we're noticing all these patterns. It's the whole deal, right? And this gets really trippy. Just kick back and enjoy it. You know, so look at this stuff. Start looking at our natural world and the world that we create, our world. And... If you start applying similar principles, hey, man, get into virtual Unixes, too. Why can't we, I don't know, do fun stuff at different... You get the idea. I'm going to go faster through all this stuff so we can get to the meat. Okay. Now, look. These ideas, like virtualizing stuff, virtualizing your operating system, this stuff's not old at all. Okay? Unix in the first place was designed to be a time-sharing system. All right? Okay. And this little snippet from a video. It was used by just one person running one program. To overcome this inefficiency, so many people could use the machine, time-sharing was developed. The obvious next step was to allow each person to run several programs. Unix is one of the multi-programming operating systems that now lets each person execute several programs simultaneously. But the usefulness of multi-programming was restricted by the existing terminals. Then the first multi-programming terminal was built. Okay. So then we get Rob Pike talking about the Blit. And I've got this whole movie if anybody wants to watch it sometime. You get the idea. So what kind of real-world context warrant virtualizing the entire operating system? We already run, you know, we have multiple processes, we're threading. That's all pretty advanced, cool stuff that's mature. But what about the whole OS? Why do we need to do that? Okay. External security threats. Why we're all here. Making development messes. But the real, real focus of why JAIL was created in the first place is to deal with the problem of mutually untrusted users. These are a bunch of capture the flag participants from DEF CON 11. Right? And that's what you usually think of with mutually untrusted users is, you know, us. But, you know, really it was designed for these mutually untrusted users. A bunch of people using computers for various purposes. You know, why are these people, they're all sitting waiting for a subway train. Why are they mutually untrusted users? Well, the guy on the far left, he is not to be trusted in that woman in the pink jacket's kitchen. All right? He doesn't get to touch stuff in there. And she's not to be trusted with his motorcycle, conversely. You know, so you get down to situations where, like, users are going to step on each other. But this is why we're here. We're here to talk about hackers. There's a bunch of them at ShmooCon. You know, like, users do all kinds of crazy shit. I hosted these people's webs. This fine lady's website. And they were a real pain in the ass. They wouldn't stop using Telnet. And like, users do dumb stuff. We all know this. You know, like, this guy is barefoot on a ladder in a pool with an electric drill. Right? And users have funny user interface requirements at moments and funny habits. And sometimes users are just outright abusive with the machine. Right? Yeah. Users get abusive. And some users just, that's how they do it. Then you get into cultural clashes. Right? People have different ideas about how, what's cool and what's not. Like in India, they love rats. In New York City, we do not. Okay? And, you know, you have mutually, programs are mutually entrusted users, too. Bugs. Things blow up. And some of the worst mutually entrusted users are professional sysadmins. Yeah. I'm gonna have to do that in the next last year or two. Because I'm gonna have to do it, too, next year. I don't know. I'm running out of ideas. Or one day. I'm gonna write a letter. Or I'm gonna do it in a couple weeks. I feel like all of the other countries out there, you know, some of the other countries that I've been talking about. Well, we lock down machines, right? It's not fun to work on machines that are so heavily locked down. It can be really cumbersome to do simple tasks. You can't run all the software you want. This isn't a way to manage everybody to keep them at the point of a gun, right? I mean, Unix used to be fun. I still think it is fun. All right, one more last little thing is if you're maintaining a lot of old junk, GLs are great. So this rack with all those one-gigabyte SCSI hard drives, this has got three web servers, a local use DNS cache, file server for two people, and two dev servers. It's a lot of juice. All of that stuff could be shoved into a nice brand-new high-density 1U box, and you run a bunch of jails. We've got all of our isolated systems. And, hey, get another one, and it's redundant. All right, so let's get into the nitty-gritty. What is a jail? Jail is a part of FreeBSD. How many people in here use FreeBSD? Yeah, all right. How many people use OpenBSD? Yeah, cool. NetBSD, a lot of BSD people around here, right? Great. What is jail? It's a user space utility like ifconfig. All right, real simple. It produces a virtual system image, and this is process tree-based. Okay? What is a jail system call? Well, it's a system call that jail uses, and it calls chroot and attaches it to an IP. Pretty simple. And it's very few lines of source code. What jail is not? It's not a classical machine emulator. Like, if we have time, I'll get into more of them at the end. It's not chroot. Okay, this is commonly misused vocabulary in other Unix cultures. OpenBSD, people. Stop calling chroot jail. It's really annoying. It's not chroot, though. It's something completely different. Great users for jail, hardware resource sharing. You can securely separate untrusted users' processes. They're great for learning, development, testing, hacking. You want to test your new root kits on some safe environments? Make a bunch of jails. Insane high availability possibilities. Moving jails around from machine to machine. Cool for honeypots, because you've got a god view of a system. And they're really cool for highly vulnerable network services. Stuff that you have to run that sucks. Poor users for jail. You don't get a kernel in a jail. So, if you've got to do anything that requires dealing with a kernel, you don't got it. You have limited network and device interface access. Okay? And, you know, poor users for jail is like when chroot will simply do the job. Like bind on FreeBSD. You have some simple flags in RC startup and, you know, just start bind in a chroot environment. It's not really worth building a full jail for that, because you've got to build a whole OS. And noteworthy, Postgres does not run securely in jails, because Postgres uses, and this one's a real annoyance, it uses System 5 IPC calls, shared memory, which totally borks the whole idea of, you know, keeping jails separate from each other. That's a Postgres thing. I want to talk about it with me later. I'd love to. It's been a real pain in my ass for years and other people's. How to jail. Okay. Look, the definitive instructions are in the man pages. GoBSD for keeping man pages. But it's real simple. Three steps. You compile your FreeBSD user land from the source code somewhere on the host machine with some minor tweaks. You create an IP alias on a network interface and you run the jail call with the IP user land and you boot the jail. Just like throwing flags at ifconfig or something else. Practical comparison between a jailed system and a regular computer. Pretty much the same thing. Over here we got, you know, a device node that's been hidden from the jail. We have no kernel. And other than that, everything's there. So let's make a jail. This is the best way to talk about how to really secure and break jails. Our host machine is a FreeBSD 6.1 machine. Preflight, we are going to get our source to build with. CVS up is a great mechanism. If you're not familiar with it, it's in the FreeBSD handbook. You can just get the source via FTP or whatever, on disk, on CD. You make somewhere for the jails to live. So you have to think about where you're going to put them on disk. Putting them on a, you know, partition that takes most of your system and is just there for jails is a great idea. Because then, you know, you don't waste all this space with a whole lot of, excuse me, then you lock down the amount of space your jails take up and separate that from the host system. You want to make somewhere for jail-related start and management scripts to live. Comment on starting jail from RC. There's stuff in the system to start jails from RC. This is bad in most jailing contexts. All right. This can thrash painfully. If if you have, say, 50 jails on a box, 100 jails running on a single piece of hardware and a couple of them are having some kind of problem, you have to power cycle the machine. If you're having problems with those jails when they're all starting up, they're going to bite you. And it's really painful to untangle how and why they're biting you, especially when they're bogging down your whole boot process in your system. Later the let me see. So preflight, here's the man page from the jail. Here's first important lines. We're going to keep those in the corner as we do this. So we're going to sue the route. We are going to this, you know, figured out where we're going to put our jails. OK, user local jails gravy. We're going to make a directory for our first jail to live in. We're going to call it a chick on our host chicken. So, you know, we just found user local jails and we're going to put this directory in there for chick. Now we're going to change to user source. Here's how you get your source CVS up or FTP or whatever. We've got our source and we're going to run make world with the destination directory being the directory we just created where our jail is going to live in the host user land. All right. So you run make world. And you cook and cook and let it go. And you cook and you run make you make your distribution and you let it go. And so what do we just do? We made our directory and we just populate it with the base user land utilities in our operating system. Now we're going to mount dev remount our devices and real quick. There's an old little old trick when we mount dev to it's an old school thing. From previous D4 where you'd soft link a kernel. It's not on the man page as a requisite, but nobody was sure what you would do. Like we don't have something called kernel in the root directory of the server. What could that what kind of problems could that cause? Well, none at the end of the day. So you don't have to even put something in there that looks like a kernel, but not a tradition. Why not? You could actually compile and put your whole kernel there. But in the case for making honey pots, for example, where you'd want something to look like it's for real, but you don't need to. Let me see. So, yeah, what do we do? So we mounted our device tree. One other comment. You can hide a number of devices from your jailed system so that it can't see, for example, all the disks you have in your system or all the network interfaces or all of whatever on your system by throwing flags at the mount commands for mounting dev FS. So pre-flight common question. Why isn't this a part all automated? Why can't you just push the button, go make it? Well, because God knows how your system set up, how much disk space you have, where you're going to be putting these things. And then in just a second, we'll see that, you know, you've got to add users to your system before you can do anything with it. This is you're working with a headless virtual machine. You need to do some configuration that's specific to you. So this is all stuff you just got to do and stuff that you can script out for yourself. Very easily to automate. So we're going to configure the host. If config, we're going to add some things to excuse me, RC.conf and our host so that basically what you want to do on your host is lock down anything that would listen to that would bind to all IP addresses on the machine. You want to bind everything just to the host machine's IP address. So common sense here. You just you don't want something listening on on IPs that could be listening from jails. Let me see. Also, some little tricks send mail. Submit is a real handy little new feature and RPC bind enable and get rid of it. And ID flag, blah, blah, blah. That's all on the man page. Then you want to configure your host's SSH daemon to only bind to the host IP address as well, because then you get into this condition where if SSH dies and you jail, the host could be answering on that IP address and it gets real confusing. So you want to just be real, real careful on the host machine when you're configuring it real minimal. And then we're going to configure the jail. So we're going to call make the jail call. This is the man page again. And we're going to do a bunch of stuff in it. We're going to follow this list of simple things that are the same things you do when you install and create a new operating system. So we make the jail call and suddenly it's kind of like it's kind of like a single user boot on a machine. You just got a root shell in this jail and nothing's running except your process, except the shell process. So check the host name. We just gave it, you know, chick.diverseform.net. If you check who we are, we're root and we're in the root directory. We're going to run sysinstall and be lazy with this, but also to see that, hey, the program just runs just like a standard FreeBSD install. And go through setting your root password, adding users to the system. And setting your time zone. And network services. We want SSH to be running. We've got to figure out a way to get into the jail, right? It's got no head. It's got no. Anything. We need to have an interface to it. So, hey, SSH. Cool. And now if we check the jails.rc.com file, we'll see that, hey, neat. SSH is enabled. Let's add a few more things. This is all, again, checklist from the man page, et cetera, et cetera, et cetera, et cetera. Anything important here? No, not really. It's all on the man page. So what do we just do? We have all our userland built, devices mounted. We just populated this with specific data. Our users added ports if we needed to, added other softwares, whatever we need. Just like we're setting up a stock brand new system. So we're almost there, right? And we configure it. We call a jailed. Let me see. Yeah, we're finished. So exit out of that shell, the jailed shell. And we're back in the host machine, chicken. And we're going to add our IP alias. We're going to give chicken.200 address. Following, again, the man page. We go through it. It's got 200. Our host has two. We're doing pretty good. Now we're going to mount the process file system in jail so that jail has a procfs to use. And there it is. Mounted. So what did we just do? Mounted proc and gave our host machine an IP address for this jail to use. So start tangent. Here's a script about starting a jail. It's pretty easy to walk down the script to see how simple it is to start this thing. It's easy so you don't have to keep typing the path to your jail to just define it as a variable. Define the IP address, define the host name. And we just make sure we've got our IP interface. We mount devfs and procfs. And we just make the jail call and run rc. All right. So the jail booting process starts after init and at rc. And here we go. So we're going to make the jail call. Here's the start. We're just going to start it manually. Does everybody understand the line that they're looking at that's highlighted in red? Pretty, pretty simply. I mean, we've got our jail, our path to our jail, a host name for the jail, the IP address we're going to bind it to, and we're going to use a shell to kick off rc as the process is running inside the jail. And kaboom, here we go. We hit return. Whammo. Hey, this looks like starting up a FreeBSD machine for the first time. We need to type a bunch of random junk to generate entropy so that our system create its first keys. If anybody's, you know, going to record this and wants the image of this jail so they can crack the keys on that later, just give me a holler. And hey, it started. Wow. And it started. And that looks like any regular boot dmessage. Started ssh, important, so we can get into it. On the host machine, if we execute the command jls, list jails, we suddenly get this little return of the jail, the IP address, the host name, and where it's living. Nifty. So let's ssh into our jail. Let's get into it. And if you notice, the IP address has changed a little bit in the slides, but that's OK. Still .200 for the jail and .2 for the host. So this is just a regular ssh login. There we go. Asks us for a password and we're in and we have our standard login message that we see scrolling down here. We just logged into the system and we added that user Ike. Logged in as Ike. The host name is Chick. We are in Ike's home directory. Neat. All right. There's the computer. And it's just like any new server that you could think of at all. Like right here, we're going to run top. Here's a video of running top. There's all of our processes running. A little send mail that we set up. Running submit only ssh. Pretty simple. Pretty cool. So inside the jail, we also have root. So we can do whatever we want inside the jail. Pretty cool. Now that we're inside the jail, how do you know you're inside a jail? This is useful for honeypots. It's useful for a number of things. There's a patch with a URL listed here. Also on the DEF CON CD materials. For how to patch the jails to not ever show that you are jailed. It's a pretty simple patch. But if you're in a jail, sys control will tell you you are or are not. So let's exit out of that ssh connection. And we just walked out of the jail. Whoopee. The jail is still running. So from the host, how do we find processes on the jail? This is from the man page. Some flags. You can throw it PS so that you can find the jail based on its jail ID. And the jail ID, just every time you start a jail, it just keeps stacking a new integer up on top. So jail one, two, three, four, five, six, seven, blah, blah, blah. But there's all the processes that belong to the running jail. Pretty simple, right? Now, if we want to kill those processes from the host system, we want to effectively stop the jail, shut it down. We run kill all with the dash J flag and the jail ID. And it will kill all of those processes. Another thing we want to make sure and do is unmount those proc and devFS mounts. That's a common mistake that trips people up because they will very silently stack up and you'll have several mounts of dev and procfs in the same place, which will only cause problems for applications intermittently. And in very weird, surprising ways that you may not find for weeks or months at a time. So it's a real pain. That's a little gotcha. Okay. So we're going to use the start script that we were looking at earlier to start the jail. So that's why it's a one line start. And really, at the end of the day, let me just say something off to the side here. It's really, really important to treat your host machine like, a platform that you never touch or log into or use for anything other than running your jails. You only want utilities in your host machine that are for the purpose of running your jails. All right. You do that. Keep really hardcore uptime, which you can absolutely do with FreeBSD. Then suddenly your jails are the things that you're always dealing with. Starting, restarting, stopping, doing, running applications out of. And it's consistent. It's it ends up being a consistent platform. Okay. So we're going to start our jail. Boom. That shell script. So we go for it and there it goes. Started really, really simple. And again, there's SSH started up as part of the process. And there again are our processes as seen by the host system. Now, JLID 6, pretty cool. So running processes. We're going to use JExec right here. JExec is a utility that you can execute a process within the jails process tree. So right here, we're going to run PS to get the processes from the inside of the jail. Using JExec, let's bring it up right now, is generally a bad idea in a lot of contexts. JExec makes a call to a low level system call called Jail Attach, which basically any time you're executing a process that's controlled by a process on the host that you're executing inside of your jail, that right there is a vector for something in the jail to escape the jail and get out of the jail. So if you do something with JExec to something that's been compromised or set up for you to do in the jail, like if you commonly grab some kind of file out of the jail and your jailed user finds out about this, they could craft something very malicious for your program to return to your host system. So you use this, you want to use this intelligently. Let's see, so in this case, if PS had somehow been compromised and changed around, tweaked, in some way to take advantage of the Jail Attach call, we'd be screwed. So, also in the host's process file system and in the jail's process file system, the status file contains as its last field the host name of the jail of the process which runs, or just a dash for all the rest of the processes. A lot of people who don't run jails in FreeBSD don't even really think about the dash. So back to this comparison, the host can see all the processes, the jail can see its processes, and when you look at a GIF, the given process on the host, in this case, what are we looking at? I think I'm looking at SSH on the host, SSH in the jail, and SSH statement. The jail has the host name as the last item in what's returned. The host has a dash. Wild excitement. Tedious details. Also in PS, you'll get under stat, you'll get a J if a process is jailed or not. So you can do all kinds of things to script this stuff. Does everybody get it? Everybody gets it. You get your virtualization. Okay. So, like... Excuse me. Is there any way to stop that process information? Yeah, patches to the source of FreeBSD. I would actually email the guy who did the patch before to disallow the sys control information leak, because that guy does a lot of honeypot stuff, and he may have already done it, basically. So we get it. So there's best practices and opportunities, okay? And while we're with the metaphors, anybody who knows who PHK is ever thought of the similarity here? I did. Okay. So first and foremost kind of idea, nobody's broken out of jail yet. PHK would love someone to do so. He wrote the jail feature originally around 98. And, you know, in conversations and just kind of discussing this with him, he kind of feels, and I would agree, that it's still kind of an esoteric thing. Like there's not a critical mass of Unix or BSD users who are running a lot of jails all over the world. So, you know, maybe it hasn't been a real big target for people, but the things that it's built on, which are chroot and your TCP IP stack on FreeBSD, sure as heck are. If someone breaks out of jail, PHK really, really, really wants to know about it. That gets them really excited. So best practices, SSH, indoor jails to manager processes, right? We already got that. You can always see the jailed file system in user land from the host server, but be careful when you're tiptoeing through your jails because you got a lot of things that are that are soft links and all kinds of other stuff that are part of your stock operating system. Like, can anybody in the room yell out what what slash home is on a FreeBSD system? Like, what actually is that? User home. Right. Soft link. So if you're tiptoeing into user home in your jail, that and you have the same perhaps username, like I've got Ike in my jail and maybe Ike in my host, if I go into that, suddenly I could do something to a bunch of files on my host machine when I meant to do it to my jail, right? So it's really bad practice to really spend a lot of time doing stuff to your jails from the outside. So design your jailing system carefully and be creative with core Unix utilities. I mean, there's how many how many how many stock system calls? Quick. What's the 1200 1200 stock system calls? That's a lot of stuff. There's a lot of utilities in there. You can do anything with what's in the box. Batteries included. Use your highest secure practices for your host server. All right. So this means everything, everything, everything. This means big fat SSH keys. This means every kind of lockdown you can possibly think of. Apply that crazy, hardcore, painful rigidity to your host server so that you liberate your jails to really be used and not be locked down that hard. OK, so great utilities in FreeBSD4. It's really worth mentioning for anybody using that JPS, Jkill, Jtop. They're all imports. They're kind of pearl based. They've got some rough edges, but boy, they're useful. Five and six onward built in PS and kill all have jail flags. Plus JLS for listing jails, which you've seen. Jexec 10 minutes. Wow. Jexec for executing stuff in jails. They attach. I'm going to jump through some of this because you can read this stuff. It's additionally handy or other stuff. Look, common weak points in jails, host name lockdown. If people change the host name of their jail, this can get real confusing. Say they know the host name of another jail in the box and you're doing something where you're trying to either stop or start a jail and you don't know which host name it is now and things can get very, very confusing so you can lock that down. Other things, resource attacks, partitions, disk images. Another one, fork bombs, memory hogs. There's solutions to deal with that direct, which we'll talk about. Direct driver access. Flags to mount FFS and ProcFS. What about this stuff is unique to jailing or this virtual machine environment? Like, you know, this is a bunch of special stuff you got to learn and deal with. If you're going to secure your jails. The only thing that's unique is host name lockdown. All the rest of this stuff is classic Unix stuff. All right. So you don't have to learn a lot of new stuff that's going to be just specific to jailing if you want to run jails to run virtual machines. Comments on isolation. I'm going to start whipping through all this stuff. Cool thing called the open route project that a guy named Evan Sarmanto did. People talk to me about that later. There are a number of ways to provide to perform resource based attacks on jails. And there's a number of ways to mitigate them. Let's jump through where they come from. OK, so process stacks. There's something on the DEF CON CD that a friend of mine, Brian Redman, gave me. To use and testing out jails. He made it a long time ago. It's called Hog. It's a few lines of source code. And what Hog does is Hog just hogs a certain chunk of memory. Real simple little program. Well, you can create a fork bomb by running a while loop and taking a hog. In this case, hogging 99 megs of memory. So this is going to fork off an infinite number of processes, all hogging 99 megs of memory until swap is burning. Well, you can lock this stuff down. Brian, here's why Brian made it. And he's blown up a lot of really big systems with this little piece of code. Memory and process attacks. Here's how you deal with it. You just lock down maximum processes and how much memory gets used by the processes. And let me see. Then you want to set immutable flags on the file. And then you could start up the jails themselves in a higher secure level so that those immutable flags root can't change that. These files, these very special files. So root becomes a little less than root, but in a trivial way for most purposes. Or you can actually set the sys control variable on the host machine so that no jails jailed root can change flags on a file. Change immutable flags. Honeypots. Okay. So this is that little comment on honeypots we already talked about. Disk resource control. Put at least your systems again on a separate partition to isolate them from your host machine. And file back disks are really, really, really cool. Disk images. A lot of people use Apple machines and are familiar with disk images there on FreeBSD. In the handbook they call them file backed memory disks using the MD config utility. Cool stuff. Very simple way to create partitions without truly creating partitions. And they're fast if you compile them into your kernel, which is a pretty simple little flag. And we won't get into how to use them because the FreeBSD handbook does a great job of telling you how to use them. Automation. Tar balls are your friend. If you're deploying stuff to a lot of jails, updating jails, you want to be aware of your dev and proc mounts. Be aware of symlinks. And you can also use FreeBSD ports. Hey, cool. You can. Let me see. Oh, not for the ports collection, but say you're in a big enterprise environment and you have a lot of specific custom jails you want to roll out like, you know, hundreds and maybe thousands of jails in various environments, well, you could actually use the ports mechanism, not taking and putting a whole jail in the public ports tree. That would be stupid and irresponsible. But here's my custom OS. No. But, you know, in a big enterprise environment, it's worth actually looking at how the ports mechanism works because you could deploy all kinds of custom jails using ports locally. And then you can also stuff stuff in CVS or Subversion. Upgrading is really cool. You just use build world. Upgrading is cool on FreeBSD in the first place. You just dive into the jail when you first run. What was I going to say? I'm going to just look at the time. I'm going to keep moving on faster. It's in the handbook. All right. It's real simple. You may ask questions. Ask me later. syscontrol.com. There's a bunch of syscontrol variables which are important, like set host name allowed, right, so that the jailed user or root can't change their host name. InforStatFS, this is so that the jail can see only particular details about file system mounts. By default, the jail can see all file system mounts on the whole operating system. Yet it may not be able to touch files on them. This is a bad thing. It's an information leak, like, hey, that guy's jail is on my machine, too. Ha ha ha. Now I know that. So you can lock this down to a point where your jail for OK, where your jail has can just see its mount points or see none. Allowing raw sockets for ping, et cetera, et cetera. All of these things have consequences and they're pretty self-explanatory. Access to routing sockets, system five IPC allowed. PHK put that in so we could run Postgres. Thanks, man. It's a pretty insecure thing, though. And CH flags allowed. Again, getting into whether or not the jailed can change their stuff. And then, of course, whether or not we're jailed. Firewalls moving on. You can't run a firewall from inside a jail. You want to talk about it? Talk to me later. Start script with the disk image. There's a few lines added for all of this stuff. Some little miscellaneous for crontabs. Just so your logs get really, really nice and quiet inside of your jail, you don't need to save entropy and you don't need to adjust the time. And it will just work and log it. Miscellaneous gotcha. You want to make sure that you change flags if you're trying to remove this jail directory. Quick words on true virtual machines. Look, this is from the VMware catalog or excuse me, from a brochure of VMware. Here's a structural comparison. VMware is a really classical virtual machine. And there have been a lot of them over the years, a ton of them. VMware is a popular one. It's a popular one nowadays and a pretty good one. A lot of people use it to run stuff. Well, you got your OS, your hardware, your OS and the software that virtualizes the machines that then get loaded into it. Very different model from jailing where you just have your hardware, your OS and isolated processes. OK, so once you get that, let's look at attack vectors real quick. VMware has got a couple problems that jail doesn't in the context of creating really secure services. One of them is, hey, your operating system is, of course, a risk and that's a risk in all cases. The software itself is something that has an unknown developer headcount and it's closed source, which all of those issues. Well, those are discussed in a lot of other lectures here. You know, in a similar vein, though, if we want to talk about attack vectors for jail, people need to really root they need to really crack chroot and TCP IP sockets on dealing. I'm getting the kill switch here. So just finish the sentence and kind of flip on and go. So at the end of the day, basically what I'm getting at is a lot of people in the world rely on FreeBSD TCP IP sockets and chroot. Therefore, there's a lot of hands working on jail without even knowing it. Then we get into those slur zones, which, by the way, are being used to capture the flag this year. They have little problems that can be overcome, but zones are cool. Zen is a whole other ball of wax, which we don't have time to talk about. Then you have, you know, Microsoft doing things with hardware virtualization. Bad, bad, bad stuff. So, look, here we are. We're almost to the end. So, look, at the end of the day, jails are this really simple thing. You can combine with anything else on your BSD system, which means a lot of other really cool technologies that are upcoming that just work with jails because they're all modular, independent, isolated things from each other. So with that stated, you can do a lot of really cool stuff with jails. And the boy, we missed a lot of fun stuff, but that's it. Look, quicky special thanks to Winter Mute, I mean, who taught me how to do jail in the first place and reality. By the way, buy Winter Mute a drink. He's up here. And also PHK and Robert Watson. There will be stuff errata from this that didn't make it on the DEF CON CD, like extra slides, up on the Nicebug website in the library. And I'm Ike, and thank you all very much. And I'm getting a yell. Thank you.