Thank you. Thank you. I would prefer to hear your ideas and your questions because much of what you see up here derives from all the good ideas that have been discussed throughout this conference in the talks and in the conversations. In fact, a lot of what you see up here is a result of those things happening at this conference. Because I rewrote the slides this morning. So we're going to talk about a couple of things related to host-based intrusion prevention on Windows and Unix. And I'm not going to try and define what those are. I think the community, by developing the intellectual property, will... Define what these are as we make advances. And I want to recognize several people for the contributions that they've made. Niels Provost is at the University of Michigan. He's a graduate student. And he's published several tools. One of them is SysTrace that we're going to look at closely. And those are currently in OpenBSD and NetBSD. And there's code on your conference CD. To support FreeBSD 5.1. And there's more code on his website to support FreeBSD 4.8. And we'll look closer at that. T7 with the Razor team has similar components for Windows. That provide intrusion prevention. Slides. Lightly different approach in terms of the way it integrates with the system. But very similar functionality. I'd like to thank DT for suggesting this thread last year in his call for papers. There was a call for talks on how to harden FreeBSD. Last year I gave that. And the gap analysis of that showed a real need for something that... Increases the integrity of the system. That all of the rest of the security architecture depends on. I'd like to thank Greg Hoglin for many insights about application security. And looking at application state. And the code at the binary level. MD5 at the Ghetto Hackers. Reviewed a lot of this material and contributed comments about how intrusion prevention. Looks like firewalls in some ways. That was a great metaphor. Gotroot.net. Helped me find exploits such as SSH for the demo. And finally FreeBSD Mall for all the free stuff that we just gave away. So more about Niels Provost. He's written a tool called Systrace. What it does is it catches all the data. And then the system calls and alters their behavior. It supports OpenBSD and NetBSD. He's also written something called HoneyNet. That supports the... HoneyPipe project. And all these tools you can find on his homepage. It's listed right there. Okay, so in the abstract for the talk. I mentioned a couple of things. Why should we care about intrusion prevention? What does it do? What does it do for us? And we'll look at how it works. And how it is consistent across the platform because of architectural constraints of the way kernels are put together. We'll look at some common features and talk about what's missing. So why should we care about intrusion prevention? prevention one way to think about this is to look at an analogy of the network layers of network security so if you if you look at layered network security you'll find rules and routers and firewalls and services at the router level firewall and I NET D or TCP wrappers and each has a distinctive performance advantage because of the kind of objects it's dealing with at the router level dealing with lower layers of the protocols and doing a lot of filtering at the firewall if you have those rules in the router you're dealing dealing with higher layers, things that are more specific to individual sessions. And at INetD, you're looking at services that have successfully connected and a context of where they're coming from and who they're coming from. So each of those has a different specificity in terms of the context information, and each has something that contributes to the performance of the next layer. So if we look at the host side, there's a parallel structure there of information flowing through the app through the kernel to disk. And applications explicitly use authentication methods. Have rules for... Yeah. when to allow access and when not to. The kernel does the same thing. Enforcing permissions and the file system does as well. At each layer, you have different performance advantages depending on the kind of messages that are coming through, and each has a distinctive advantage. At the file system layer, you've got access to individual objects and permissions specific to the object. So in terms of specificity of rules, at the application, you have rules that can be specific to the session or the connection and the kernel, rules that are specific per system call, and at the file system, per file or other object. Each of these layers depends on, in a lot of cases, the application. So in terms of specificity is the integrity of the other layers. The file system permission assumes integrity of the application and kernel. The granularity of system call permissions affects what you can do in an application. So you depend on the granularity of the semantics of system calls to decide how you're going to enforce security. The problem is, all of this depends on the integrity of the layers around a particular layer. And it's very often that applications or services run as root, and if that integrity is not held, the architecture is not going to run as root. So if that integrity is not held, the architecture doesn't do you that much. And this is compounded by advances in the various layers, encryption, fragmentation, re-encoding. All of these can prevent application layer filtering on the wire. And that's why we're going to look at this in terms of the kernel being a gap. And the ability to preserve integrity of the system and the application. Why would we do that there? It's through the application that, well, your data is going to reside there in memory, and exploits are going to go through there to get to the disk. So visibility in the application, the application layer also provides the ability for better contextual discrimination. When you have an incoming connection, you have IP address of the client, maybe a domain name. Once you're inside the application, the application is likely going to be collecting other kinds of information about the session, about what permissions have been applied. And if you're inside the application, you're going to be up to date with what the application has been authenticated. And you can leverage that contextual information about what the application has established to enhance what you can do to block exploits. So why would we need another tool to do this when we have all the other layers already? We can think about this kernel level. System call filtering as, like we do about firewalls, as an application level firewall that enhances what you do at the router and downstream what you do in TCP wrappers. A lot of exploits are going to attack through service and daemons, and without enhancing the protection against buffer overflows and everything you do inside applications, the system is going to look crunchy on the outside, soft on the inside. The problem is applications. The state is very complex in terms of the state of memory, disk, clients. On the other hand, all that contextual information allows you to write signatures that are application state specific, specific to the state of the OS. Within the context of a process, there's all sorts of system information that you can rely on that should be met. Perhaps should be consistent each time an application runs or for each session, and these contextual clues that, if they are consistent from run to run, can allow you to block from the inside of the system, inside the application. So let's look at a specific example on FreeBSD, how it works. What's the motivation for doing this? We're going to look at an SSH exploit. It's an off-by-one and channel lookup in SSH 2.9, and it was current in all the BSDs at the time the exploit occurred. And the gap analysis for this was that if we can't rely on something, a hard, relatively hard application like SSH, what can we rely on? And what can we do to prevent exploits on something we would usually trust? So in this example, the stuff being done by root is at the top of this green. The stuff being done by a client user is at the bottom. So this is an example of setting up sys trace to filter system calls for the SSH. And at the very top, you see a directory that sys trace looks in to find all the rules. The rules that specify whether to permit or deny system calls. In the second panel, we've invoked sys trace with a capital A in order to gather all the system calls. And it'll watch those system calls and spit out a list of what's... what the application... application does. So here on the bottom we're logged in as a user. We've got SSH daemon running and we run an exploit here. The exploit uses, exploits this channel lookup. The exploit payload listens on port 11520 for a connection. So that's what the payload is doing. Then the client side connects to that port and the payload folks a root shell. And there's a message from the authors. That's part of the source for the exploit. So just to make sure what our context is, execute ID and we see we're root, wheel group. And PWD shows us we're in the root of the file system. So what can we do to modify this to block that exploit? Well, here we stop SSHD and when it exits, sys trace generates a file containing all the files. So there's the file right there. User bin SSHD. And we'll look at what it contains here. What we'll see is a list of system calls. These are all the system calls that SSHD invoked. You see all names of all libraries. So it gives you all the file names that it needs access to to run. It's invoked bin SSHD. And down at the bottom of all the permissions you see something interesting. It's invoked bin SSHD. So that's something that SSHD fundamentally normally does. But we can tune it a little bit by adding a condition. Let's change it so that it can fork a shell only if it's not root. So what happens when we change that rule? We'll invoke SSHD again with a minus little a. That means apply these rules with a default deny policy. So any system call that it hadn't made the first time is going to return an error. So invoke the exploit again. The client side binds to port, I'm sorry, the payload binds to port 11520. The client side connects to it. It tries to fork a shell as root, and a system call returns an error, and they close the connection. So that's the modification. That's the modification. Fundamental motivation for doing something like this, to add another layer to the security inside the host. And that does a couple of things. In this context, we're looking at SSHD that's normally one of the most trusted applications. In this instance, it's an off by one error in channel lookup that's buffer overflowed and elevates in user to root. It was in all the BSDs, as we just mentioned before, the demo. What can we do if we can't rely on something as trusted as SSH? What can we do to prevent this? As we saw in the example, we're doing something there that's specific to the payload, not the injection method. And that's slightly different than the way we're doing it in the demo. We're doing what's happening at other layers. It's a unique way to recognize what's going on in the exploit, rather than being unique to aspects of the injection. But for each of those, if there's contextual information that's usually consistent, we can use that to form rules. 1. tô t бл legen sin 4. narrow the footprint of the exposure of the system. What kind of contextual information do we have inside the application? We've got network identity of the client, the IP address of the source of the connection. A lot of times we have user identity, either on the client system or user identity inside the application. We've got application state. We've got information about what was done to authenticate the connection. We've got information about workflow, where in the state of the processing we are. And we've got the advantage of being orthogonal to methods that are applied. And other layers. So MD5 suggested a look at firewall wizards discussion. And they were saying that intrusion prevention basically looks like a firewall. At first I thought, you know, that's a lot like a kid with a hammer. Everything looks like a nail. But they have a good point. You've got messages that come in. Messages that come in. Messages that come in. Messages that come in. Messages that come in. Messages that go out. Rules that decide what gets discarded. And in a firewall, that's packets and sessions. And the host-based side is analogous to that. You can look at it as API calls. But even more fundamentally, when you make a system trap, when the trap occurs, you've just got data sitting there. This calls a number. You've got a bunch of arguments sitting there in memory. So you've got a packet of information. So where for the network, you have packets, IP packets and signatures on those. On the host-based side, when you have a trap, you've got packets of syscall information. So you probably wouldn't consider, you know, if you have a trap, you'd be running on this network without a firewall, would you? And it's not that firewalls are the only essential thing. It's that they allow you, together with the other parts of the security architecture, to mount an effective defense. So I would look at intrusion prevention in the same way. That it's not an, it's not a solution in itself, but it's a way to tune all the layers together to provide something effective. So... where is intrusion prevention going and how is it different? The firewall wizards distinguish intrusion prevention from other kinds of firewalls in that that they use signatures rather than rules. Take a lot more state into consideration. But these aren't the same kind of rules that you might run in an intrusion detection system. In more cases, they're signatures as forms of access control. So, consider snort with hogwash. That's the sort of signature-based firewall they're talking about. And the IDNS vendors call this a gateway IDS. Some people look at it as intrusion prevention. And again, that's why I don't necessarily want to try and give you a definition. But I do want to give you a definition. There's a lot of creativity going on out there. And I think it's up to the community to decide what the effective boundaries between the layers are and what the effective architecture is. So, firewalls are complementary to routers and IDET-D. Intrusion prevention can be complementary to the IDNS. It can be complementary to antivirus, sending out a file system layer. The intrusion prevention filters messages. It's basically data staying in the stack or memory when you do a trap interrupt. And the intrusion prevention can use signatures to recognize, rather than the injection method, the payload, the behavior of the payload, and the payload. So, how does this work? Let's take a look at some architectural layering in Windows and in Unix. So, here's Windows kernel architecture, user land. It's a little bit different from Unix in that they have microkernel architecture and a few more layers. At the top, you've got executive services. That's where most of the syscalls land first. That then takes the traps, routes the messages, and you've got an NTDLL, in some ways, kind of like libc that takes an API call, turns it into a trap. Oh, that's basically what I just said. You've got, in the bottom half, executive services at the top. A bunch of top-level services that abstract away the hardware for various objects. At the bottom, hardware abstraction layers. Oop. Dang. End and home are right next to each other. So, you've got a lot of blocks to page up and page down. Okay. So, this is an example of Linux system architecture. It's similar in some ways, especially the boundary between the user land and kernel. So, you've got libc up there between the applications and the trap. Which, you know, is represented by the dotted line. Below that, you've got the system call interface that interprets the, the information associated with the trap. Turns it into access to the various modules there. And. You've got some layers, but most of the layers are specific to certain kinds of resources. In the case of Linux. And this is simply a fact of the architectural decision to use a macro-kernel architecture. So what are the common abstractions here? We've got a common abstraction in the layer between applications in the kernel and between most of the kernel and the upper side above the trap. Each of these layers provides some unique contextual information. So we're going to look closer at this particular boundary. You can apply this principle to all the other layers. This just happens to be a convenient place to do it because the method is very consistent across the various OSs. So to compare them, this highlights the similarities. We've got a C library on top. And something on bottom that interprets the traps and turns them back into calls to services in the kernel. So even if we consider the application a black box, even if we don't look at contextual information specific to an application. We still have contextual information. And at these various levels. Contextual information and API calls in libc. Or we can trap contextual information when the system calls invoked and we have trap into the system call interface. And lastly, at the instruction level. And all of these are, all these have distinct advantages. So what's being done today is really something that's the. Tip of the iceberg. We're looking at the most convenient place to apply these principles. So as, as exploits are advancing in terms of capabilities, there's a lot of focus on escaping IDS or using exceptional behavior to get in. And. I. I'm somewhat delusional with IDS. And. So what I'm. This provides a way to take an entirely different approach. And it's a unique approach because it's independent of the transport, can be independent of the transport, and independent of the method of ejection. And it can be specific. And it can be specific to the state or behavior of the application and the behavior of the exploit payload. So in terms of gap analysis, when you implement layered security, a lot of the host security depends on the integrity of the OS. And this assumption is made even when you have very complex or vulnerable systems. So this is kind of the source security issue. So it's important to keep in mind that all these things that are not regulated byовор and untrusted applications, things like netscape, IE, binds and mail, even SSH, exploits are advancing just as rapidly as the defense is. And those advances. And those advances. Are often gaining capability to circumvent existing layers. You know, using various human control mechanisms. encryption, fragmentation, re-encoding. So added layers is a common way to enhance protection. The system call rules have a distinct advantage in terms of being specific to individual system calls. And you can use them to enforce permissions, but you can also use rules to alter system call semantics, alter what the system call does and how it does it. So what we saw in the example was we first invoked the SSH daemon to generate a set of rules to allow or disallow individual system calls. So by default, we invoked it once and got a list of what it normally does. It invokes, and this narrows the footprint of interaction with the system. So that later on, if we invoke it again and does something different, it's outside of that footprint. It's blocked. And we can refine that in consideration with the other layers to reduce the dependence of the other layers on the permissions they need. For example, you can rewrite bind call, bind to a socket, so that you can open a low-numbered port without being root, and then perhaps not have to run a service as root to allow the server to run a service as root. So changing the semantics so that the application needs less resources is one way to move the specificity of the rules to the layer that best supports it. We can also rewrite system call argument. We'll talk about that a bit more. Some of the implementations use pop-up dialogs, similar to what a firewall does. So this is a big advantage in terms of being able to generate a first draft of your rules and not have to close all the gaps immediately. And it takes advantage of a default ask policy. So rather than just permit, deny, you've got default and ask. I mean, you've got ask. This allows gaps in the rules, allows you to incrementally develop the rules as you observe the behavior, and allows you to iteratively tune the specificity. Furthermore, in addition to permit and deny and ask, you can log exceptions, exceptional calls or interesting calls, divine rules for interesting calls like fork-bin-sh's root. And this permits improved reporting. Also permits logging interesting and contextual information. So when fork-bin-sh occurs as root, grab the client user IP domain and application state. So the next couple of slides talk about how this works in practice. For a lot of applications, things like LS, find, a lot of other, core components, a lot of them use around 25 system calls. And relatively heavyweight applications like browsers, email clients, you know, with rich interaction, they can use up to 60. And this is out of a total of, say, 250 for Unix. And I don't even know how many there are in Windows. A couple thousand. And as it stands, most of the current implementations are generating and using rules for file names. And in some way, this duplicates file system permissions. And what this suggests is that there needs to be more consideration of cross-layer architecture and interaction of the file system production system. Consequently, things like this don't work. performance impact of the Syscall. What it also means in terms of performance impact is that typically there's a high performance impact on applications that make a lot of open system calls. In terms of using rules that do a string match or rules that use regular expressions. And with the current implementation, you see relatively low impact on anything that CPUs or other objects bound. What this means in terms, well, let's look at how this fits into the rest of the system. One advantage of this is that the system call filtering is completely transparent to the application. So the application doesn't have to know anything about or recognize anything about the system call filtering. So you can use third-party applications, untrusted applications. The caveat is that rule creation isn't fully automated yet. It's not completely transparent to the user. And that's where it's really important for things to be transparent. And lastly, the third-party application. You can see that as it stands, most of the tools generate rules by observing application behavior. And in general, a large part of the advantage is being able to reduce the dependence in other layers. So zero-day code. There's... There's patches for FreeBSD 5.1 on the conference CD. Niels Provost has all these. They are differences between the SysTrace and NetBSD and OpenBSD current for kernel and user land in FreeBSD 5.1. It's on the conference CD. It's on Niels Provost's home page. And hopefully, it's going to work. And hopefully, we'll be in FreeBSD current soon. So here's what I believe are the current advantages of these tools. You've got things like chroot and jail for sandboxing. System call filtering does some of the same kind of thing in terms of being able to sand... Reduce the footprint of an application's interaction with the system and can be tuned for the footprint of each application. The current tools allow iterative and interactive rule generation, a lot very similar to what firewalls do. It's got some limited automated rule generation in terms of tracing past invocations they have. It's transparent to the application and allows you to tune system call permissions, but more importantly, system call semantics. You can change the system call semantics to reduce the dependency of other layers on the security architecture, on their ability to enforce permissions. So it's available for FreeBSD 5.1. And you can find updated versions on my website, on Neil's provost's website, hopefully in FreeBSD soon. The slides that you're looking at now are slightly different than what's on the CD. And the updated slides will be on the DEF CON site's archives and on my sites. And if you like, you can contact me at the DEF CON website. I'll be happy to get this email address. I think that's about it. Wow, we're way early. So there's a couple other things I can talk about. Before the questions, let me make a couple more comments. We looked at the system architecture. There's a common architecture for the layer between user and a kernel. And this is similar at the source code level for the BSDs. Great. and similar at the binary level for Windows. So for these tools in general, across all these platforms, there's a lot of commonality in the architecture of how you implement system call filtering. You've got to have a device that allows you to set rules so something in slash dev that you can write rules to. You've got to get the module into the kernel somehow. And when the module's invoked on a particular application, it's got to have hooks to start up, grab the rules, wait for an application to be invoked. And it's got to catch the application as it starts up. Between when fork is called and when the application starts up, do things like fill out the system call table. And there are a couple of methods of how you do the hooking, but it's always going to occur between when you create the process and when it begins to execute. And there are a couple of different implementations out there. Are we close? OK. I'm told the awards ceremony is going to be held in the Apollo room, rather than here. And that's at 4 o'clock. It's about 3.40. 3.45? Yeah. 35. 35. OK. So the similarities here across all these platforms are those junction points I just mentioned. Between start up of the application, or between creating the application, filling out the process structure, and starting the application. Something that happens when the module's loaded. And some kind of architecture for a device, that you can use. And applications can read or write rules to. There's a couple different instances, or implementations, of system call tracing. We looked at one, Systrace. There is another for FreeBSD called SERPNG. SERP Next Generation. They... That varies from Systrace. In a couple of ways. It's a loadable kernel module. But they both have to do the same kinds of things, in terms of where they hook in. Whether it's module load, or if it's a static, statically compiled, in the case of Systrace, there's a start up routine that gets called. So for each of these implementations, they may plug in differently, but they're basically going to plug in in the same place. Start up of the module, start up of the application, and something that happens at the syscall, at the time of the syscall. And because we've got a couple of implementations out there, I have a feeling that these things are going to evolve, like the way the firewalls are evolving, and other tools. There was a statement by Linus Torvalds recently, about people lobbying to put in other firewall implementations, and he basically said, I'm not convinced which one is the best, or where we're going to go, so what I want to do is create an API. Let them all sort it out. So I think that's what I'm going to try to pursue next, is create a first draft of an API, get Systrace and CERB Next Generation to plug in, and then hopefully let them fight it out. How we doing on time? Okay. Why don't we take questions? Right here. Oh, wait. Mark? Is there a port for this for Windows? Yes. There's a reference to it in the acknowledgements. Okay. And it was written by one of the guys at BindView with the Razor team. I'm sorry. There's two implementations for BSD. There aren't any yet for Linux, but if we use the same kernel abstraction for these modules, there's no reason we can't use the same implementations in Linux. Windows, we don't have the opportunity to implement those interfaces at source level, but the Windows, it plugs in at the same places, but it's got to muck with the kernel directly to hook in. I mean, muck with the binary. So T7 with the Razor team at BindView has a tool called Systrace again. I think the current version is 0.3. So same name, but it's for Windows, and it's on BindView's site. And I believe it's more or less open source license. I was going to ask you, in the next version of Windows in Longhorn, they have something called Next Generation Windows Protection Services, which is Palladium, which is actually exactly this. They actually, Microsoft is trapping all API calls and generating rules for them based on whether they have like a signature or something like that, unique processor ID or something of that nature. But what happens when a version of the software changes and they change the API calls that they do? How does the BSD tools react to that? Do you have to regenerate all the rules? If you're extremely paranoid, you probably would, because you'd want to close, reduce as much of the footprint as possible. But with Windows... In practice, I would imagine you would do exactly what you do with a firewall. If you upgrade a client or a service, you continue applying the same rules and you catch any exceptions and decide on the per exception basis whether to add rules. So with the Windows tool, does it plug into the ntdll.dll or does it sit above it? No, it plugs into system trap. Okay. Any more questions? No, the Microsoft research has detours library, which allows you to insert trampline functions into syscalls. Cool. For the system. And the latest messaging vulnerabilities everybody's talking about, I think one guy had to prove a concept using McAfee and how he could send this to this window. Does this take care of that problem? A lot of the windowing is in the kernel and Windows. But that's not the case in Unix. So I imagine that would be very different, implemented very differently on Unix. So maybe they're trying to fix it with this Longhorn implementation. Yeah. So I would imagine a lot of that would be rather than the syscall filtering and library call filtering for xWindows. Any other questions? We're good. All right. Have fun at the awards ceremony.