Thanks everybody for coming. I appreciate it. Good turnout. This is good stuff. This is my second time talking at DEF CON and it was good turnout both years. I am Jacob West. I run security research at Fortify Software. And Matias is one of our researchers. I'll let him introduce himself in a second. I came to the security world because I worked on static analysis. So I worked on a static analysis tool at Berkeley for looking for security vulnerabilities in C and C++. And I got really excited when on our last project with that, we applied it to the entire Red Hat Linux distribution. So it was like over 100 million lines of code. It was the biggest static analysis exercise to date. And what it turned up was we could find a bunch of bugs. And bugs that were easy to report, easy to fix, easy to deal with for the most part. And so that got me really excited and I joined this company called Fortify and since then we've been building static and now some dynamic analysis tools to find security vulnerabilities. I got to write a book a few years ago called Secure Programming with Static Analysis with a college of mine, Brian Chess. That's a great reference for any programmers out there who want to understand how static analysis as a technology and software security can come together. And how static analysis, which is good for hammering all different kinds of nails, is particularly good at the software security problem. As I mentioned, my co-host today is Matias Mado. Matias, you want to introduce yourself? Yep. So I'm principal security researcher at Fortify Software and at Fortify Software I focus mainly on developing new techniques for finding vulnerabilities. This by doing static analysis on source code and dynamic analysis on running apps. Another project that I'm working on is developing new ways to protect web application firewalls. So we have some sort of a web application firewall that is inside the application so it's context sensitive so we can actually do a better job. Last year I contributed to the BSIM Europe project. I'm not sure if you're familiar with BSIM, but BSIM is a maturity model that is... I'm sorry to interrupt. I'm curious about this audience. Who's heard of BSIM? Oh. That's more than I expected. So BSIM, for the other people, BSIM is a maturity model that is based on real world data from leading software enterprises. So this model can help you actually shape and plan your software security initiative. And when I was a researcher at Ghent University I developed a code obfuscation and binary writing tool. So that's a little bit of my past. Alright, fantastic. So I'm going to get us started today with a little background on what we mean by the insider threat problem. What we mean by an insider, what kind of threat they might pose. Matthias is going to go through a series of examples and kind of a classification of the insider threats, the code level that we've identified and then I'll talk some about what tools people trying to protect against insiders have at their disposal, both in terms of process and technology. And then we'll conclude with the examples that Matthias already explained, lined up against the defense techniques and the technology that I'm going to talk about and showing you in the real world what we can actually accomplish today in terms of identifying insiders. So first off, last year 43%, more than 43% of organizations that responded to BSIM were responded to a CSI survey said that they attributed at least some of their losses to insiders. So people that were employed for their company ostensibly working towards the same goals as the company but exacted some damage deliberately. I like a definition that Bishop and Gates, Gates is from CA Labs and Matt Bishop of course is at UC Davis used to define the insider threat. So there are really two kinds of threats that we're worried about here when we talk about an insider, somebody inside the organization. One is they have some existing set of permissions, access to some resource, something of value, and they use that in an incorrect way. So they have permissions legitimately to read all the users from the database because they work in support. But when they take that information and send it to their buddy on the outside or use it to spam all the users, then they've used legitimate access for a nefarious goal, some illegitimate goal. The other class we're interested in are insiders who gain some access that they're not supposed to have. They're supposed to have a user login that would let them query their own account in LDAP. They hack into the system and gain access to an admin login that can update all the records in LDAP. That's gaining more access than they were intended to have. So you can take legitimate access and do illegitimate things, or you can gain ill-gotten access, illegitimate access, and do more than you're supposed to do. be able to do with it. Of course, insiders can fill all kinds of roles. So we hear a lot about IT people, we hear about people on the support team, we hear about all kinds of users who might be upset with the organization or want to do some damage. At Fortify and from our backgrounds, we're interested in software. We're software people. So in particular, we're going to talk about developers and what kind of an insider threat a developer with access to commit code to whatever your organization's codebase might be, what kind of damage they can do, and how we can identify the kinds of problems that they introduce. So what motivates a malicious insider? One of the most interesting stories I have from two or three years of working on this is a board of directors contacted our senior management and said, what can Fortify do to help with insider threats? And we said, the board of directors is asking about IT insider threat programmers. They don't know those people. What are they doing? Turned out they were getting ready. This was a big financial institution around 2008. And they were getting ready to lay off 6,000 programmers. They were really worried about one of those programmers that they were about to lay off leaving something behind, a time bomb, some sort of malicious logic to do some damage to the organization. So they had started pushing their internal security team, what are you going to do to protect us against this? What's your process and technology in place to avoid these insiders doing damage? And in this case, these two potential motives, revenge, this is the first and foremost, but also maybe monetary gain, right? If I'm going to screw the big guy, maybe I can do a little good for myself on the way out. These come up again and again. And these are the concerns both that drive and motivate the insiders and the concerns that organizations looking to stop insiders focus on. And what really motivate effort in this area like the work that we have done. So, we're looking for developers. We're looking for developers who might be trying to bring monetary gain for themselves or do some damage, get revenge against their company. The main crowbar, the main tool the developer has in contrast to an IT administrator or someone on the support team is code. They get to check in code. They get to control the software in some form or another. Now we'll talk about a lot of examples today and how just checking in code to do something really nasty, it's not quite as simple as just checking in code to do something really nasty. You've got some concerns like not getting caught in the way too. And how that functionality is actually going to execute as part of a greater system. But in the end what we're really looking for is bad code. And we don't necessarily mean code that is vulnerable. We'll see a lot of examples today where the malicious insider code has a perfectly legitimate use. Except that's not the way it's being used in the case that we're looking for. It's being used illegitimately. So, where do you find examples of this stuff? If you want to find the newest way to write a SQL injection vulnerability or the latest and greatest JSP tag crosshead scripting example, there's plenty of open source out there. You can find examples of these vulnerabilities very readily. If you can't find it there, then you can go talk to companies and you can say, okay, you've got crosshead scripting. We all know you've got crosshead scripting. Why don't you show us some of it and we can help you detect it and avoid it in the future. People don't want to talk about insider threats. If you've been bitten by an insider then it means you had some employee that you hired and paid a paycheck to every month and they tried to bring your company down or they tried to steal from you. It's one of the most embarrassing problems in the software security field. And for that reason, A, it doesn't crop up a lot in open source because who's the target? Who are you trying to get revenge against there exactly? And companies that are actually susceptible to these or have been bitten by these don't want to talk about them. They don't want to show you examples. They don't want to even admit that it's happened. So coming up with examples is a real challenge. There have been some notable examples in open source or public disclosures of closed source examples of this. We'll show some of those later today. Some of our customers have at least gotten close to showing us the real thing. They're like, well it looked kind of like this except we changed a few things around. So that at least gives us an idea. But one of the most useful sources of examples that we found was a contest run at Stanford in 2004 called the Obfuscated Voting Contest. And the goal there was to write an electronic voting system that contained malicious code. Basically an insider threat to miscount votes and skew the results of the election subtly towards one of the candidates. So in this case we had 40 or 50 strong programmers come in and try to circumvent a review. Try to keep auditors from finding their insider code from their time bombs or whatever it might be. And we found that this was a great example of the techniques that programmers are likely to use to try to avoid detection. So between these three sources we've come up with the examples that we'll talk about today. We have to acknowledge some related work here. This is a relatively new field but there are plenty of people that have made important contributions. Weisopel and Eng published a great paper about using static analysis on binaries to detect backdoors and other insider threats. Jeff Williams has done work in this area. Matt Bishop, who I mentioned earlier and various co-authors of his. He's approaching it very much from the we need an academic underpinning for all this. We need to define the terms and give formal definitions for what we mean by an insider and a threat in that context. And then finally at CMU there's a research group called Scilab that's doing work on the insider threat problem more broadly. And they've actually with a little coercion focused somewhat on developers and programmers. Code level insiders. So this is a particularly interesting one for us. So there's our background. I'm going to hand it over to Matthias to go through some examples and classifications of different sorts of threats that we're concerned about. And then we'll come back and look at some of the techniques we use to defend against them. Okay. So there are like numerous ways to classify insider threats. And to give you an idea, I'm going to go through a couple of examples and I will try to classify them. So I have three examples up here. First of all, it's the Medco case. So after a particular date and time it will delete over 70s all the files on 70 servers. So first of all, we can classify this as a very destructive insider threat. Another way to classify this is it's a very destructive insider threat. It's like of high risk of the company itself for the business. If this piece of code is executed, it will delete 70 servers which means downtime which means no business. So it's like of a high risk for the company itself. It's also trivial to write this piece of code. It's not complicated at all. So you can classify this as a very trivial way to implement. Depending on where this code lands in the application itself, it's like an auto-trigger. You do not have to manually poke it. A certain date arrives and it will execute. So a fourth category can be like it is an auto-trigger. The second one is from Linux. The functionality of the if statement should be like the following. Two flags for a particular command can only be executed when a person is root. So the options, you're going to compare the options again, clone and wall and you check if the user is root or zero. And then you can actually use the if case. Something is wrong over here. Can somebody tell me why my... Yeah, correct. It is not trivial to see but over here this is not a comparison. It's setting the value setting the user ID to zero not comparing the user ID to zero. And this is a little bit blended into the code. It's not like a separate statement that says hey we are making the user ID root. No, this is in the if statement itself. So this is definitely trying to hide from a from a manual auditor. Another way to classify this is this has to do with authorization. So only the root person can execute this particular command. Over here we have a problem so this can also land in another bucket which is authorization. The third one was a Borland Interbase case. So at Borland they had a software design problem and the way they fixed it they had a chicken and egg problem about authentication. And the way they fixed this was by inserting this line of code. So they hard coded checked if the user name was politically and the password was correct. So this works if the code is closed source. But of course when you open up the source to everybody if you make that source, if you make it open source everybody can spot this line of code and everybody can grant himself access to the code. So the way we can classify that one is in three ways. So we can classify it as an authentication modification. We can also classify this as hard coded sensitive data that's in your application should not be there. Hard coded username, hard coded password should not be in your application itself. And the third way to classify this is it's actually abnormal control flow path creation. So this normally should not be in your application so you're creating an additional control flow through your application that bypasses the authentication mechanism. Sorry. So the way we actually classify insider threats is based on characteristics to spot the insider threat. So later on in this presentation this classification will become clear so now it's a little bit odd to look at this. But during the face off I'm going to explain how we actually find these insider threats in your application and then it will become clear why we chose these classes of insider classification of insider threats. So what I'm going to do next is I will go through these classes and I'll give you some code examples. So I'm going to explain the class and I'm going to give you some code examples. So I will not show you how you can spot it in your code. That's for later on in this presentation. That's for during the face off. So first of all logic bomb and time bomb. I'm pretty sure that everybody is familiar with that. So it's a piece of malicious code that is dormant in your code until something triggers it. If that triggering mechanism is related to time then we call it a time bomb. There are like numerous public disclosures over here and it's mainly about comparing hard coded date and time against the current time. What we've seen so far is that if you're really destructive if you have a destructive piece of code you're using a time bomb to set it off. You choose like a date like your birthday or when you're a year laid off or something like that. One interesting case over here is the logic bomb. Hacker gets eight years for failed stock rigging. So UBS employee planted the logic bomb into the code and went short on the stock. So the logic bomb went off. It deleted files over a thousand of computers. He got caught. He was prosecuted. He was eight years in jail. And unfortunately for him the stock didn't even go down. So he was like completely screwed. What we actually figured out or what we found in code was not that it was really destructive. So what we found in code was that people used it for various reasons. For instance in the first case what we figured out with this logic bomb was that they tried to bypass control mechanism. I'm not going into detail of what they exactly did. But so there were like checks installed and after a particular date these checks were no longer valid. So you could easily bypass these checks. Another one that we found is instead of being truly malicious what you can do is update queries at random, change some data. And this is really hard to track it down. If you do not find this particular piece of code you're going to look into where you're updating your queries or whatever is related to the fact that your database is changing and you will not look at this piece of code. So this is really hard to spot or to track down if you do not find this inside the thread. Backdoors and secret credentials. This category is all about securing your future access to the machine. And you can achieve that in like numerous ways. What you can do is adding additional credentials. Adding a master password. Some code that allows some remote access to the machine. You're bypassing some authentication mechanism or even just a way to execute commands on the machine is enough to grant yourself access later on. A couple of examples over here. Well I've explained already the Borland Intercase Interbase example where you insert like a hard coded username and password. Another one to secure your way afterwards was the WordPress backdoor. So you can still execute commands on the server itself if you know the special parameter. So knowing the special parameter means you can execute whatever you want on the server. So later on you can grant yourself access. You can execute whatever you want on the server. The last one that we found in code was inserting some special credentials at startup. So if you're starting up your application, the first thing that's executed, well after a while the credentials database is created and they inserted a line of code that added an additional pair of credentials to that credentials database. So later on you could come back and use the username insider and the password thread to grant yourself access to that particular machine. And so backdoors and secret credentials are not like limited to these normal applications. All applications can be backdoored. For instance, Optics Pro is actually a backdoor program containing a backdoor because it was like a master password to grant yourself access. Sub7 is a trojan with the backdoor. So it's not limited to normal applications. Nefarious communications so nefarious communication is about a fixed communication channel to transfer data outside of the organization. So we cannot execute whatever you want on the server, but it contains some code in it and we can poke it and trigger it or it connects back to us and it gives us some data. So it's an excellent way to transfer sensitive data out of the organization. So a couple of examples over here. So you can do that for instance by the server opening a socket or opening a network connection to our machine and transferring data to us or you can actually the server containing some mailing application that mails once in a while some secret information to us. And the way you can the way that code becomes active is sometimes it's time based. So on a certain date or on a regular basis it sends over some information or you can actually monitor the database some confidential database and if that database is updated it's going to transfer the whole database to our server. Or you can actually poke it. If you know how to poke it it gives you back the information. A couple of examples over here. So this is about making a server sorry, making a socket creating a new socket and they were actually monitoring one specific file. I've changed it to confidential file so they were monitoring one specific file and if that file changed it opened it created a new socket on port 666 and it transferred the whole file out of the organization. This is a very similar one. It's pretty much the same but instead of opening a socket over here it's post to to a website. So to an evil website. Again you can monitor the file and transfer it out or you can manually poke it. The email, so the Blackberry email spying case. So in a particular country this update was advertised as a performance update. When you actually decompiled the performance update you found the following piece of code. So it contains like some forwarding mechanism that for each mail you receive on your Blackberry it was also forwarded to that particular address. That was actually deliberately into the code and it was there to comply with regulations. So work of Jeff Williams, well sorry dynamic code injection and manipulation this category is all about changing, adding, compiling code on the fly. So you have some source code in your application and you compile it on the fly and execute it. We got inspired by Jeff Williams work on this particular category. So he enumerates like a lot of categories. Like abuse of reflection where you rewrite read only variables, resource rewriting, compilation on the fly, abusing class loaders. Pretty neat stuff. One example over here comes out of his work, out of Jeff Williams work. It's the abuse of reflection. So what you're actually doing over here so you have some final strings in your application. You're not able to modify it. You're not able to change the data of these final strings. What you're doing is you change the string class. So you change the string class in such a way that all final strings become writable. So it doesn't matter anymore if there's final with the string. You can actually rewrite all the final strings. Obfuscation and camouflage. Over here you're trying to hide from different actors. For instance you can try to hide from auditors. These days we see that people try to hide from tools too. But at the beginning it was mainly about hiding from people looking at the code doing manual analysis on the code. And the way they do it is they make really subtle changes that by doing that they achieve their goal. But it's really hard to spot. I went through the first one that didn't check if it was root but it was actually setting the root. Another one is the X11 case. So the forgotten parenthesis. There are like two checks over here. The get UID and the get EUID. So the effective user ID. With the second one as you can see they forgot the parenthesis. So this will make the statement always true which means that it can use whatever module you want. And normally that was exclusively for the root. But now over here because of the forgotten parenthesis everybody can add a module. And it's just a mix up of names. So if you have like a variable with the same name you can do this stuff. Another one over here is assuming you want to hide the following piece of code. So you want to hide that you want to remove everything in the root directory. So you want to rip out everything on a particular machine. But this statement is obvious to spot for a manual auditor. The way you can achieve that is you're going to encode it with base 64 for instance. You're going to encode it. You're going to decode it on the fly and you're going to execute it. The good part over here is these three lines of code do not have to be in sequential order. You can spread them out over your application where it makes more sense to put that piece of code. So once you come to the execution of the string you have no idea what's actually executed. It's not obvious. So you have to track back and try to figure out what's actually executed over here. So that's like a neat way to hide. Another way to hide from a manual inspector is using very simple substitution ciphers like for instance rod13 foursquare, bfit and so on and so on. Over here what they did is they wanted to insert something in a particular database but they wanted to hide what kind of database they were inserting to and they also wanted to hide what kind of values they were inserting to that database. So what they did up front was they declared a couple of variables, the database, the data and data2. They didn't give any specific names and they encoded it with rod13. Rod13 is really useful because it only requires like six lines of code to implement. So if it's not by default in your application you only need six lines of code and you have it over there. So what this was actually doing was inserting into the credentials database insider and thread but it was a little bit hidden from, so I've shown that example before where it was just like you inserted in the credentials database over here it's much more harder to track down by use of a, for a manual auditor. So I've introduced like a little bit the classes of insider threads and a couple of examples. Jacob is going to tell how, what kind of techniques you can use to spot these malicious code. Thanks Matthias. So I'm going to talk about a couple of techniques. First and foremost maybe most popular, peer review. Manual code review. You're reading through code that somebody else in your organization wrote. Static analysis is when it comes to security vulnerabilities a great way to expand on and expedite the code review process. So we're going to talk about how static analysis can apply to finding insider threats. A couple of slides on run time techniques for tracking these down and then a little bit about how to interpret the results. It takes a little bit of a different mindset when you're looking for an insider as opposed to an accidentally introduced vulnerability. So first off if you're doing a code review and you see those lines up at the top you're going to ask what on earth is that? Why is that in the code? That would look strange no matter what codebase it was in. Maybe it's a crypto key or something interesting but whatever it is there aren't many of them. The second line is a little suspicious but there isn't anything completely out of the place there. You're checking a request parameter and then you're doing something based on the request parameter. That happens in a lot of codebases. Usually not with a hard coded name and a very specific case like this but that one might slip by. If you came back after lunch and you were reading through code and you saw that one you might let it go. What about the last one? Somebody over on this side of the room I think tracked down the problem with the last line of code there when we put one line of code on the screen and asked what's wrong with it. If that was one of a thousand or ten thousand lines of code that you've read this day or week you're much less likely to see it. So the ability to track these things down with manual code review is relatively low. And we've seen this with the success of insiders writing code like this that is laying dormant in codebases that have been reviewed year after year because it's not a smoking gun. It's a breadcrumb. It kind of points towards maybe a possible problem something a little bit fishy but again it's nothing egregious in and of itself. So those are really the two challenges with using manual review for insider threats. One is your reviewer has to know what you're looking for. What he's looking for, what she's looking for. So they need to have a lot of domain expertise in terms of the kinds of techniques that insiders are going to use to do some sort of damage. So A, your reviewer has to be pretty well trained. They've got to be thinking about this problem specifically. Two, where do you look? Some vulnerabilities, it's easy. I'm going to look where important stuff is happening. The database queries that access the table with money in it, I'm going to go code review those, make sure there's no SQL injection. The pages that deal with authentication or other sensitive activity, I'm going to check to make sure XSS and CSR aren't a problem. Insider threat code could be anywhere. A lot of it isn't terribly interesting. A lot of it is, as Matias showed on the slide before, hiding the thing that you want to use, decoding the thing that you want to use, and then eventually maybe using it. Only the place where you use it would get any sort of security attention because the other two can live in any arbitrary place, some dark corner of the code base. Static analysis can help find insider threats in code two ways. One, it can represent all of that domain expertise. What are all the kinds of ways insiders might attack a code base in a set of rules? Granted, those rules aren't the same as the rules we use to find normal vulnerabilities, but they can be codified and used systematically. The static analysis tool can apply those time and time again. The reviewer doesn't need to keep them all in their head. Second, they can tie those breadcrumbs together. I said a lot of these techniques that insiders are going to use aren't necessarily malicious. There's a malicious use for them, and then there are lots of legitimate uses too. Static analysis can start to look at an entire code base as opposed to however much of it we can cover with manual review, 1%, 3% maybe. It can look at an entire code base and can track down all these breadcrumbs. It can start to show you a heat map of the application. It can start to show you where is there a particularly thick line of breadcrumbs. Where do things start to look like there's this suspicious thing and that suspicious thing, and there are three of them there. That really warrants some further review. They're not going to find smoking guns, and we'll look at examples of that, because these things aren't smoking guns. They're, again, perfectly legitimate ways to do all the things that an insider would want to do. They're just doing it in an illegitimate way. Just to give you a little idea of what the inside of a static analysis tool looks like, the piece we're talking about is just one aspect of the tool overall. Source code comes in the front end. You build a model from that source code. You run some various kinds of analysis on it, and out the other end come results. The piece that we're talking about changing are the rules. These are the definitions that tell the analyzer what to look for, what constitutes a problem. Here, it's very different from vulnerability detection. Vulnerability detection is useful, too. Sometimes an insider leverages something that is technically just vulnerable. This is an example that Matthias talked a little bit about earlier, except he just had the first line of code. The first line of code says, this is PHP code, I'm going to check a request parameter, and if it exists, called IZ, then I'm going to call this get theme m command function. What the hell does get theme m command? I guess it's going to load a theme. If I was doing a manual review and I wasn't looking too carefully at this, I might just read right past it. The definition of get theme m command is to execute pass-through, which just executes a shell command or a script. This is a command injection vulnerability. Any static analysis tool worth its price would find this out of the box, because you're taking a request parameter, IZ, and passing it to execute as a shell command. That's just a bad idea, no matter why you're doing it. It doesn't matter that you've got that conditional over to the left that says only do it sometimes. It's always a bad deal. Out of the box rules would find this problem. Some other problems aren't as obvious. They aren't vulnerabilities in and of themselves. Let's talk about a scenario that Matias already showed us code for. A laid off employee installs code that reads the entire database on a regular basis and sends the results over the network. There's a couple of bad things going on there. I'm going to talk about them one by one and then show you from a detection standpoint how we might go about identifying this broader insider threat. First off, if you're reading the entire database and entire table for any reason, it's pretty suspicious. If you're doing migration, that's a possible legitimate use for it. But you probably are looking at more than just one table at a time, too. So if you have a query in your code base that does a select star on a single table, that is in and of itself suspicious. It's not a vulnerability all by itself. It's not a command injection like the slide we looked at last. But it's pretty weird and if you're a manual reviewer looking for insider threats, this is a good place to start. This is a bread crumb in a pile. Second off, you're reading something from the database and we'll assume you're in a web app here because a lot of people looking for these things are in web apps. It's your banking site. It's your e-commerce site. These are where insiders tend to target. You're doing manual network connection management. You're opening sockets, particularly sockets with hard-coded ports. Again, perfectly legitimate reasons to do that, but it's pretty uncommon. Not something you'd regularly see in a web application. So we can create another rule that flags uses of sockets in web applications. And in particular, hard-coded socket numbers, just really strange. You're building in some special sauce there, whether it's for legitimate purposes or malicious purposes remains to be seen. Alright. A regular basis. Most applications don't depend on fixed points in time. That's not to say there aren't legitimate reasons why they might, but if you're checking the current time, that's a breadcrumb. That's something interesting. You're not going to do that a million places in your code base. So a manual reviewer looking for insider threats could afford to look at all the places where you read the current time and check on what you do with it. In particular, an interesting thing you might do with it is compare it against some hard-coded value. So if you access the current time, that's a little suspicious. If you access the current time and then compare it to a static string, compile time string in your application, that's really bizarre. There are very few legitimate reasons for that. So again, the pile of breadcrumbs gets a little thicker. I guess that's the last breadcrumb. This is a lot of what goes into the detection techniques that Matisse is going to show examples of later. I'll talk about this a little more when we talk about interpreting results, but again, you don't get to find a single smoking gun. You're looking for things that indicate something suspicious. The more suspicious things you find and the more suspicious each of them is, the more likely you are to have an insider threat. The goal for most organizations would be to run this rule pack against their code base and not find anything. That wouldn't be terribly surprising. You might just not find anything. Or you might find a few of these that are being used legitimately. Or you might find a few more and see, hey, this spot on the heat map is looking a little red. This is actually a problem. Okay. So aside from static analysis, how might you track down insider threats? Your existing functional testing in QA can be pretty useful here. Here, for the most part, you're looking for code that isn't run very often. And probably during a functional test, it's code that's going to look dead, in fact. If you have a mechanism for overlaying what's potentially security relevant, so talking to the database, talking to a directory server, printing content out to the web, executing shell commands, there are a handful of things that are security sensitive. If you can overlay your ability to detect dead code during functional testing with things that might be security sensitive, you find people opening sockets in dead code, that's a good thing to get rid of either way. At the very least, it's dead code that might introduce a bug or cause some problem later on. But it's also quite possible that it's behind one of these logic bombs or hard-coded credentials, time bombs, something that's meant to not execute on a regular basis. In production, runtime monitoring can do you some good, too. Because, now this is a little late in the game, but if you suddenly see a bunch of data being written out from your web app that isn't typically, or a bunch of traffic on your admin console that isn't typically there, there are things at runtime that suggest something is out of the normal here. And this comes down to, for the most part, anomaly detection, looking for common behavior and looking for things that deviate. So, watching your application both in QA and in production can help track these things down. We're particularly partial to the static analysis approach because that's where we put a lot of our energy, but belt and suspenders does apply here, too. Okay. So, now you have a really big pile of breadcrumbs. None of them are smoking guns. Let's talk about this code for a second. So, you get the current time. That's nasty. You compare the current time against some hard-coded string. That's nasty, too. This might legitimately be update code. You might say, we're a startup and once a month we just want to check to make sure there aren't some new bits that we should download. And this was a hacky way to, kludgy way to introduce that. It's possible. You might be able to talk your way around it, but it might also be nasty. And the fact that we see the two breadcrumbs that we latched onto before, right? Accessing the current time and doing a comparison based on it give us a little more confidence. So, in the end, what we can really do with these results is we can associate a strength with them or a priority with them. Just like we would other vulnerabilities that we detected in an automated fashion. So, some problems like accessing the current time might only give us a low fidelity feed that it's an insider threat. There might be lots of reasons you access the current time. But if you compare that with a hard-coded time, that's pretty strange. Maybe that goes at the high end of the bucket. So, each one of these breadcrumbs has a strength of implication. How likely is it to describe a real vulnerability? And one of the most exciting things you can do with static analysis is combine these. So you have a low, a low, a medium, and they're all in the same method. Okay, that method definitely warrants manual review. But it's important to see that eventually this does come back to a manual review process. You need a smart person who understands what an insider might go after and how they might do it. And that person needs to take the code base as one input and the feedback from the analysis tools as another input and maybe some run time monitoring as another input and combine all these things to start looking for the real problems. Of course, if you've been doing this by hand, this is going to sound great because now you've got more inputs. It used to just be the code, right? Figure it out. Now you've got other things to help start to develop that heat map. If, however, you weren't doing it before, if you weren't looking for insider threats and somebody says, yeah, now you've got all these inputs and it's up to you to interpret them, it's going to sound like a hard problem. So a piece of this all boils back down into what's the motivation and what's the organization actually after finding. Are they interested in finding these things? If so, this is going to sound like a good story. Okay, so I talked a little bit about how you might find these things. Matthias talked about what these things are, classes of insider threats. Now we're going to line the two up and talk a little bit about how latching on to some of these specific attributes at analysis time, we can point out problems at varying degrees of priority. The face-off. So what have we done? So where are we today? We have 17 insider threat categories and we've implemented them all for Java. Ten minutes. We found multiple real issues in enterprise code, so we have confirmed issues that we found in enterprise code. So the way I'm going to do this is I'm going to rerun the examples and I'm going to describe what we flag. So just to have all the we have like 17 categories, they are listed here, they are in the slides so you can if you want to talk about them afterwards feel free to do so. So all these categories are like sub-categories to these main classes of insider threats. So I will tell you what we flag in the code, what we flag and how that relates to the code that we've shown before. So first thing first. Logic bomb and logic and time bomb. So what we flag is in a low priority if you get the current time it goes into the low priority bucket. If you get the current time and you compare it against you get the current time and you compare it it goes in the medium priority bucket. If you get the current time you compare it and you compare it to a hardcoded date, then we drop it in the high priority bucket. So obviously this was found in the high priority bucket so it's ticked out, we found it immediately. Backdoors and secret credentials. The way we flag stuff goes as follows. We flag insertions in the database. If you insert something in the credential database it's a low issue because there are good reasons to insert new credentials in the database. If you insert something in the credential database and it's a hardcoded credential well that's pretty suspicion and that's at least a medium issue. If you insert in the credential database a hardcoded credential and you do that at startup which means that these credentials will always be there and you can always use them, well then it's definitely a high issue. And that's a perfect way to secure yourself access to the machine. What else do we report in this category? We report comparing hardcoded usernames and hardcoded passwords. All the comparisons of the username with the hardcoded username and or the password with the hardcoded password, we flag that as a high priority because that's most likely a threat. How do we tell what a username is? Okay, so we have a couple of username and password if the variable is username and password it's obvious but not in all applications it's username and password. So you can also customize your, we have some custom rules available for your application that you can simply use your variables and we will automatically trigger them. Default command injection in WordPress, so for some cases we do not need any special rules. So the command injection it will be found by regular static analysis. If you really want to have this in your insider threat code base, what you can do is you can take the command injection rules and port them over to the insider threat rule pack and we will flag that as a backdoor and secret credential. Nefarious communication, we flag hardcoded ports and sockets. So if you use a socket and it's a, if you create a new socket with a hardcoded port, we flag that as a high issue. What we also flag in general is server sockets. Most of our customer base they are not using any server sockets, so if you do, we flag that as a medium issue. We also flag accessing hardcoded files. So we have a couple of default rules if you try to access ETC password or whatever file you do not want to expose, we are going to flag that. We also have custom rules, so if you know of some files that are really confidential to your organization, you can set them and we can track that. Hardcoded email addresses, so every hardcoded email address is flagged in your application. There are again legitimate usages when you want to contact the administrator or whatever, that's a legit usage, but in normal cases it's legit. We can also flag mailing APIs for instance. We flag functions that change the read-only flag, so for instance the set accessible on a field class, we're going to flag that because you shouldn't use that in your application. We have similar rules for all the categories that are described in Jeff Williams' paper, but we broadened our view and we thought about more examples and how people do stuff, so we have rules for all these things. Obfuscation and camouflage, we flag the usage of a single equals inside an if statement. You should not use a single equals in an if statement, so we flag that in the obfuscation and camouflage. We also flag when you're having the same name for a variable as a common function. If you're doing that, we will flag that in the obfuscation and camouflage. And then the really useful one is if you're trying to decode hard-coded strings, we're going to flag that as an obfuscation and camouflage. That turned out to be a really useful one. We found a lot of issues with this kind of rule. If you decode a hard-coded string, it's very suspicious. It's implicitly saying, like, hey, I'm hiding something. So you do not want to have that in your code. So I hope that makes sense. And for the conclusion, I want to hand off to Jacob again. Thanks again, Matthias. All right, we're almost done, guys. First, and particularly for the DEF CON crowd, how do you avoid getting caught? So companies are going to start using technology like this to find insider threats. How do you avoid detection? What's the technique for not getting caught? First off, and one that we've seen used again and again, is make the code look as legitimate as possible. Make it look like real code and make it look like code that fits with its surroundings. If you have a five-line encrypted string hard-coded at the top of your class definition, it's going to stand out no matter who's looking at it, even if it's just a cursory review to make some other edit. So make it look real. Also, if you can make it benign, meaning it doesn't show up as a pure vulnerability, like that command injection that I talked about in WordPress, that's better. The more it looks like application logic, as opposed to a vulnerability, the less likely it is to turn up for people who aren't really looking for insider threats. It's good to understand who you're up against. So understand what organizations and security teams are looking for, and understand what tools they're using to look for those problems. If you can get access to one of those tools, if you can run, for example, the static analysis tool against your code again and again, you can tweak little attributes of it until it doesn't show up. And this is, of course, a real concern for the defender. But finally, there's a lot more attention on this problem today. So one way not to get caught would be to just not do it in the first place. I think getting a job on the support team and avoiding the source code altogether would probably be an easier route to wreak some insider damage. So for the good guys, what does this all boil down to? It's really like looking for a needle in a haystack. So you're looking for a huge variety of different tools and attackers that people might use. It's hard to think with this big number three in front of my eyes, sorry. The attackers have a big arsenal of tools at their disposal because they've got the entire programming language or multiple programming languages. If you think of a multi-tier application, they might do some damage in JSP or Java or PLSQL or a native C procedure that no one's ever going to look at. So they have a lot of tools at their disposal. And what we've seen for the most part has been they put a lot of planning into this. They think about the code for a long time. They've got it in place a year before they get laid off. It's not a spur of the moment. Oh man, I hate my pointy-headed boss. I'm going to go code up something really nasty. They put a lot of effort into these. So they've got a lot of variety available to them and they have a really large window of attack. Much bigger than the period between when the board decides to lay people off and they actually do. Technology can help a lot here. I hope with some of the examples that we showed today, you guys see that static analysis, although is never going to point out smoking guns, is a big help over manual review. And can really reduce a multi-million line application into a heat map of areas that a code review can do more value in by focusing on those hot spots. And it's really key that going into it you don't just rely on technology but that you have your auditors and the people looking for problems apply the right mindset. The things coming out of the static or runtime analysis aren't smoking guns. They aren't vulnerabilities. They're breadcrumbs. They're indicators of a potential problem. And until you get a thick enough pile of breadcrumbs you're not guaranteed of finding a problem. Thanks very much. I know software is not the usual DEF CON topic but I appreciate you humoring us and thanks a lot for coming out today. We'll be happy to take any questions after the fact.