Hello everybody! Man, this stage is not doing anything for this whole, like, Hackers Are Not Rockstars thing. Yeah, Hackers Are Not Rockstars. Who are rockstars? Rockstars, man. I made a few. We got nothing on them. Alright, so, before I say anything, I want to thank, you know, thank you Baidu. Only Epcon could go to China, and I think only you could make that happen. So, thanks guys, and thanks to all the other sponsors who've brought me. This is my first time in China, first time in Beijing. I've been to Asia before, but never out here. It's really exciting. So, what are we here to do today? Well, this is a keynote talk, so I'm supposed to inspire you all to build crazy, interesting things. This is a technical talk because, you know, they say you stop writing code in your thirties. That is a dirty lie. I've written more code in the last few years than ever in my life. The goal of this talk is to connect a series of concepts you may never have thought were linked. The quote-unquote hacker mindset really is just saying, you know, those things might be connected. Hamburgers and cheese, that's great. Hamburgers and clouds, sure. Anything can be linked, and I kind of want to, like, expand your horizons there. So, let's consider this sort of a skydive. We're going to start with a bird's-eye view, and then we're going to dive straight into the weeds and get ourselves, if you'll excuse me, pun, a bug's-eye view. So, I wanted to start this discussion, you know, there's a problem where we talk about hacking in terms of only software. So, like, if you already understand software, maybe you'll understand what I'm talking about. But what does hacking look like when it has nothing to do with software? And I figured, you know, most of us can see. I do have a hobby on human perception. Ask me about colorblindness sometime. There is a myth in human vision that we see at 60 frames per second. And I say it's a myth because you can run pretty much any experiment you want, and it's like, uh, no. We don't see at 60 frames per second because we don't see at frames per second. Your eye just kind of, like, wanders around and collects a bunch of gunk, and your brain's like, ahhh, what's that? Yeah, this is, uh, this is why dreaming works. This is why you're able to see things when your eyes are closed and you're unconscious. And your brain just makes stuff up. It's kind of cool. But why is the number 60? Because it shows up all over the place. Now, my traditional answer to why 60 frames per second is, oh, they say it has to do with human vision, but really it's 1940s television technology. That's just how fast we ran TVs back then. True, it was how fast we ran TVs back then. But why did they choose 60? They could have chosen any number numbers, but why 60? Um, I didn't realize my answer was incomplete until some news came out of Eastern Europe a few months ago that everyone's clocks were running slow. I actually literally mean, like, the clock radios on their, like, you know, cabinets. Um, European clocks move six minutes after dispute saps power from this electricity grid. Turns out Kosovo and Serbia don't like each other very much on your statement. And, uh, there was some, um, stealing of electricity and it was slowing down the frequency of the power. Just like, uh, water out of a tap has a certain temperature, power out of a wall has a certain frequency that's supposed to be around 60 frames per second or 60 hertz, and it wasn't. It was going a little slow, and so everyone's clock was going slow. Now, you could just have, like, a clock in your clock radio, a little coarse crystal that vibrates, but, uh, you could keep it cheap and use whatever's coming out of the wall, assuming it'll never change. Uh, just because you can doesn't mean you should. Let me tell you how often this happens in security. Oh, that thing, um, we'll just get it from the, the upstream. They'll take care of it for us. Well, they weren't taking care of it, and now the clock's running slow. So, we didn't make television 60 frames per second for human vision. We made television 60 frames per second because there was a 60 frames per second, 60 hertz clock handy. Okay, well, why was that clock 60? Why did the power lines go to 60? So now you just get to keep digging. Power was 60 hertz because in 1890, that was what we were good at making technology do. Uh, according to Wikipedia, the induction motor was found to work well on frequencies around 50 to 60 hertz, but with the materials available in the 1890s, it would not work well on a frequency of, say, 133 hertz. And that was too small to see up there. You actually see, like, all the various frequencies that people paid for, for power lines. So now you get the 60 frames per second thing, which supposedly had to do with vision, actually 1890s power generation. Kind of funny. But let's keep digging. So, um, it's funny. It has nothing to do with human vision. Why did they pick these numbers in the 1890s? Why was this what the materials did? Well, quote, there's a fixed relationship between the number of magnetic poles in the inductive field, the frequency of the alternating current, and the rotation speed. Ah, so now, now it's not 1890s technology, now it's physics, actual physics encourages 60 frames per second. And this is what blew my mind. I wanted to bring this up because I did not expect to find anything close to this when I started digging into the number 60. You know, our brains are made of physics, too. Human vision comes from the brain. Electromagnetic signals, we have an entire series of waves called gamma waves that run at 25 to 100 hertz. Pure speculation, you might have 60 hertz and 60 frames per second and all these things because of physics. And physics is a shared element between power generation in the 1890s, between television and our brains. This might be correct. This might not be. And that is part of hacking, too. You might be thinking, why have I gone to this length in a talk that's supposedly about bugs? And what I really want to get through here is we don't necessarily know why things are the way they are. Usually, as a society, as a people, we do things because we've been doing them, and they mostly worked. What hasn't been a problem? What I want to get across is there's a universe of reasons why things are the way they are. Sometimes they don't need to be that way anymore. Sometimes they really do need to stay that way and we just don't know why. So stay intellectually honest as you go through these deep dives. Understand you really are operating from ignorance. That's actually your strong point. You don't know why the thing is doing what it's doing. That might mean you find something new. It might mean you aren't. Just have some humility as you explore, but also explore. I do it. It's okay. Just know that you're speculating. So, speaking of speculation, let's talk about what is actually going to actually become one of the ugliest bugs we've had to deal with in the last 10 or 20 years. Speculative execution bugs. So there's a couple that people have nicknamed and talked about. I assure you there's a hundred more. And I'm not exaggerating. Number 98, number 99, number 100. There's a giant pile of flaws in this arena. What are a spectrum of them? The best explanation that I've had, that I've been able to explain to people, is that, you know, you ask your friend, Oh hey, you go to the coffee shop? They're like, No! Hey, do you go to the bar? No! Hey, do you go to the club? No! When you say the same thing, but you say it a different time, sometimes you're not saying the same thing. These bugs are timing bugs. These bugs involve a security boundary attempted to be maintained by a microprocessor, where it either is or is not supposed to give you some bit of information. And in fact, it finds out that it's not supposed to. It rejects. It gives you an exception. It gives you an error. But when it gives you the error, it's different, based on some information that you don't already have. Generally, it's the sort of thing where, hey, the first character in this password is A. The first character in this password is B. The first character in this password is C. And when you say C, that is the correct answer, either things go too fast, or things go too slow. In the case of Spectre, it's where you're trying to read data that you're not allowed to. You're told no, but it's the wrong time. Actually, that was Meltdown. With Spectre, you're trying to run a code you're not allowed to. And again, things go faster and slower based on what you were or were not allowed to run. What went wrong? Now, commonly people say when things go wrong, oh, you know, Intel, they were lazy, they were stupid, they were bad people. I have to tell you, in 20 years, I've never seen stupid moralization fix anything. Like, we're engineers. Sometimes things are going to fail. We can either figure out why they fail and do something about it, or we can point and laugh. Don't get me wrong, lots of people like pointing and laughing, and they can go have fun doing that. But as engineers, and hackers are a sort of engineer, we have better things to do. We can point and study. So, digging in, the assumption in a lot of vulnerability analysis for bugs like Spectre and Meltdown, these speculative execution flaws, the assumption was that you could find out that something was in memory, but not what it was. So here's the deal, maybe a little lesson in how microprocessors work. It doesn't matter how fast your chip is, it doesn't matter how powerful it is, it doesn't matter what crazy 3D instructions it can do, if it doesn't have the data in hand to work on. So, a lot of the real world work of making a fast chip is in making sure the right data is available at the right time. So, your system might have gigabytes of memory, it only needs to work on a small subset of data at any given moment, but that data really needs to be available or the chip is just going to sit around like, oh, I guess I gotta wait like 20,000 cycles for the data that I need to work on. That means it's running at 120,000 the speed or so, for certain instructions anyway. So, your chips have caches, they have local stores where it's like, okay, so I have a copy of what's in memory over here, if I need to run it, I don't need to go all the way up to main memory, I've got some what's called my L1 cache. The assumption was that you could know that something was in L1, but not what was in there. So, that was a nice theory. Unfortunately, we have very rich things that we can ask the chip to do. We can tell the chip, hey chip, I want you to go get me this memory plus the value of that memory over there, like the address, it's like, hey, there's a house at 55 Santa Monica, go to 50 and by the way, take that 5 that's over there and add that to the address too. In fact, I don't even know if the 5 over there, whatever is over there, add it to the address. Maybe you end up with 55. So, this action happens without any care for the security model that the chip is trying to maintain. It will simply go ahead and be like, okay, well, I've got this base address of 50, that value over there was 5, I guess I've got to go retrieve 55. Now, as the attacker, you're like, hey, do you know about the address of 51, 52, 53, 54, 55? And 55 actually is already there because that's what was forced in. And so now the attacker knows, okay, that value was 5. There's only 256 possible values of a byte, so you do this 256 times and you get the byte. You might say, oh, but the difference is going to be really small, it's all really fast anyway. Yeah, it's really fast. That means you can do it like a million times in a second. Any small difference multiplied by a million is no longer a small difference. Especially when you can do what's called a CL flush, a cache flush, make the difference as large as possible. So that's kind of the transition that has happened. The shift in attack methodology. But there's something underlying all of this, which I really want people to understand. Spectre and Meltdown and this entire bug class exist because we assumed we could make computers faster. A lot of people are like, why do we have these bugs anyway? Isn't this just math? Can't we prove things are correct? And we can't. The primary consumers of mathematical-proving software in the world are microprocessor designers. You know why? Because when a chip screws up, you can't easily ship a patch. We try, but that stuff is... those bugs are literally etched in stone. That is, in fact, what they're in. We really, really do not like having microprocessor flaws. And so we do a tremendous amount of work with what are called theorem provers, what are called SAT solvers. And we make sure the right bits, when the right bits come in, the right bits come out. Time has not been part of the equation. That is why your computers are allowed to get faster, your phones are allowed to get faster. If you really think about it, a faster computer is doing different things. It is. Before it took this long, now it takes that long. That computer is operating differently. But we define it as operating the same way. So, all of these bugs happen because security has been made to depend on an undefined element. So, context matters. If you'll excuse me hopping to the 30,000 foot view. Are two things the same or are two things different? Depends on the context of what do you mean by same and what do you mean by different. Same thing might be predictable or random based on context. Corporations, relatively predictable, you might even call them plodding. But an executive at a corporation, that guy could quit tomorrow, could have a nervous breakdown. An executive can be erratic. But the actual heart in that executive is actually beating erratically. By a behavioral standpoint, the heartbeat is pretty steady. But a single cell in that otherwise beating heart, that single cell might be erratic. We're talking about the same point in space, the same point in time. Is it predictable? Is it random? It depends on the context in which the question is asked. Are two computers doing the same thing or are they doing different things? Well, it depends. Does time count or does time not count? And there's not a right answer to that. There is no one context. A huge amount of what we do in hacking and what we do in security is we play context off one another. We're like, that context thinks this is stable, that context thinks it's not. They are going to behave in a different way. We said something right down in the middle. Tremendously reliable source of vulnerability. So, the CR-improvers didn't fail when they showed no leakage of information between contexts because the right bits went to the right places. They just weren't being asked to prove these particular elements. The last thing that we did that caused Spectre and Meltdown to occur is what I call the Great Repurposing. We turned a stability boundary into a security boundary and hoped that it would work. Spoiler alert, it did not work. Historically, I know this is going to surprise you guys, most software is pretty bad. Like, it kind of barely works. Historically, most code would crash all the time. The game was making it so it would only crash itself. Like, how do we get it so when the calculator dies, it doesn't take down the server backup. Because I can live without the calculator. So, we did this stuff where all the software was specifically opt-in to the resources that are required. This is my RAM, this is my network connection, this is my stuff. So, when the software blew up and visibly blew up, you could clean up just those parts. So, the theory was that hackers were just kind of a new source of misbehavior. Instead of the software crashing randomly, it was crashing because someone intended it to. But otherwise, we could still see it doing bad stuff and we could still cut just that part off. It kind of worked. It kind of didn't. Here's the thing about hacker misbehavior. Hackers are actually pretty well behaved. You know, when hackers crash code, it doesn't actually crash. It actually does, like, re-control things. So, what hackers are doing is changing smaller things from a computer's perspective that are bigger things from a human's perspective. So, you don't get these random, noisy data structures that immediately cause all these exceptions to fire. Instead, you get nicely well-defined data structures that cause a calculator to pop up. In the context of Spectre and Meltdown, these attackers change time. Which, in this context, is not defined to exist. These operations that might happen fast, might happen slow, fast and slow don't exist in the context of the microprocessor running these instructions. They're allowed to take as long time or as little time to get the data out of memory. So, it means nothing to the chip, but it means everything to the users, to the administrators, to the security models, but nothing in this context. That's what's going on. It's worth noting, by the way, that the exploits in Spectre and Meltdown involve attacking the system timers, which often operate once every 15.6 milliseconds. Kind of a specific number, that 15.6. You take the reciprocal and you end up at 64 frames a second. Because the only thing computers like more than repurposing 60 FPS is powers of 2. So, there's a thing. Spectre and Meltdown leak bits that we would prefer they not. You can't leak bits you do not have. There is a hidden architectural choice in all of these bugs. That architectural choice is decision. It's context switching. What we do with computers generally is we have a tremendous number of contexts in which they're operating. One moment, it's you, the user. Another moment, it's the kernel running some device driver. Another moment, it's the web browser as a whole running something. Another moment, it's JavaScript from an individual page on that web browser. It's constantly flipping around and flitting around. Some of those contexts have special access to data and some of them don't. And we hope the design of our interesting architectures mean when we switch from one context to another, nothing is left over. Now, you can do that. But there is another context. And it kind of goes back to the quote, if you want two security domains, get two computers. You can do that. Computers are small now. Like, I don't know if you guys have seen this stuff coming out of Shenzhen. This is beautiful. Look at this thing. This is 20 bucks. 20 bucks. It's got four cores. It's got a half gig of RAM. It's got gigabits. This is ridiculous. Look at this thing. I actually have one here. If you want to know if I bring a camera, I'm like, no, I want you guys to strain your eyes to have to see this. This is like, hey Raspberry Pi, nice job, but here's a real computer. It's got an Intel, it's got Apollo cores, four cores. It's got PCI Express. It's got, you know, let's see, five gigabits, ten gigabits, USB, three. It's got a PCIe port on the back. Like, you know, yes, we can totally go ahead and try to make context switching work. But, you know, instead of trying to pretend like we have a hundred computers, maybe we should just have a hundred computers. We could potentially do that. So, our present approaches to dealing with Spectre and Meltdown has been a little painful. There's a lot of work that we put into making context switching able to be aware that there is a security boundary and that we should not just protect what is visible at the user level or even at the kernel level, but actually what's called the microcode level. So, let me tell you something. Intel chips haven't been running x86 for a long time, okay? Like, there's another operating system underneath every operating system that you run. And that is the operating system that's managing all sorts of this prediction, what memory to grab when. That's the thing that we're interacting with, with all these Spectre and Meltdown patches. It's incredibly painful, and honestly, it's pretty slow. There's a great article from... actually, there's a great proof by the guys from this company, Research in Motion. They made the BlackBerry. They basically made a really compelling argument that the iPhone was totally impossible. And their argument was incredibly compelling right up until the moment that Steve Jobs dropped an iPhone on the table and said, Well, what do you think of that? The iPhone was impossible because, well, we just sort of assumed a certain amount of interactivity required a certain amount of power and electricity and resources. And here's what we were going to get from batteries, and here's how fast batteries have been getting better. And, you know, you intersect all your curves, and you end up with the iPhone will never have a battery life more than 20 minutes. And if all of those assumptions were true, that would have been correct. All of those assumptions were not true. The reason computers got fast is because this microcode layer, these layers that do all of this prediction about what resources are required when, what work can be done in advance, so that you don't need to wait and find out in real time. Like, okay, someone asked for this, and I have to do a bunch of this other work first. The work to be able to be long. Here's the interesting thing. One thing that every class developer is bad at, but the microprocessor guys are masters of, is this will probably work. The microprocessor guys have mostly figured out how to do. We're going to try this because 99.9% of the time is exactly what we're supposed to do. 0.1% of the time, it was the exact opposite, and we need to hit the brakes and pull everything back and make it like it never happened in the first place. Pretty much only the chip guys have this working. But man, you ever wonder why Intel chips are really fast, and chips that have the exact same specs, they're just as good memory, they're just as good instruction set, but for some reason everything is slow? That's why. Branch prediction. Because we didn't have the worst machine learning around yet. Oh yes, prediction and learning, of course they're linked. Kind of obvious when you think about it in retrospect. Tangents aside, I like going by tangents, what can I say? We have patched everything in case there's a security boundary. That doesn't actually mean there's always a security boundary. There's a ton of machines where the only user on the device is the administrator. There is no non-root. Or, sometimes the administrator is only not the administrator when they're running a web browser. And some portion of the administrator's code is a non-root, actual non-user. They're still the user, but they're not the user who should run code, they're the user who should run JavaScript under a particular domain name. Under the same origin policy. There's a huge amount of what you might call in the electrical domain, impedance mismatch between the security models that our architectures expose and what we actually do in the real world. Let me tell you, there's nothing about that. The most popular security model in the world is the same origin policy in your web browser. It's the thing that makes it so you can have one tab open for email, and one tab open for news, and the news site can't read your email. Like, someone had to build that. That security model, nowhere to be found in how ships work or how operating systems work. But it's like the most popular thing to do. So, as we work to deal with the horde of bugs that are coming along with Spectre Meltdown. I'm not joking, I think 8 got announced today. We will get a more explicit type of security domain to be declared. It won't look like users, it won't look like processes. It probably won't even be constrained to single machines, because guess what? As you look at the cloud from the large scale, or as you look at, if you want two computers, two security domains get two computers at the small scale. All sorts of resources get lashed together. And the amount of flexibility that we're going to need to declare what is and is not able to manipulate each other. It's going to get complicated. It's going to be interesting to watch it grow though. There's a shocking amount of operating system design work going on out there. I thought I was being all clever, I'm not even going to lie. Oh man, I really found the future. And then it's like the HPC guys are like, get in line Dan, we have figured this out long before you. And why has HPC, High Performance Computing, figured this out? Well it turns out, huge amounts of just how operating systems normally work involve a user-kernel boundary where the user is untrusted and asks the kernel to go do something. This turns out to be ungodly slow. I'm not sure how much of our computer performance we're giving up to this, but it's pretty clearly double-digit. Everything fast goes ahead and just for performance reasons, just for perf, says user-kernel needs to go. So you'll see like, you know, Intel's networking stack, DPDK, will run entirely in user space. There is a Linux web server called Tux, it should be now Sys in Windows. It will run entirely in the kernel. There's a cute little thing, you will know somebody is an old school kernel hacker if they've ever heard of the phrase kernel mode Linux. And you'll know they're a security person because their head just exploded. There's a funny thing called rope kernels. They claim to not have kernels in the kernel. This is not actually true, they totally have all the kernel code. They just don't run the kernel code with a kernel boundary. They run a kernel as a library. There's even a thing called LKL that is Linux run as a library. It's really cool. You run a command, watch Linux boot, you're in Python. Like, you go to the library, but it's Linux, it's kind of neat. There's a giant amount of work going on here because when you look at the HPC space, when you look at all the people that are looking for performance, what they are really saying is, there's a security boundary, but not you. These literally thousands of computers all trust each other. It's not like 500 of the computers over there are run by bad guys, but we want to hopefully still get useful compute out of them. No, they're all mutually trusting. So, there's a thing that security forgets, which is that you can have a place where a wall could be, but you don't always want to put a wall there. Not all walls are a good thing. Build your boundaries to what the actual security model is. Otherwise, you'll have fake boundaries that are just speed bumps for people to jump over. You've just stopped useful work from happening. So, why am I telling you this? Well, me being kind of real here, security that doesn't care about the rest of IT is security that grows increasingly irrelevant. Computing in 2023 is not going to look like computing in 2018. Too much is changing. Like, that gear that I showed you over there was not around like 5 or 10 years ago. That matters. Like, we build things differently now. In fact, computing in 2018 doesn't look like what most people think computing in 2018 looks like. There's a lot of mental models, even among hackers. People are really, really stuck on what they have on their desk. Let me tell you, I go ahead and I rent a machine for $13 that's got a terabyte of RAM. I solve problems differently than you do. Also means I have vulnerabilities different than you expect. So, that's the flip side. If you're just looking for bugs, look for things people think don't matter. Look for time, look for the flawed assumptions that developers have, that operations has, between how people think the system works and how it actually does. Bugs aren't random because their sources aren't random. The mismatch in assumptions starts in the developers thinking their system is working one way and it's really working another. And then, going on, it's what, as a hacker, hackers have to model. Hackers aren't just modeling code. These are not good ones. Hackers are modeling the developers and saying, what did that guy screw up? I tell you, I can't tell you how many... Okay, this is my own process. I used to run a hacking group out of Seattle. We spent a couple of years at Microsoft. Every time I would sit down with a team, I'd just be like, tell me your story. Tell me what you're worried about. Tell me how you think your system works. And you know what I'd do then? I'd shut up and listen. And listen for all the things they didn't talk about. Because that was always where my first bugs came from. It's like, oh, you didn't think of the auth layer? Oh, you didn't think of the storage layer? Oh, you didn't think of the directory layer? You just look for what you see in the code, and what the developer isn't thinking about. Like my favorite one of my audits, going off on a complete tangent. I'm like, reading through the docs. Like, what verb here? Repair. I'm like, hey Bob, what does repair do? Bob gets this look on his face. That's still in there? Yes. So many bugs. People think bug finding is purely a technical task. And it's not, because you're playing with people's assumptions. It's so much more, or at least there is such a strong angle of understand the source, and you'll find the destination. So right now is about a good time to introduce what I'd like to say is the big, catchy, only vaguely correct catchphrase designed to spark interest. There's no such thing as reverse engineering. This is only vaguely true. It's kind of a cute little combination. Let me tell you what I mean. You know how people are like, oh, you know, our team, we only make the car drive left. Right? That's some other guys. It's just my job to get my plane in the air. Who cares if it lands? It's not that there aren't different teams. There could be a different team that handles takeoff and landing. It's just that if you don't care if your work affects the other guys, you're going to crash. So my thesis is there's no reverse engineering. There's no forward engineering. There's just engineering, okay? But we do have cultural elements in engineering that block the integration of forward and reverse. And the primary thing that we seem to do wrong is I think we have aggressively separated development and testing. And it's biting us. It's biting us really hard. Hackers like, you know, I was the director of hacking. I was the director of penetration testing. Hackers like, you know, penetration sounds cool. But no, testing is the important part of that phrase. We are a specific branch of testers that, I don't know, gets on cooler stages or something. Testing shouldn't be split off, but it kind of has been. And it's kind of had to have been because people, when they write code, tend to see that code for what it's supposed to be. And as a tester, you're trying to see it for what it really is because you're doing some things. What this means in practice is that large amounts of tooling in software that tells you what software is really doing are isolated to a different group of people. So the developers who already have a problem psychologically of only seeing what their code is supposed to do are also isolated from all the software that would tell them, no, actually you're doing five other things for what you really shouldn't be. So it creates this enormous bias in developer knowledge. Anything that's too testy goes to the test people. They'll figure it out for us. And what it does, it ends up biasing the generation of a lot of code. And let me actually show you in concrete terms what I mean by this. So, Fortran, ancient language, pretty fast, lets you do a lot of interesting math. Python, convenient language, not so fast, but fast enough, useful. And last step, did anyone here ever use a package called Numba? See, we can't just stick to hacking, okay? Like, there are some tools out there that do some freaking magic. Numba is, as far as I know, the first practical environment for taking what is, you know, Python has a nickname, executable pseudocode. It lets you write Python, and then it does a bunch of magic, and suddenly you have code that's approximately as fast as Fortran. I am not even joking. It is a LLVM CPU-GPU optimizing platform. It is an optimizer, which means it works like most optimizers do. It constrains what it thinks can come in, and given those constraints, throws out a bunch of optional work at runtime, and ends up delivering very fast execution. It's important you think about all of the, what I just said in the context of hacking. What happens when you define your constraints incorrectly? There's a simple answer, vulnerabilities. Stuff blows up. At best, you get the wrong answer. Most commonly, you get undefined behavior, which in the presence of hacking, becomes redefinable behavior. The problem that even Numba has to deal with is that Python is a dynamically typed language. When you have a variable, you don't really know what's going to be in there. So there is some dependency on the developer telling you, 2 to the 63, or 2 to the 64, and so on. Now there is some developer pain to go ahead and declare up front what data types are going to be in what place. The whole reason they used Python was they didn't have to declare that. They could just say, there will be something there, figure it out at runtime. Well, a really cute code came out recently. Dropbox wrote something called PyAnnotate. And what PyAnnotate does is it looks at... So you write your code, you write it your normal way as a developer. And you run through the test kit, or you run through production data. And it looks to see what's going through. And it says, ah, this was dynamic, but man, all we get in production is a bunch of floats. This is probably a float type. And here's what's key. It goes ahead and it updates the code. There's actually optional typing information in Python now. That is one of their dev extensions. This is the thing that you don't do. You never have runtime, alter compile time. Only the developer is allowed to actually touch the code. That is an unnecessary constraint. Now, this work has only come up for correctness. It hasn't come up as a means of accelerating number. I'm just getting in front of you guys here saying, oh man, we can make a bunch of code real fast by using PyAnnotate for performance instead of just security. Even the authors of this code consider it appropriate only for legacy. They're like, oh yeah, but the developer should do the right thing. Okay, yeah, it's not vitamins. It's not eating your Wheaties or eating your cereal. There's a job to do, which is to secure millions of lines of code. Let's figure out what we've got to do. And if we can discover stuff at runtime about what needs to be done to keep things secure, yes, do that. Why shouldn't runtime influence code? The approach does seem weird by standard models. It's a little similar to what's called profile-guided optimization. It's where you run a bunch of test code and you spy on what happens. But a lot of profile-guided optimization only lives in the compiler. It doesn't actually touch the source code. What I'm telling you is, no, we should actually update the source. Partially because the developer sometimes needs to say, no, it's just all floats today, sometimes they're big floats, sometimes they're integers, sometimes they're this, sometimes they're that. Developers don't know nothing. It is a little bit of pair programming with the machine, but if anyone here has ever coded for Android and you hit that tab key a lot, it's not like that's that new. It's important to realize that we are loosening the assumption that the developer knows what the system is supposed to do. See, we think we're the only ones as hackers that are ignorant. But the truth is, everyone who touches the computer is a little bit ignorant. Developer tools are weird, though, because they are the things that assume the developer is right. Because that's what you do in optimization. In optimization, you assume, okay, they have told me exactly what I need, I can throw out every handler, I can throw out every other possible path, let me just do the thing that my ground source of correctness and truth and loveliness, the developer has said. And any day, hacker tools don't do that. Hacker tools are all like, let's figure out how the hacker screwed things up, how the developer screwed things up. Because sometimes it works. All of our tools are incomplete. All of our tools are blind. The one concrete difference between reverse engineering and normal engineering is do you have the source code? I know this one guy, he's going to laugh when he finally sees these slides, he doesn't even bother with source if it's a C++ code on it. He's like, man, C++ lies to your face. Forget it. What is the computer executing? Binary. What am I going to read? Binary. That way, whatever I happen to get out of it, at least me and the CPU are on the same page. Forget what the developer thought, he doesn't know what's happening anyway. You know what, that guy wrecks code. He really quite does. So, one of the directions that I'm moving in, in building tooling that really unifies the building and breaking mindset, I'm a little tired, if I'm using an open source platform, why can't I see the source every time something crashes? I mean, yes, I can compile my particular app, but you know, it's got a library, and then, oops, it didn't have the source. Or it's calling into glibc, and oops, it didn't have the source. Or it's calling into the kernel, and oops, that didn't have the source. This is ridiculous. Like, yes, I understand the tools did not want to take a hard dependency on source being available. I once went into a SSD manufacturing plant, and I'm like, I want to audit your SSD from top to bottom. And they just looked at me with these sad eyes, and I think they basically finally got out, there probably is not a company in the world that has all the source code required to make a solid state disk. Each of them passes a binary blob onto the next, so that they won't be factored out of the manufacturing equation. We have a little bit of that going on in software, but it's unnecessary, because in software we have environments like Gen 2, where you can say, I need you to compile everything. And I need you to put all the source code right there. So I've been playing with, what's it like having source code access to absolutely everything in a system? Oh my god, it's awesome. Like, error messages are terrible. Developers pretend they know what they're telling me. Oh, it's because you forgot to set this flag on this thing. They're making random noises. Show me the source code that's crashing. And so this is the middle of SSH, and this is the middle of TLIPC, and I just have a nice, consistent, if it blows up, I get to see why. It's lovely. It's lovely for hacking, it's lovely for development, to be honest. And I mean, in this scale, it's whatever's on that machine. So it's running on SSH, a little tiny thing, it's running on Chromium, frankly, an operating system larger than Gen 2 in the first place. So I like to joke, ADB is old and busted, APD is the new hotness, always be debugging. It's a legitimate question. If you're always running a debugger, sometimes that code is running in the kernel, sometimes that code requires permissions to look at. You know, are you going to be typing sudo all the time? Like, are you going to be getting root? Okay. You ever get the feeling it's easier to be root on someone else's machine? Because, like, you have root for, like, a year somewhere else, but you are typing sudo, you're getting root, like, one line at a time. Like, I need to do something as an administrator. I need to do something as an administrator again. No, I'm still doing something as an administrator. It's an awful user interface when your work as a hacker involves constantly having to do things that alter the machine state and therefore constantly require root permissions. And by the way, you get such a wide variety of broken software behaviors. So, like, here's Wireshark. If you run it as a user, you know, it doesn't give you any prompt, it just runs. You can, you know, you can, like, listen remotely to, like, a Cisco remote pack capture. But with Wireshark, I want to listen to packets on interfaces on my machine. That's why I'm running the network snipper. Where's my local interfaces? Oh, well, then you need to run as root. But if you do that, you get a big, scary message that says, I'm not going to let you run code in Lua. It's okay, I hate Lua. It's not true, I actually think Lua is okay. You can embed it, therefore it's interesting. But, like, this is this really common thing where we have a security model that assumes that I've got, like, 20 people on my machine and I'm the only one who should be able to be root controlling them. Let me tell you, if I've got 20 people on my machine, I've got 20 people with root on my machine. I'm in trouble. So, Linux knows this is a problem. They kind of hide and fix. You have to, like, declare that it's an embedded machine because they don't want you to know it's there. And then you go into this, like, advanced mode and up, up, down, down, left, right, left, right, B, A, B, A, select, start. And, like, you end up with this checkbox that has multiple user groups and capability support. You know what that means? You uncheck that and all, like, the user root stuff goes away. You would think it's lovely, but man, all this code complains. So this, this is my solution. This is going to be sudo 2.0. I'm going to have, like, a key. I'm going to have a button. I'm going to have, like, three rocker switches. And then you know what I'm going to have? I'm going to have root now, and then, like, in my next prompt and in my next terminal window until I happen to, like, shut it down. And don't say it's less secure. This is way more work than typing sudo. Now, yes, I'm being silly. But so is this security model, and so is all this stuff we're doing with sudo. This is not reflecting reality. There is an implementation quirk. You can't just make all actions happen as root because software will complain like Wireshark complained. You have to do something weird and then bring it up without the code done because basically I'm recruiting. It's something I'm going to work on in the Blue Team Village after this. Come by and hang out. Effectively, what you need to do is allow action to happen as a non-root user, but mysteriously, all the permissions checks go through. It's okay, it's secure. Those rocker switches with the flips, there's an LED at the end. The LED makes it secure. Having kind of a faking root environment seems weird, but guess what? It's what we're doing with virtual machines. It's what we're doing with containers. Do you know why Docker is so popular? Because the app you get installed freaking works again. Katlin Linux, the first time you get an operating system that's totally designed by hackers, we're like, oh, screw that. That thing's a mess. Like, this is what's going on. Jupyter is probably... I don't know if you guys have ever used Jupyter. It is now how I tell people to start learning how to use code. It is a web-based interface for Python and data science. It is lovely. It's all the gunk of go ahead and start playing with code and turn it into logo from back in the day. It's great. But there's no way inside of Jupyter to add a package because that would require root. So you've got the most usable environment and it's missing actually some key functionality. And it's because of us. It's our fault. We need to stop breaking the rest of computing. Now there is a reason why things are this way. You know, you can't just say, like, why are people so stupid? Well, usually there's a reason. Usually when you give people who are just learning computing root access, the first thing they do is totally destroy their computer. This is true. And so we've evolved this model that will give you just a little bit of functionality. And we'll kind of have, like, a talent bar. You have to get this good before you get, like, real access to the system. It's not a security model as much as it is we don't want to get called in the middle of the night because the user's broke something again. Yes, you can do that and have a talent bar for users or you can make it just really easy to fix stuff. Check out this little stunt. So, I've been working on something called Inception. Forging the universe. I wanted to see, is it possible to take a fully configured, fully running machine that maybe a user doesn't want to break but does want to try something on and fork a copy? With the existing configuration, with everything in place. Now, I would love to do it with the present, you know, the exact moment of the flip. But here's how I got it working, just booting into the system that has already been configured. So here we are, we've got a stock little Ubuntu box. Couldn't really have live demos here. It's okay, there's no time for them anyway. I promised that I was going to show some code. Here's why you don't show code in the middle of a talk. But let me tell you what's happening here. There's a super obscure, elementary kernel module called DattoBD. It's the Datto block device. There are other ways to do this using the DMMapper functionality in Linux, but I'm using Datto because it's cool. Datto lets you basically say, I need to make a backup. And you know, when you backup a hard drive, it needs to be like a point in time. You can't have like, this file was what it was at the beginning of the backup, and this file was what it was at the end of the backup. Your system will not boot. You need to be able to take a snapshot. Datto is interesting because it allows you to snapshot a disk and not have some other disk required to store content as well, to store the changes. It's just a more stable variant. What we do in here is we take a snapshot of the running disk, and it's a read-only snapshot. You're not able to write to it. But virtual machines don't care. They can totally be like, read-only, that's fine. I'll get my reads from over here, I'll put any writes over there, so it's called a copy-on-write approach. So, I get myself a read-only copy of the disk, I make snapshots of my EFI partition, in this new thing, UEFI, it's a disaster. Terrible. We make a copy-on-write copy of the Datto environment, and then we boot a VM. And you know what happens? You just get that system. That exact system. And you're even rooted in it. You get to test whatever you want, you get to explore whatever you want, you can't break anything. It's lovely. It's rooted. Nothing bad can happen. Remember earlier I told you, you can context switch, or you can just have other computers. All this is about persistence, all this is about managing how much damage can happen where. I want to leave you guys on kind of a down note. I have a hard question. Why are we vulnerable to ransomware? Why is it a problem? Like, why is it possible for all of our data to be deleted all at once? Why is it possible for anyone even maliciously to wreck everything? Like, who is this a feature for? You might say, oh, you're going to run out of storage. Really? Like an 8 terabyte hard drive is like 50 US dollars. Like, your entire companies are not generating data fast enough. They could log every single bit 100 times over without exaggeration, and not spend nearly as much money as a single ransomware cleanup. What's going on is we have all of this leakage of capability to lose data. We have too many people able to break stuff. And as we look at the underlying capabilities of computers, realize we're not just as hackers able to break things. We're able to redefine them so they can't be broken in the first place. So let me leave you with some closing thoughts. We should not be separating development and testing. Guys, at the end of the day, computers are capable of magic, and we're just all trying to make the magic our magic, and not some bad guy's. Our hardest problems in security require a layment between how we build systems and how we verify them. And our best solutions in technology are going to require understanding the past, how we got here, how we really got here, even if it's from the 1890s. We're going to have to understand what is a unnecessary presumption, and what, oh no, we really shouldn't touch because we could screw this up. All that matters is how we protect users, and I look forward to seeing how everyone here makes the world better. Thank you.