Wow, I wish I hadn't said that to him. What I was talking about before I came up is that this year was the third Black Hat talk I did. This is my first at DEF CON and I'm a thousand times more nervous about this. I've been coming since about DC 10 and I'm always amazed here. I always learn so much and I'm really honored and really stoked and really amazed to be standing up here. And a little freaked out, so I'll do my best. Sorry for the Black Hat slides. I suck. I was going to put DC logos and I was up way too late last night. Sorry. So who am I? I'm a security consultant, which means that I deal with a lot of people who get owned. That's kind of a lot of the job if you do this stuff for a living. I work for a company called Spiritipic Technologies, which is in St. Louis. We do forensics a lot. We do incident response a lot. So like I say, deal with people who get owned a lot. And weddings, funerals, bar mitzvahs. I like unsolvable problems, so to me defense is a little more interesting. I have to deal with the other side too. I think people who really understand this stuff understand that the sort of binary distinction is . . . A little bit simplistic. So my hat color is fuchsia. Something that I want to say here. I've talked to a lot of, especially in the past couple of days, a lot of people who develop exploits. A lot of really elite, really, really smart, really, really awesome people. I'm not one of those people. This is my attempt to understand this topic as a normal human. So the picture of me right there, actually, just to maybe help you out with that, is me running the New York Marathon. And I finished kind of somewhere in the bottom third. And this has been kind of a marathon too. Sort of my attempt to understand this stuff. And hopefully I'll kind of come a little closer to the middle of the pack. We'll see. So yeah. I mean, basically like right now with VISTA, we're really getting Mike Howard and these guys shouting from the rooftops that buffer overflow, zero days, that there's going to be a lot of new stuff. That's supposed to make this stuff a lot harder to do. For me, it seems like we're in kind of a flailing death loop in the security business of patches and signatures for sale on a subscription basis. And things never really seem to get any better. Did anybody go to Bruce Potter's talk? Has that been yet? Yeah. I mean, basically, to me, the security industry is kind of a racket. They really don't have an interest in making anything any better in the long term or really getting to the root of the problem. So this is kind of for one very specific kind of attack vector. This is kind of my attempt to understand kind of the root of the problem. So basically what we're talking about, I get asked by a lot of people, like, what's your talk on? And I'm like, oh, shit. ASLR, no exec stacks, pro police, canaries, access control models. And so it seems like the prevailing term that seems to make sense is exploit mitigation. That seems to be kind of pretty easy. It's a pretty easy way to describe what this stuff is. So it's a range of compiler, OS features, library features that intend to make successful compromise a little more difficult. One of the kind of the main aims and really that's kind of what a lot of this stuff is about is to make mass exploitation a little less difficult. It isn't necessarily something that's going to protect a concerted effort to go after a unique single system. But it does kind of make, things that are sort of reusable a little harder to do. And then, you know, sort of fundamentally a lot of this is about limiting our exposure from overall kind of memory corruption-based attacks, which is kind of a blanket term to describe, you know, stack-based overflows, heap overflows, return ellipses, all the, you know, kind of all this stuff. So, yeah, so we're pretty much talking about no exec stacks, ASLR, canaries, some compile time stuff. A lot of these things are compiler extensions. And I'm going to talk about a couple other containment models too. Yeah, so again, if you're elite, you're in the wrong room. Go somewhere else. Let the humans and the normals talk for a little bit, you know. This is basically just my attempt to understand this stuff and some of the implications, you know, that are out there. And, you know, like I say, this is something I kind of got interested in about six months ago. What got me kind of on it was, and I talk about this a little bit in the paper, was working a big yellow outbreak and looking at that and a couple other recent Windows exploits where it was like, well, wait a minute. Aren't they telling us that, you know, this is all fixed now? We've got the GS extensions to Visual Studio and all that and, you know, this is supposed to be solved. We've got depth, you know. So we're all supposed to be safe. It's all supposed to be so much better. So just to kind of like rewind way back, and this has been my attempt to understand this stuff. Okay, like ten people know who these guys are at least, right? Anyone? Bueller? No? All right, I'm just not cool enough to. Did somebody say it? Yeah, it's actually, I looked for KNR. I couldn't find a picture of KNR together. So this is Thompson and Ritchie. Sorry. But you're close. You get a cookie. Yeah, and I think Ritchie is the guy with the Phil Collins kind of hair, you know, with the bald on top deal. But, you know, I mean, I think something fundamentally to this whole kind of problem, and, you know, there's, if you read Joanna Rakowska's blog, there's an entry there talking about, you know, game over. Like how do you get past this stuff in a fundamental way? And I think kind of the prevailing thought is that we really need to change the computing model and kind of look at some new, like, different ways to approach this. But, you know, KNR, when they were designing this stuff, your adversary, your attacker, that's the guy at the other teletype, right? So you can elbow him and say, hey, cut it out, dude. You know, so now it's an entirely different model from what they ever expected things to be. And, you know, so fundamentally the class of bugs has been around, you know, longer than, you know, probably almost everyone in this room. You know, at least since the 1960s, we've kind of understood some of this stuff in terms of high-level languages and how they deal with things. It is something that's kind of intrinsic to the Von Neumann model. So Von Neumann, kind of created the data code abstraction. So when you are back in the early... He was a Manhattan Project guy and he was involved in, like, UNIVAC and some of these things. And on the early, early systems, to get new code, you had to re-solder, right? I mean, that's how it worked. And that was a less than elegant way to do things. So Von Neumann kind of came up with the data code abstraction. So you have, you know, code and you have instructions and then you have data. And it's the breaking of that membrane between the two. That is what a lot of this stuff is about. So, yeah, some of the cool... I always like Fandango on core. I don't know why they didn't take off. You know, like MSO 546 Fandango on core in ISS or IS, you know, would be kind of neat. But everybody kind of went for buffer overflows. And it's a less than perfect term. And if you talk to a lot of people, they'll talk about the specifics that it's, you know... It's not the best definition, but it seems to be what we all kind of use to refer to it. So... In trying to go back and, like, understand, like, how far back kind of this stuff goes, the Morris worm was... One of the vectors that Morris used to spread was a stack-based overflow in FingerD in the gets call. And it's actually bug ID number two on security focus. Bug ID one was sendmel debug, which was, like, the other vector. And it's like, yeah, okay, sendmel bug first one in bug track. Makes sense. Cool. Okay. And here's what's interesting. In Gene Spafford's analysis of it, he says that, you know, the lack of balance checking in C, the gets call and the scanf call, you know, and some of the other unsafe calls in C should be avoided. So the answer is, yeah, we've known about this for about 19 years at least, that somebody's quantified it and said, hey, fundamentally, this is a problem. So between Morris, there were a lot of system vulnerabilities back then that were not that complex. There were things like really bad coding, you know, stuff like, you know, entering bad input. I think there was, like, a VAX bug where it's, like, hitting enter a couple times or something drops you into a login. Like, silly stuff like that. So things got a little better on the basic stuff. In about 95, Thomas Lepatic found a stack-based overflow posted at the bug track in the NCSA HDBD. And what was kind of cool for me about it was he said, hey, this looks like the Morris worm bug. It's the same thing. And the thing I guess I would say about Lepatic was the reason that was so much more interesting, right, was that it was this, we were just starting to begin the commercial internet and all the interconnectivity and all these other connections between different networks and it was, like, a whole different problem then, right? And it's a problem where, you know, we're all sort of getting our brains around still, right? So Mudge wrote a paper in 95 that was kind of like one of the first ones. It actually does predate LF1. It's really, like, kind of like scratched on the back of a napkin. But, you know, he describes it as a note to himself, but it's how to write buffer overflows. You can find it out on, you know, if you're an antiquarian like I am, you can find it in a lot of places. So, and then LF1 obviously has, well, I already asked the elite people to leave, but how many people here have read Smashing the Stack? Does it qualify as elite? Wow. Oh, shit. So, like I say, this is just my attempt to understand it. I read it, like, a long, long time ago and I kind of got into, like I say, I kind of talk about this in the paper, but I got into the security industry, you know, for good or bad. You know, so, honestly, like most people in that business, with the exception of the really cool, really elite people here, I'm not writing exploits. I kind of got my hand around it a little bit, kind of started to understand it, and then I circled back to it, like about six months ago, and I was like, okay, I've learned a little bit. I kind of understand it a little better now. But, you know, he talks about memory segments, stack, it's always a good place to start. And, you know, the data code abstraction, you know, kind of really started to fine-tune and describe, like, creating shell code, some of this kind of stuff. Then, Solar Designer, in 97, just a little bit, you know, around the same time, there was a lot of activity in kind of understanding this problem around them. Talked about return to libc, because he had authored a patch, there was no exec patch for Linux kernel. And he said, hey, wait a minute, you know, I broke my own stuff. You know, here's a whole other kind of method, which is just basically preloaded functions, libraries, and things like that in memory. So, and then 99, the woo-woo guys, you know, the woo-woo on heap overflows paper was kind of one of the first really detailed papers on heap overflows. There were some other ones around the same time, so if anybody wrote them, like, don't mean to not give credit. But, kind of the same thing, you know, talking about that the heap is another method, it's another area of memory, and so when you're talking about overriding memory corruption vulnerabilities, you know, there's basically kind of the, really the kind of the three main targets that you're talking about are preloaded functions, doing execution on the stack, or writing to the heap. So, okay, so I could talk about this the whole time, and maybe you'd all fall asleep. To me, it's kind of interesting stuff, kind of the history of all this. But, kind of the point is that the approaches kind of have evolved, and you know, there is a lot of, a lot more complexity to this, but sort of fundamentally, you've got two or three places that you're targeting, and that's kind of what this is about. The vectors, you know, kind of are the same for exploitation. So, this is National Vulnerability Database, remote buffer overflows. So just remote, no locals. Up to 06, because that was kind of the end of the year. And there are some questions about the stats they use. You know, they count different Linux distributions separately, and all of that. But, you know, fundamentally, I mean, this has continued to be a problem. It's continued to be a bigger problem. You know, and I guess for me, you know, the reason I'm, you know, I really would like to see us start to concentrate on you know, some of the other problems out there, in terms of you know, end users, desktops, you know, the client end, and all these other areas. And it's like, we're still stuck in this, like, 90s loop, you know. So, this is, you know, this is old stuff. And in fact, actually, like, I find when I talk to people that work on this stuff, it's kind of boring anymore. Like, oh, network, you know, network based, you know, overflows. That's dull. You know. But it still goes on. It's still a very common method of exploitation. And we still see lots of bugs in it. So. So, you know, at a very, very high level, and again, this is just my attempt to understand these things. What you've got is unexpected input and unchecked allocation of memory somewhere. You write to the stack, you write to the heap, you call preloaded functions, you move execution to that, and you end up with control execution flow. I mean, that's sort of fundamentally. And the best way I ever had it described to me, like, quite a while ago was, you know, ten pounds of crap in a five pound bag. You know. So, you've allocated to memory and then there's more input than was expected. So, kind of the first place that things went in terms of dealing with this stuff was, you know, the no exec stack stuff, which is sort of saying, back on like the Von Neumann stuff, there's a data layer, there's a code layer, there's data segments, code segments, you know. So, let's keep them separate. So, the, you know, basic kind of concept of a no exec stack implementation is that you have a data buffer where you take input from programs and allocated memory that you're using and you make that segment kind of read-write, and then you have code segments that are read-execute. So, just, you know, keep them separate. So, the Solaris stuff, and this is, you know, what's funny to me is I used to do a lot of Solaris hardening and Solaris work, like, a lot of years ago, and people used to say, oh, you know, we're so cool on Sun because we've got the no exec bit. You know, and the truth is that it really did almost no good. I mean, it's been described as a speed bump, you know, by itself. But, you know, that was kind of one of the first implementations. And then, you know, nowadays we kind of circle back to that on the AMD64 platform, and specifically, it actually is, it's page address extensions, which give you a more kind of granular paging model in memory. And there's a bit that's bit 63 that you set to 0 or 1 for a given page, and that kind of sets the execute bit. Something that is pretty important, and we'll get to it here in a little bit, is that, by itself, the CPU is not doing anything. You have to have operating system hooks into it, and the implementation of how you hook into that is pretty important in terms of how sound it works as a protection mechanism. So, the CPU itself is not doing squat. If you don't have hooks into it, it's just sitting there. So, and then on the emulation software stuff, Solr, the no exec stack patch stuff, the stack patch for Linux was kind of the first stuff. OpenBSD's done the WXRX stuff. ExecShield is Red Hat's implementation packs, which is very cool. And then on Windows, you've got the dynamic execution prevention, right? And I guess on 64 versus 32, you're really, typically on a 32-bit platform, it's really just in the software. So, what you're really doing there is just kind of drawing a line in the sand and saying, this sort of section of memory, this segment, and divided, depending on the implementation, they divide it in different places, but it's saying, this area of memory is for data, this area is for code. One of the things about no exec stacks, and I have a friend who's a Java developer, and he always gets annoyed with me when I talk about this, and that I'm interested in it, because in Java, this is what you do all day long, is create code on the stack. And that's what a JIT compiler and things like that do, is they actually break the model. That's by definition, that's what you're doing. So, one of the things about that is that the different operating systems have had to have a mechanism somehow to exempt those things, and allow them to not sort of play by the rules. So, with the no exec stack, the vulnerability is still there, and we kind of talked about heap and return to libc and things like that. You just sort of reduce what's possible. So, probably the most important thing is return to libc. You basically call a pre-existing function to memory, something else is loaded. The reason it gets called return to libc is that libc includes a lot of common calls that will allow you to exec commands or things like that. System.insh was always the example in some of the early stuff. Most of the things that talk about breaking out of NX sort of come down to this. Another kind of method for this is to call the mprotect function, which allows you to say for this chunk of memory, don't make it don't sort of apply the protection, so you're exempting yourself out with mprotect. We'll talk about some testing tools later, but basically if you have the ability to call the virtual protect function, the mprotect function, these sort of allow you to exempt a given chunk of memory from all the restrictions. Return to libc does require you to have a known address. We'll talk about some of that later. Heat-based overflows. You know, the like I say, the libc is not the only target. Stack is not the only target. Heat-based stuff is kind of, seems like lately of more interest. Did anybody see Atlas' talk? The deal Malik talk? It's after me. Oh yeah, shit, okay. He's like way cooler so the elite people can come back then. So yeah, so stay here. Stay here. I actually want to ask him about something I'm going to get to here in a little bit in terms of heat-based stuff. Something else is mbody came up with what they sort of call multistage overflow. So the idea is, you know, when you do a noexec stack it's a very specific set of conditions that you're protecting against, which is basically like say sort of data jumping over to code. And so what you can do in the case of theirs is you overwrite a function pointer first and you point to an address and then you load shellcode at that predefined address later. And so you didn't break the model necessarily. So you didn't jump from data to code. So it's still a method to circumvent that. Escape and Skywing, and this is kind of interesting to me, have a paper, it's from maybe a couple years ago, talking about MS's dep protection. A lot of people were interested in that when it sort of first came out. Dep is configurable in the case of MS's stuff. Remember we were talking about how JIT compilers and things require the ability to construct code on the stack, so you have to find ways to exempt them out of the model. So what MS does is use process execute flags. Well, what Escape and Skywing found was that there's a value there, mem execute option enable disable. So if you flip that bit, you've just allowed yourself stack execution. And so then you can pop back in. So pop back through that and sort of opt out of that. So one of the things they talk about in there is setting the no execute bit as always on. In the boot I and I, it'll break a whole lot of stuff, unfortunately. But that on, especially on systems that don't have sort of all the other protections, so like 2003 and XP, this is probably the best you can get, is to set it to always on. If it's set for opt out, or it's set for opt in, it's kind of moot. They're basically the same thing in terms of the fact that you can set that, set those bits and let's say jump out of the model. Doesn't matter. Pax uses an ELF header and lets you set bits on a file and say like this file is blessed to do this by itself. And I think maybe that might be a higher bar than sort of doing it in memory at load time. One of the probably biggest problems with all of this stuff, not just actually no exec stacks, but the whole thing is that this is an opt in, opt out model. You can pass flags to the compiler to opt out of it. You can find yourself disabling it when you set optimize flags and things like that. So you have to be really careful, read your compiler documentation and things like that and understand exactly what you're doing. It's pretty easy to turn this stuff off without realizing that's what you've done. And then there's other mechanisms that allow people to opt out. Skywing has on his site, if you check this out, the no exec hall of shame. It talks about a lot of apps that break whenever you have stack execution turned off 100%. Me personally, running that with that bit set, Firefox, Acrobat, Java, will just barf and they'll shut off and then you have to sort them back up. Something that I thought was kind of interesting, I used to use an app called SecureStack which is a no exec stack implementation a long time ago that actually ran on NT4 and Windows 2000 before they had anything else for that. I was doing a large network that had a bunch of Veritas Backup Exec clients set up and this admin was pushing this update. They have some kind of ability to hot patch the drivers and the services that you can push update client now from the admin console and it pushes this out. Every time you ran that it would crash because SecureStack was saying no, you can't execute on the stack. A couple years later you had some stack based overflows in backup execs. Maybe it was shutting it off for a reason. Somebody more qualified than me could probably say that. The next step was to check for memory corruption around the same time that overflows and all of this stuff was kind of very common as an exploit vector. Around that same time, Chris McCowan, who has a talk tomorrow I think, the guys from Immunix developed StackGuard which was kind of an early implementation of the canary approach. Basically what you're doing is for the return address you're setting a canary value in the stack and if this value is changed that means that you've overwritten memory. In function prolog at startup you stamp it with this canary word and then at function epilog if that value is no longer there then you call exit and actually they called different calls through the different limitations of it but fundamentally you're shutting off if the canary value changed. So let's say it's kind of tripwire for your stack is the way I, sort of for me, understood it. Later versions of StackGuard kind of added different ways to do the canary stuff. There's been, there were a number of different papers that talked about problems in the way they did canaries so they tried a whole bunch of different approaches. We'll get to actually Propolis which is probably more interesting because it's more common these days and probably the most widely accepted approach for this. So yeah, Propolis is actually what was integrated into GCC 4.1 pretty recently. The OpenBSD guys did a lot of work a few years ago backporting it for the 3x GCCs. It was embraced and extended by MS as the slash gs compiler flags. From what I understand the latest version of Visual Studio is a lot closer to a full blown Propolis implementation. The early stuff that they did was just kind of sort of a kind of, I don't want to say half-assed, kind of a step into implementing that. Like I said, the gs-cookie in Visual Studio is kind of the same thing as the Propolis guard value. Hiroki likes to call it guard values. StackGuard's canaries. He says it's a guard value and he wrote it so I'm going to take his word. It's an XOR of the pointer in a random value and then you store those somewhere off the stack. He moved beyond the return address so you have sort of all registers. We'll get to that in a minute about StackGuard but one of the things that it did especially initially was just protect the return address. Variables and arrays at the bottom, arguments at the top. Something that helped me understand Propolis is whether I'm an exploit writer or any of those things I consider myself a hacker so I don't like anything with police in it. It kind of made me cringe when I read the name of it but Propolis is actually what bees use to construct their hives and so it's the outside of the hives and so really what he was using in naming it that was describing sort of a well ordered stack and a well ordered address space in memory and so that helped me understand it a lot better and I felt more comfortable about the name. What Propolis does and this is totally ripped from a slide that Hiroki did at CanSecWest so if you go get his slides they're like way cooler than mine but you're taking some of the more commonly overflowed buffers so arguments are typically things that you're going to see arrays that are things that are pushed in and tend to be places where buffer overflows are where you're inserting data and he laid out the stack in sort of a cleaner way than what you would typically have so in inserting data into the stack and overwriting a memory segment typically what overflows do is to overwrite both the array the buffer and then the return address so you kind of have to in order to do that they have to be sort of adjacent so by laying it out in a better layout it makes it substantially more difficult to exploit stack based overflows so that was to me that was more important about Propolis than maybe the guard values you know that's why I think it developed a lot wider adoption than stack guard because it was a sort of a move to a whole kind of a better model a better approach so kind of an interlude to canaries which relates to Atlas so I'll try to maybe stick around for his stuff is something that is not too widely adopted that's out there is heap canaries there are a couple implementations for that contrapolis is one attempt the open SSD stuff has the G option to mallet conf and that's not enabled by default because it breaks a lot of stuff but what this does is apply the same thing to the heap so in talking about the heap as another vector for this stuff what they do is place kind of the same thing canary values guard values at sort of the beginning and the end of the memory allocation so and then WKR I wish I knew his initials but he has this is one of the guys from Shellfish a couple of years ago and he has a heap guard implementation for DLMalloc now the thing that he says on his site is that he's discontinued development because it's supposed to be integrated into DLMalloc so that's why I'm kind of curious about Atlas' stuff because from what I could tell it wasn't yet in DLMalloc so maybe maybe it's not actually out there yet or maybe it's totally irrelevant so that's why I'm going to stick around anyway so the main thing about canaries was that if the canary is the only element to protect against corruption in memory it's the defense simply becomes sort of as good as the canary value so Gerardo Richard this CoreSec guy he had a paper on a lot of different methods to defeat specifically stack guard and stack shield and some of these other things and basically what he was talking about is if other addresses aren't protected or if you can find ways to overwrite things like stack frame pointers other places in memory it becomes a way to defeat it BulbinKiller have a there's a FRAC paper from a while ago that was specifically pointing out probably the fatal flaw in stack guard which is that it just protects the return address so they found that because of that you could write pointers in other places you could write over other areas on the stack and you were just sort of doing what was the most common method to exploit stack based overflows which is to overwrite the RTA but it's not the only way so another thing is canary is somewhere in memory if you can read that canary value somehow that may be of value there are some methods to kind of keep it off stack and so things like formats from bugs and things these info leakage might give you a way to disclose that so and this is what especially Vista there's a lot of hype about there's a lot of discussion about with Vista is you know if you look at most exploits they target kind of known addresses so if you look at exploit code they'll have you know this is you know if you ever run exploits nobody does that around here and stuff you'll see this is the red hat version this is for Fedora core 5 this is for whatever well it's pointing to specific addresses in memory so with address based layout randomization or ASLR what you're doing is you're randomizing that stuff PAX is really probably the first people to come up with this I think I think there's a little bit of finger pointing and stuff but they have probably the most robust implementation of ASLR out there so you randomize user land, case stack and map calls things like that something I like about PAX is it has a lot of tunable bits so you can flip things kind of on and off and also chpax or pax control lets you do that on per bind on a secondary basis so it's more tunable when you look at the stuff that OpenBSD does it's all kind of turned on and that's what you get so if it breaks things sorry there are some similar bits for NetBSD and FreeBSD and I actually got some slides on that later if you're interested in checking that out on other platforms exec shield is Red Hat's implementation it does some stack randomization things like that I don't know why they didn't just use PAX it was out there it was already pretty widely supported and instead they sort of decided to build their own thing so that it doesn't make a lot of sense to me I think it's one of the problems with the open source world sometimes especially the sort of corporatized open source is that even though there's things in the community people will still develop it open source but they'll still do their own thing so they can say this is controlled by a Red Hat developer so Vista adds a random XE and DLL loader varying degrees of entropy and randomization PAX, OpenBSD, some of these have a lot better randomization than Vista for apps to utilize this internally there are some compiler flags that have to be passed to it I was talking to a guy from MS a couple days ago and he was talking about how much he really hated the slash dynamic base flag because it makes crash dumps really hard for them to understand and I think there's some developer backlash about it but in order to really take advantage of this stuff you have to pass flags to the compiler Ollie Whitehouse did a talk a little while ago talking about some of the weaknesses on the heap heap addresses and the heap randomization in Vista is much more predictable than maybe it should be and I think there's some discussion that they're going to probably correct it in a couple revs so position independent executables are a way to take advantage of some of the ASLR stuff in a given XE and that's kind of required to really take advantage of ASLR fully so if DLLs and libraries are randomized that helps but it doesn't get you all the way there unless you're building things that are fully position independent themselves and so basically they find the global offset table they go somewhere random and so at each run a given XE it's sort of less predictable John Moser is a guy who's been trying to get a lot of this stuff integrated into Ubuntu he has made a little progress probably not as much as he would like but his guesstimate is that if you take stack random bits and mmet random bits it's a one and two to the power of that to predict and address you're relying on randomization to make these things a little tougher to exploit PicPy DynamicBase all of these things are kind of key to a full blown ASLR implementation if you don't have position independent executables ASLR by itself doesn't really do you a whole lot of good as it would with both bits so on ASLR basically what we ended up with was the randomization itself becomes kind of the key sort of factor so somebody that I thought was really interesting is a guy named and he's an Israeli cryptographer who looked at this stuff and said well hey wait a minute this is bad crypto right this is just kind of weak crypto he did a paper on packs on a 32 bit platform so this is a while ago but what he did was build an Apache that was vulnerable to a couple different things but what he did was attempt to do a return ellipsy on that and try to guess the offset of the system call and what he found is that an ASLR protected Apache he could exploit that in about 200 seconds the problem is that Apache restarts, respawns every time that it loads so if it crashes typically when you're taking advantage of buffer overflow you're crashing a service so if it restarts every time then you can continue to keep trying until you guess the correct address somebody tells me in Vista I think they do three failed three failed startups like service restarts three times and then it stops and GRSEC which is some other technology with packs they have some bits to do that to do the same kind of thing so if a service crashes in memory it'll restart X number of times and then after that you stop so that makes this a little more difficult and I think actually with GRSEC they pause X number of seconds again so that makes this a little harder to brute force I think what was neat about this guy he looked at this as a weak crypto system and pointed out some of the problems with it he has a paper that just came out that I wanted to point out because I thought it was pretty interesting it's a look at a way to do return to libc with no function calls so he has this if you go out just google for like I think it's is his domain he just published this a little while ago what he does is he I'll call you back what he does is scan through loaded libraries and come up with a series of what he calls gadgets which are little bits of code that do different things and then kind of chains them all together ties them all together to end up doing execution without actually calling like a function and so he has a method to scan memory for all these pieces it's not really specific to stack protection it's just kind of interesting because I've never seen anybody come up with an approach like that and it's kind of a whole different problem from some of this stuff something else that just sort of occurred to me is that Shackham on the heap in Vista you have weak randomization when you're looking at something like a client site exploit where potentially you can restart as many times as you want something that's browser based for example, you could just keep starting over, starting over in say something in JavaScript that's in a browser if you're looking at say Vista having pretty weak randomization on the heap it would seem like maybe this would apply Ben Hawkes did a talk at Ruxcon a little while ago and he talked about a method called code access brute forcing so what he does is use a series of sort of unsuccessful reads so again in ASLR being mostly a method to protect against return ellipses preloaded functions in memory have sort of you don't know where it starts and ends but it's still the same size like the system call is roughly the same size on a given platform so if you can kind of narrow it down eventually you can infer that address so he actually did a bunch of work against OpenBSD and looked at that and also things that pre-link will potentially give you the ability to guess some of those locations as well Ollie Whitehouse I mentioned him a couple of times he did a talk actually at Black Hat DC and he did it here in Vegas as well it's out there because it was at Black Hat DC you can get it on the site so it's out there on the site and he did a bunch of series of kind of regression tests against Windows Vista and looked at how efficient the randomization is and he found probably the most interesting thing that he found was that when you use the standard C and protect sorry, Mmap call, MS has like their own and he found that when you use the ANSI C one it had better randomization than when you used MS's own recommended call so I thought that was kind of funny what he what he found was that the randomization was substantially more predictable and he's got these really neat visualizations of it that make it really kind of easy to understand because you can see this kind of mostly flat line as he went through and what he did was do a series of like hundreds of reboots on a Vista box and then look at the addresses and then map them out and so what he found is that crypto there is not so great so sort of exploit mitigation cliff notes let's say no exec no exec stacks in NX if they're configurable at run time they're pretty useless there's lots of other ways so in and of itself it's just about worthless Dave Maynard called it a speed bump a couple of years ago and I think that's pretty accurate ASLR, bad crypto is not a panacea by itself memory leak bugs and things will allow you to find other ways again, canaries, bad crypto is not a panacea so all rights to memory space require protection and I think that was the lesson from StackGuard is that just a couple of addresses doesn't do you that much good the best practice today so all these kind of have flaws but basically what the consensus seems to be Schneier says security in depth the aggregate of a series of imperfect controls is a better control that's the hope so the mesh model is another expression of that it's a combination of all kinds of different features that maybe may not work so great in and of themselves but hopefully the aggregate of all these together gives us some modicum of safety and what I can say again this being just sort of my attempt to understand this stuff is that a lot of really smart guys so go by the immunity booth and talk to Dave Vytel because they're really cool guys in general and he says hey this stuff is pretty tough to hit we'll actually get to this in a little bit like what seems to be the main problem now is the ability and sort of problems that different pieces of software have in implementing all these and some of the ability to opt out of these things but sort of the aggregate of all this stuff so you've got address based randomization you've got a pretty consistent no executable stack and you've got some kind of canary method to check for overwrites and corruption in memory like the aggregate of all this stuff is you're in a pretty good spot and like I say that seems to be the consensus is that you have all these things and they're turned on consistently and it's turned on in all of your code and it's all built that way potentially what you'll get this is the hope right is that if you're running vulnerable code and you don't know about it because we don't unless somebody else has a lot more time than I do we don't read every line of every single piece of code we run it's not possible unless you do one thing or unless you sleep a lot less than I do and I don't sleep a lot anyway the intent of all this stuff is that we'll have some level of protection against these things and give a way to kind of contain this stuff so 19 years later we're just kind of getting a handle on this so what else can we do to raise the bar static code analysis something that especially if you run open source stuff something you probably ought to know about is the fortify source bits for GCC dash d fortify source equals two will actually replace dangerous function calls and things like that and look for mistakes and actually the one thing I found was format string bugs which are not that common anymore from what I understand but when they are out there they're pretty ugly stuff because they sort of allow arbitrary reads and writes to memory dash d fortify source equals two will actually catch some of that stuff in compile time so that's pretty cool which was a project that was funded by DHS went through and did static source analysis with obviously Coverity's commercial source code review product that they want to you know promote they got a contract with department of homeland security to go through and perform static code analysis on sort of every major open source project so they went through Apache and you know bind send mail lots of other things kind of that I thought was pretty sharp was Ben Laurie pointed out that it's really nice of the department of homeland security to pay a commercial company to find bugs in open source code it would be even nicer if they paid open source developers to fix them so what you're finding is a lot of this stuff and then they're not disclosing it they're working with the particular project teams to address it but then they have to have their resources to deal with all the bugs that are found sort of a limitation of static code analysis obviously the single best way to find any given bug is to actually do source code review by a human being you know line by line and yeah and there's of course discussion about things like fuzzing all this other stuff but you know Rice's theorem says that I guess for a given problem set you know there's a if it has X number of answers it's not predictable you can't fully fully predict the yeah I actually suck at Rice's theorem I'm gonna drop that but what made more sense to me was what I call Rumsfeld's corollary which is there's known knowns there's known unknowns and there's unknown unknowns so we know what we know we know what we don't know but we don't know what we don't know we don't know so you know and that's when you're doing static code review and things that's kind of the deal you hope that some of this stuff will find all these things but you don't know for sure one of the other things that that sort of comes into this stuff is access control models it's not really a method to actually stop memory corruption vulnerabilities but it is a way to sort of do containment so you have things like RSPAC, GR security AppArm, RSC Linux and there's a lot of contention in Linux about which is the best and what access control model everybody wants to do I'm just gonna say and try to be agnostic and say they all have varying degrees of complexity and I won't mention which one is the most complex I think other people probably if you've touched any of this stuff you can guess but there are lots of solutions out there that allow you to contain what applications can do and contain where they can read write and sort of even if you have exploitation or given vulnerability maybe you can't kind of find access to other areas of memory or other areas of the file system things like that MS has an access control what they call mandatory integrity control model in Vista this is the thing you click allow allow allow allow allow when it pops up so in Big Iron Unix you have trusted Solaris and HPEX has a C2 trusted mode these are sort of other ways to kind of like say contain execution based on I mean to contain file permissions and things like that based on user ID and then Little Iron Unix trusted BSD which is part of FreeBSD from 5 up and then I actually I guess should mention that OpenBSD has the SysTrace stuff which is some other ways to to control what applications can and can't do Mac has Mac now apparently it's actually part of Leopard it was I didn't find a lot of docs on it it was announced at the WWDC that it was going to be integrated and then there's if you check on Apple's site there's like no docs so if anybody's got docs on how to do this stuff in Leopard you know let me know there's some of that was an offshoot of a project called SE Darwin which is an attempt to kind of include some of the SE Linux features and the trusted BSD features into into Darwin OpenBSD is as I think probably most people know done a lot of work with ProPolice, WXRX they've got a lot of other things one of the things that the OpenBSD guys ran into a lot of debate with the Pax people about is the mprotect function call which like I say allows you to kind of say this check of memory sort of opts out of the model their belief is that breaks positive compliance and that's all well and good but I like the fact that with Pax and GRSec I can turn it off I'd like the option to say no I don't want that even if it breaks some of my stuff kernel randomization is from what I understand out there if somebody wants to tell me wrong I'll go for it but recently you've seen a lot of kernel based vulnerabilities in OpenBSD and I think that's probably a factor Pax does do some randomization of the kernel stack FreeBSD there are some ports of some of the OpenBSD stuff to FreeBSD so just google for like SSP FreeBSD and there's this guy his URL is out there I'll have the slides out pretty soon sorry they're not on the CD but this guy's ported some of the stuff to FreeBSD if you're not doing that and you're running FreeBSD all you're getting is sort of very rudimentary no exec stack the NetBSD guys have been pretty active on some of this and they really have been looking at Pax and trying to kind of add some of these features into NetBSD so with Linux you know with the integration of Propolis into GCC 4.1 kind of everybody has some bits of this the Ubuntu guys there's a offshoot of Ubuntu called Ubuntu Hard and there have been a couple different Linux distributions that have been centered on some of this stuff the Emunix guys the Adamantix guys that were working on some of these bits for Debian but the two that are most active that are actually doing a lot of this stuff are the Harden Gen 2 project and let's say Ubuntu Harden they've been sort of trying to move some of this stuff and you go out to the Ubuntu site they have something called the Ubuntu Security Roadmap that talks a lot about this stuff and actually for me that's probably where I got most interested in this was just kind of reading through a guy named John Richard Moser who's thinking about a lot of this stuff for Ubuntu like say in GCC everybody has at least the Propolis stuff but if you look through the bug reports for most of the Linux distributions you'll see a lot of stuff about hey this broke my code so I did fno stack protector all so I just turned it off because you know something broke so actually what I will say is that that is one thing that the OpenBSD guys are pretty impressive to me about is they've kind of said you know no we're going to make this work sorry so you know it's pretty cool Vista the least explosive Ford Pinto ever so you know they've made a lot of progress you know I guess what I would say is they sit where some of the security centric open source projects were about 02 you know so that I mean that's really that's pretty cool when you consider that they're a commodity operating system that everybody you know they have to support thousands of different closed source applications that run on their platforms right so they have ASLR they have some basic position independent executable stuff the biggest problem they seem to have is the consistency so there have been a number of Windows based vulnerabilities where you've seen things where people went through and said well wait a minute why didn't this get taken care of and it's been because it was compiled with different versions of Visual Studio that didn't have all the same bits or you know the also like I say the ability on a sort of software basis to opt out of some of this stuff to me I think is part of their problem something you may want to check out if you're interested in this stuff is these guys Wayness I think an app in a series of sort of binary drivers that allow you to have some ASLR for 2003 and XP which is not something you really get basically 2003 and XP basically just got kind of some of the GS stuff and a rudimentary sort of no exec stat OS X I think obscurity so 3% of the market share means that we're absolutely rock solid and unbreakable it's true you get a no exec stack in the kernel because they deal a lot of their stuff kind of ties into FreeBSD stuff and Darwin is coming for some of that so you have basic no exec stack that said no ASLR no pic no pi you know I think that Apple is going to continue to have a problem with this until they really sort of take this stuff seriously right now I say it's more about not being a very visible target I think that is why they can say they're so rock solid so belts, suspenders you know kind of both every defensive measure can be defeated in a vacuum basically the reason that I got interested in this was that all the material that I could find was either written by somebody who and actually let me say with one exception if you go to the PAC site those guys have this stuff very well documented there's a lot of really great docs out there of just going through how this stuff works and so if you want to start somewhere to understand it whether you run PACs or don't go check that out because it's pretty cool but you know most of the things that I found either were written by somebody who wrote a defensive mechanism and said how unbreakable it was or somebody who wrote or came up with a method to defeat that mechanism and said how there was no way around what they came up with so this is kind of trying to look at both sides you know volmprog.c will always get on one other piece that you should check out is PACsTest and Vistaprobe they're available for PACsTest for example is probably built on just about every platform you can run this and kind of look at on your box what do you have turned on and how much of this stuff is there and then Vistaprobe actually was written for Vista to look at some of this stuff and it basically runs through some simulated exploits to kind of gauge your how effective the different measures are so like stack execution with and protect without stuff like that and then it tries to predict how many bits of randomization you have for your libraries and executables so it'll tell you sort of where you sit and like I say same for PACsTest there's some debate about PACsTest on other security platforms is it sort of centric on PACs but it is about the only thing out there that you can sort of as an average person run and get some idea of where you sit I have five minutes let me say just real briefly the own the box thing you know where that came from was that I actually sort of wanted to find out not knowing how effective sort of really being able to say unequivocally myself you know how good is this stuff what sort of I proposed originally to the DEF CON folks was that I was going to bring a box plug it in the network and build it with in my case like Jenjoo Harden and all the PACsBits and put some services some apps on there that are sort of old versions and then when they decided that that was something they would want to promote I decided I didn't really want to make it about just me so I sort of asked lots of other random people to do this same thing and so it actually I guess I would say if you've had any involvement with any of the people that have sort of glommed together and are working on it it's kind of become more like the own the anti-cardware project so not a lot of people wanted to bring boxes to get owned at DEF CON I thought it was a good idea I don't know so if you're interested in like old Sun IPXs and like an old NexBox and things and you have some stuff that will work on that you know it's sitting out there what I will say about my stuff is that I brought actually a pretty nice piece of hardware running in my case like 1.3.37 of Apache that should be vulnerable to the mod rewrite overflow and open SSH some other things I think really the reality is that people that are sharp enough to to actually look at some other ways to get around some of the things that I have turned on probably not really interested in my like shitty $500 server but if anybody wants to talk about some of this stuff and tell me why I'm wrong that's cool that's about it thanks guys thanks for sitting through this waiting for Atlas