00:00:00.000 --> 00:00:05.405 Thank you all for coming. So shall we begin? Of course a 00:00:05.405 --> 00:00:09.676 legal disclaimer. Use words and representation and not my 00:00:09.676 --> 00:00:13.914 previous current or future employer saying I have creative 00:00:13.914 --> 00:00:16.817 ideas and that should not reflect upon others and other 00:00:16.817 --> 00:00:21.455 ideals. Once again you guys are Awesome, scooching down and 00:00:21.455 --> 00:00:25.225 making room for everyone here. Thank you. I have this personal 00:00:25.225 --> 00:00:28.829 rule for myself where there are more than 10 people who show up, 00:00:28.829 --> 00:00:32.833 I am ecstatic. So I am overly ecstatic and joyful and I'm 00:00:32.833 --> 00:00:37.704 going to celebrate after this talk. So what we're covering 00:00:37.704 --> 00:00:43.677 today is Backdooring Git. We'll talk to how to backdoor it. How 00:00:43.677 --> 00:00:48.916 to prevent backdoor for the white hats, black hats. Here are 00:00:48.916 --> 00:00:53.220 a few techniques that did work or did not work based on the 00:00:53.220 --> 00:00:58.325 perspective. We're not going to cover the entire SDLC or how to 00:00:58.325 --> 00:01:02.696 distribute and create beautiful eloquent code with integrity and 00:01:02.696 --> 00:01:06.800 security. I don't care how you guys publish it or build it into 00:01:06.800 --> 00:01:12.606 your chains of integrity. Nah...it's more of how does this 00:01:12.606 --> 00:01:16.977 code get into the repository and how does it leave it. I'm not 00:01:16.977 --> 00:01:21.915 going to be talking about the myriad of source managements 00:01:21.915 --> 00:01:25.719 tools that are out there, I.E., SM and they're still out thereto 00:01:25.719 --> 00:01:28.088 from the dawn of computeers to new tools to scratch a 00:01:28.088 --> 00:01:34.094 developer's itch. Some proprietary certainly and many 00:01:37.097 --> 00:01:42.235 open source. Another thing we should clarify in the beginning 00:01:42.235 --> 00:01:46.139 is what a backdoor versus functionality. So for instance 00:01:46.139 --> 00:01:49.843 here we have an open DSD political ship storm that 00:01:49.843 --> 00:01:53.947 happened a long time ago where this person alleges, you know, 00:01:53.947 --> 00:01:59.319 hey my NDA with the F.B.I. came up. I just wanted to let you 00:01:59.319 --> 00:02:02.122 know the F.B.I. and other entities paid for us to 00:02:02.122 --> 00:02:06.593 introduce backdoors into some functionality for site-to-site 00:02:06.593 --> 00:02:13.000 and this was an allocation. By the way you should check these 00:02:13.000 --> 00:02:16.903 entities who committed all these changes and verified that they 00:02:16.903 --> 00:02:20.140 didn't introduce anything. So some people might view this as a 00:02:20.140 --> 00:02:23.210 bookdoor. Others might view it as where it says implemented or 00:02:23.210 --> 00:02:27.280 functionality. So I'm not going to get into that debate. Let's 00:02:27.280 --> 00:02:31.418 just all agree back doors are evil. People can still write 00:02:31.418 --> 00:02:37.591 horrible, ugly error-prone code and that's not good either. Now, 00:02:37.591 --> 00:02:40.460 hopefully there are none of us in the audience here who think, 00:02:40.460 --> 00:02:42.963 yeah, I don't need source code management. Just me, myself, 00:02:42.963 --> 00:02:46.033 some DIFs, pass around to friends. That's the case. This 00:02:46.033 --> 00:02:48.602 talk is probably not for you. In fact, you'll probably get pretty 00:02:48.602 --> 00:02:54.341 bored. But kind of set the stage, let's start at the 00:02:54.341 --> 00:02:59.046 beginning. Unfortunately I'm not going to be able to help you 00:02:59.046 --> 00:03:05.852 pick which SEM tool you should use, maybe Tom Cruise might be 00:03:05.852 --> 00:03:13.427 able to tell you but I'm not going to tell you which one is 00:03:13.427 --> 00:03:15.429 done better. I'm not going to harp and allow those...but there 00:03:15.429 --> 00:03:17.631 certainly is something called revision control. There's 00:03:17.631 --> 00:03:24.304 something called source code change management and they are 00:03:24.304 --> 00:03:27.007 very different from each other. You want to think so like 00:03:27.007 --> 00:03:30.077 imagine if you were to have a large amount of documents and 00:03:30.077 --> 00:03:33.447 you wanted to say hey I have a new pin test report to implement 00:03:33.447 --> 00:03:38.552 the version and use Git or some source control software, it will 00:03:38.552 --> 00:03:41.088 break horribly or vice versa you will go through a lot of pain 00:03:41.088 --> 00:03:44.091 and suffering. Or if you want to use binary files, a lot of the 00:03:44.091 --> 00:03:47.194 algorithms and techniques, they don't appreciate these tools. 00:03:47.194 --> 00:03:52.766 Imaging or anything like that or movies or ex{TRAEPL}ly large 00:03:52.766 --> 00:03:58.872 object -- extremely large ons, they'll just choke and die. As I 00:03:58.872 --> 00:04:02.809 like to say to myself, with {TKWOERP}s pick up a hammer, you 00:04:02.809 --> 00:04:05.879 know, everything is a nail. Well, here we see Jeremy 00:04:05.879 --> 00:04:09.783 Clarkson with that same mentality of hey I have this 00:04:09.783 --> 00:04:14.654 cool, nifty little tool that demines fields, let me use it to 00:04:14.654 --> 00:04:18.792 take down a house. Not only for inter{TAEUB}ment, but, you know, 00:04:18.792 --> 00:04:24.798 that looks like a nail. (videotape) >> Special fun 00:05:01.234 --> 00:05:04.137 little feature called the remote which later on he goes in there 00:05:04.137 --> 00:05:10.710 and hilarity ensues but the proper method for taking down a 00:05:10.710 --> 00:05:15.949 house might be explosives such as what we see here. So once 00:05:15.949 --> 00:05:19.386 again really find the tool in the SEM that really works for 00:05:19.386 --> 00:05:22.422 your work flows and processes and think about it you have two 00:05:22.422 --> 00:05:27.594 fundamental gaps. You either have the traditional model where 00:05:27.594 --> 00:05:30.330 there's...everyone interacts with and not with each other. 00:05:30.330 --> 00:05:33.700 And you have more of the distributive model where 00:05:33.700 --> 00:05:35.835 everyone can interact with each other and there is no 00:05:35.835 --> 00:05:42.542 authoritative source between each other. And we look over the 00:05:42.542 --> 00:05:47.247 history of SCM tools say Google trends, tell me what's popular, 00:05:47.247 --> 00:05:52.118 what's not, what we see is Git since 2007 just rising far and 00:05:52.118 --> 00:05:58.825 above and beyond and SCM peaks just kinds of dribbles down and 00:05:58.825 --> 00:06:04.464 sort of stays low and it just dies slowly. But it's 00:06:04.464 --> 00:06:07.868 interesting because Git seems to be the hot, cool new thing. I 00:06:07.868 --> 00:06:12.873 hear about it all the time. What about Git and since we're here 00:06:12.873 --> 00:06:16.943 to talk about Git, let me transition into there. So the 00:06:16.943 --> 00:06:21.581 problem that I had from the very get-go is what is Git? Well, it 00:06:21.581 --> 00:06:26.319 came down to two fundamental moods. If you're happy with Git, 00:06:26.319 --> 00:06:30.323 it's called the global information tracker. But Git 00:06:30.323 --> 00:06:33.793 does break or the processes may break or may just destroy your 00:06:33.793 --> 00:06:37.063 tree and in case that happens you think it's a truckload of 00:06:37.063 --> 00:06:43.069 Shit. And I mean people are ignoring the security 00:06:43.069 --> 00:06:46.806 consequences, think about the functionality, hey, you can't 00:06:46.806 --> 00:06:50.243 use your rePoe. All of your magic cancer cure, the recipe 00:06:50.243 --> 00:06:55.482 that's in there. It's broken, you can't access it. So imagine, 00:06:55.482 --> 00:07:00.854 it's very popular internet about I, think about how Hitler feels 00:07:00.854 --> 00:07:04.958 when Git breaks on him. (videotape) ( LAUGHTER ) >> So 00:07:04.958 --> 00:07:10.964 imagine if you're that... ( LAUGHTER ) >> So imagine if 00:07:19.973 --> 00:07:25.011 you're that mad, it's functionally broken, wait until 00:07:25.011 --> 00:07:28.615 someone hatch your repository or is able to introduce 00:07:28.615 --> 00:07:34.621 unauthorized code. I don't want to imagine how people would 00:09:42.382 --> 00:09:48.388 react to that. So the interesting part about Git, it's 00:10:52.385 --> 00:10:55.788 not your traditional system. It's very distributed in nature. 00:10:55.788 --> 00:10:59.058 People can work with each other. You don't have to continue to 00:10:59.058 --> 00:11:02.128 have access to the source of truth. I can work with say Chang 00:11:02.128 --> 00:11:08.134 Ki and Chang Ki can work with Aliceson Bob and it's a very 00:11:11.471 --> 00:11:16.843 powerful technology that allows processes can be warped around 00:11:16.843 --> 00:11:21.414 it instead of always have access to say the main repository and 00:11:21.414 --> 00:11:24.617 oh, I can't do any work unless I'm online it's a pretty nifty 00:11:24.617 --> 00:11:27.387 thing but the interesting thing about the distributive nature is 00:11:27.387 --> 00:11:33.192 that there is this ring of trust where now you're forced to trust 00:11:33.192 --> 00:11:36.329 someone and the decisions that they will make. Not the 00:11:36.329 --> 00:11:38.698 decisions of the people that they trust will make and 00:11:38.698 --> 00:11:43.336 transitly goes down but the interesting part of it to quote, 00:11:43.336 --> 00:11:48.241 if you have ever done any security work and it does not 00:11:48.241 --> 00:11:53.046 involve the concept of network of trust, it was not security 00:11:53.046 --> 00:11:57.116 work. It was Shit. I don't know what you were doing. But trust 00:11:57.116 --> 00:12:01.454 me, it is the only way you can do security. It's the only way 00:12:01.454 --> 00:12:06.159 you can do development. This is only one perspective, but it's a 00:12:06.159 --> 00:12:10.430 rather influential perspective. So can anyone here tell me who 00:12:10.430 --> 00:12:14.934 said this? And to help entice you guys, here is a party invite 00:12:14.934 --> 00:12:22.442 badge for the D.C. 503 party. Who said that back there? Come 00:12:22.442 --> 00:12:28.781 on down. Yeah, so Lenis Torvalt said that. He has some pretty 00:12:28.781 --> 00:12:35.021 choice quotes, how do I say, blunt. Because the interesting 00:12:35.021 --> 00:12:39.225 part is you fundamentally end up with this graph of trust where 00:12:39.225 --> 00:12:42.228 you're at the center of it and then you have all these people 00:12:42.228 --> 00:12:45.598 trust each other. Some people trust others. You end up with 00:12:45.598 --> 00:12:49.335 this ugly graph so you end up seeing this code from someone 00:12:49.335 --> 00:12:53.306 and you're like what? Where did this come in? Like I don't get 00:12:53.306 --> 00:12:56.676 it, should I trust them? And we'll get into a little bit of 00:12:56.676 --> 00:12:59.679 that later. Very important to understand this because you end 00:12:59.679 --> 00:13:03.683 up with another interesting choice quote where since you 00:13:03.683 --> 00:13:07.153 don't want everybody to write to the central repository, because 00:13:07.153 --> 00:13:11.524 most people are morons, you create a class of people who are 00:13:11.524 --> 00:13:15.862 ostensibly not morons and most of the time when that happens is 00:13:15.862 --> 00:13:18.798 that you unfortunately make these nonmoronic people too 00:13:18.798 --> 00:13:21.968 small because it's really hard to know if a person is smarter 00:13:21.968 --> 00:13:24.937 or not and even if you make it too small, you will have 00:13:24.937 --> 00:13:29.709 problems. Admit access issues of who is allowed to push to the 00:13:29.709 --> 00:13:32.311 source of truth or who has authority at any one time. Go 00:13:32.311 --> 00:13:35.548 ahead and ignore it, separation of privileges, things like that 00:13:35.548 --> 00:13:39.385 just give everyone commit access. It's a huge 00:13:39.385 --> 00:13:43.656 psychological barrier where no one trusts me or also cause 00:13:43.656 --> 00:13:47.226 endless hours of politics and especially in the open source 00:13:47.226 --> 00:13:50.997 community. So can anyone, once again, tell me who said this for 00:13:50.997 --> 00:13:56.469 yet another -- yes. Correct. Lenis Torbolt. One of the 00:13:56.469 --> 00:14:03.276 thought leaders behind Git itself and some interesting 00:14:03.276 --> 00:14:06.779 design decisions within Git, we'll see which benefits 00:14:06.779 --> 00:14:10.783 security as well and the morons and the -- the interesting part 00:14:10.783 --> 00:14:16.789 is when you end up typically using Git repository in a more 00:14:18.991 --> 00:14:22.028 mature fashion you'll end up with this blessed source of 00:14:22.028 --> 00:14:26.566 truth that everyone can pull from, developers, and others but 00:14:26.566 --> 00:14:31.170 they're only able to push to their Dev leads or whoever else 00:14:31.170 --> 00:14:34.707 will go through checks and balances code reviews, they'll 00:14:34.707 --> 00:14:37.744 just quick look at a code review two seconds and then might push 00:14:37.744 --> 00:14:40.413 it to the dictator or some other higher authoritative source 00:14:40.413 --> 00:14:46.586 where yes, everything looks fine or push it back into main line. 00:14:46.586 --> 00:14:52.592 So go ahead, dictator, they have the ability. The other thing is 00:14:54.594 --> 00:14:59.999 this introduces opportunity for backdoors, inadvertent or not 00:14:59.999 --> 00:15:07.573 because people think it's not my job, let someone else do it and 00:15:07.573 --> 00:15:10.476 it's quite fun because when I started to look for where have 00:15:10.476 --> 00:15:13.913 people backdoored repository. Let's look at Git, over the 00:15:13.913 --> 00:15:17.450 history, unfortunately there is not a lot of data out there in 00:15:17.450 --> 00:15:19.452 public domain. I'm sure commercially there is. But in 00:15:19.452 --> 00:15:21.988 public domain there isn't a lot. Back in 2003, anyone remember 00:15:21.988 --> 00:15:24.991 this fun little Linux backdoor someone tried to introduce. It 00:15:24.991 --> 00:15:28.161 wasn't in the main repository serverss if Linux but CVS server 00:15:28.161 --> 00:15:34.167 for people who wanted to use CVS and as we see here in green, it 00:15:38.504 --> 00:15:44.043 may be hard to read, some option, zero, and return some 00:15:44.043 --> 00:15:48.514 value. Okay. That doesn't mean much to anyone. Just like okay, 00:15:48.514 --> 00:15:52.518 what the hell does that mean? Well, what this code would 00:15:52.518 --> 00:15:56.889 introduce is if your program land on Linux and they had the 00:15:56.889 --> 00:16:01.260 appropriate flags it would have administrator or I.E. route 00:16:01.260 --> 00:16:06.399 privileges just on the fact of running so it could modify 00:16:06.399 --> 00:16:10.336 critical systems files, add or review users, it was effectively 00:16:10.336 --> 00:16:17.176 God. Oops. Now, look at the change history, at the bottom 00:16:17.176 --> 00:16:20.046 it's hard to see, you know, Torvals, if I cans zombies and 00:16:20.046 --> 00:16:27.420 then the next one is empty. That's odd. Another empty one 00:16:27.420 --> 00:16:31.457 and another empty one from the same guy and says oops, I worked 00:16:31.457 --> 00:16:37.496 with the wrong file. Hey,day, what the hell happened? This is 00:16:37.496 --> 00:16:43.502 not legit. So if anyone can help forward and claim 00:16:45.504 --> 00:16:49.175 responsibility, that would be nice. So end up filing this 00:16:49.175 --> 00:16:52.478 spread through the mailing at least and well, guys someone 00:16:52.478 --> 00:16:59.952 just tried to do this through the backdoor server and let's 00:16:59.952 --> 00:17:06.692 take care of this immediately before it catches on. Too late. 00:17:06.692 --> 00:17:11.397 Already got it and then it blew out. So fast forward along, 00:17:11.397 --> 00:17:15.301 let's look at all the cloud repository, Git hub, bit bucket, 00:17:15.301 --> 00:17:18.905 others, there is a part about these technologies is that 00:17:18.905 --> 00:17:21.440 they're being built with newer technologies, tech {TPHAOEBG}s 00:17:21.440 --> 00:17:26.679 that may not be necessarily proven or battled hardened. You 00:17:26.679 --> 00:17:31.817 know, your data will be safe. Well, some of you guys might 00:17:31.817 --> 00:17:35.988 remember this...this interesting vulnerability that discovered 00:17:35.988 --> 00:17:41.994 where you could change attributes and the rails 00:17:45.898 --> 00:17:51.437 community and pretty nasty default behavior, you should 00:17:51.437 --> 00:17:55.942 like, ah, no, twice, really, you should change it. Ah. Like, 00:17:55.942 --> 00:18:01.347 okay, I know how to change it. Besides, hey, the Git hub and 00:18:01.347 --> 00:18:07.353 the -- and their service and take some keys that allow me 00:18:09.789 --> 00:18:15.795 to...and hey, guy, look, see, I can do this. It's vulnerable. So 00:18:17.863 --> 00:18:22.234 all we really did was hey,ly's give me some special users, got 00:18:22.234 --> 00:18:25.504 some privileges to be able to modify that repository and say 00:18:25.504 --> 00:18:28.841 hey, give me that key and then push it and they were like oh, 00:18:28.841 --> 00:18:32.611 okay, and then rails community decided to accept that and said 00:18:32.611 --> 00:18:35.982 okay, quick, push the fix and so on and there was some blow back. 00:18:35.982 --> 00:18:41.887 Plenty of stuff online if you want to read more about that. So 00:18:41.887 --> 00:18:46.559 story time...sit back, take a drink. Kind of settle in and I'm 00:18:46.559 --> 00:18:52.565 going to tell you guys a fun story. So imagine my manager 00:18:55.134 --> 00:18:58.838 comes over to me and says, hey, John, your TCS reports, you have 00:18:58.838 --> 00:19:03.642 those done? No. It's a waste of time. I'm just going to do my 00:19:03.642 --> 00:19:09.115 job and you'll end up promoting me anyway. Thanks. I will 00:19:09.115 --> 00:19:13.753 promote you but you introduceed a pretty nasty buffer 00:19:13.753 --> 00:19:16.689 vulnerability in your -- and I'm like, no I didn't. I actually 00:19:16.689 --> 00:19:24.597 don't hate my job that much. Well, let's take a look...and 00:19:24.597 --> 00:19:27.600 then yeah, that's a vulnerability. Yeah, let's look 00:19:27.600 --> 00:19:31.604 at the log. Yeah, introduced by me. Introduced by me. Calculator 00:19:31.604 --> 00:19:34.907 C. Simple program, okay, sure. Finish time traveling. What? 00:19:34.907 --> 00:19:37.843 Steve Jobs@Steve.apple.com. That's not right. June 27, 2008. 00:19:37.843 --> 00:19:40.780 What...time traveling from beyond the grave. What? That 00:19:40.780 --> 00:19:44.784 wasn't me. And they're like no, well, you committed it. You 00:19:44.784 --> 00:19:50.256 accepted it. That was you. No. So maybe it was my friends who 00:19:50.256 --> 00:19:53.192 decided to pull a prank on me. Maybe it was my coworkers. Or 00:19:53.192 --> 00:19:59.498 maybe it was the evil hacker with their ski masks standing 00:19:59.498 --> 00:20:05.504 behind my computer. So, you know the security team, product 00:20:08.007 --> 00:20:14.013 security team will come over and say hey John let's figure this 00:20:16.949 --> 00:20:22.955 out. Keep calm. We're here to help you. So since you're using 00:20:25.925 --> 00:20:33.165 Git, who do you trust? Who are you set up to inherently trust? 00:20:33.165 --> 00:20:39.071 And I'm like, ah, everyone...no. There's a saying in God we 00:20:39.071 --> 00:20:45.077 trust, all those X1509 certificate but Git handles the 00:20:45.077 --> 00:20:51.083 integrity. Let's use C.R.Y.P.T.O. because it solves 00:20:54.553 --> 00:20:59.759 everything. So they end up adopting the trust model. Now, 00:20:59.759 --> 00:21:02.795 kind of complex to explain but effectively you can somewhat 00:21:02.795 --> 00:21:07.466 trust someone. You can fully trust someone. Or you can just 00:21:07.466 --> 00:21:12.471 absolutely not trust them and...so let's say I trust Chang 00:21:12.471 --> 00:21:16.208 Ki fully and I'm going to trust everyone by default I trust 00:21:16.208 --> 00:21:20.412 everyone there. Let's say I have this person called Alexander and 00:21:20.412 --> 00:21:25.384 I don't really trust her or the decisions they will make so I'm 00:21:25.384 --> 00:21:29.221 not going to trust her signing anything or accept our 00:21:29.221 --> 00:21:32.258 signature. So there's some that I kind of trust but I want to 00:21:32.258 --> 00:21:35.294 verify and do some additional due diligence before I do 00:21:35.294 --> 00:21:39.965 anything and this goes on and on and on but effectively it's all 00:21:39.965 --> 00:21:45.538 based on the GPG capability and build the PKI but go for it. But 00:21:45.538 --> 00:21:52.111 when it comes to commit, you only get one signature. You have 00:21:52.111 --> 00:21:56.282 two people sign it, yes, we both agree. And the signature like 00:21:56.282 --> 00:21:59.952 you see Jake with their -- and these signatures can be embedded 00:21:59.952 --> 00:22:05.891 in the repository or you can kind of extract them and do all 00:22:12.064 --> 00:22:14.600 other controls around that which we'll discuss for another time. 00:22:14.600 --> 00:22:18.737 But by default they will be up in the repository, but you end 00:22:18.737 --> 00:22:25.978 with four fundamental ways that you can sign the statement. You 00:22:25.978 --> 00:22:31.150 can sign every single commit that you're going to change and 00:22:31.150 --> 00:22:37.089 they say yes, yes. I authorize this. It's...pick up the things 00:22:37.089 --> 00:22:40.759 that you like and you can say yes, I reviewed each and every 00:22:40.759 --> 00:22:47.433 one. Sure, five. But sure when I'm deeming with a few hundred 00:22:47.433 --> 00:22:50.869 thousand lines of code because Red Hat released their version, 00:22:50.869 --> 00:22:55.207 oh, God, that is a hassle so you can't -- what you can say 00:22:55.207 --> 00:23:00.746 instead is yeah I'm only going to sign the merge. I don't know 00:23:00.746 --> 00:23:02.915 everything else, but I'll sign it. It's quick and dirty but 00:23:02.915 --> 00:23:05.851 you'll still have police coming at you, hey, have deuce the 00:23:05.851 --> 00:23:08.187 backdoor and your manager may come over and bother you more 00:23:08.187 --> 00:23:11.724 about TCS report or you flatten all of the change you're going 00:23:11.724 --> 00:23:15.394 to look at and say give me all the changes and I am just going 00:23:15.394 --> 00:23:22.568 to say I did it all and throw it in there. The problem with that 00:23:22.568 --> 00:23:27.172 is you lose the history of how all that code before was 00:23:27.172 --> 00:23:30.109 generated and if you try to dissect it, pull it out, oh, 00:23:30.109 --> 00:23:34.914 God, it's kind of ugly or you can do a version that does a 00:23:34.914 --> 00:23:39.718 scale...so imagine we have two people, hey, this is me and I 00:23:39.718 --> 00:23:42.721 did this, you know, here is a picture -- and you'll see Google 00:23:42.721 --> 00:23:45.924 engineers use this from time to time and you'll see it post up 00:23:45.924 --> 00:23:48.794 on -- more Google plus failed to do this. Yeah, this is me. See 00:23:48.794 --> 00:23:52.064 look my Google plus identity and this is...as you mike imagine 00:23:52.064 --> 00:23:58.070 that doesn't really work. But the interesting part is if you 00:24:00.940 --> 00:24:05.978 decide to destroy the history...by the victors so if 00:24:05.978 --> 00:24:11.684 you want to do a...go for it. But if you really care about the 00:24:11.684 --> 00:24:14.887 history but you want to live on the wild side, take a chance, 00:24:14.887 --> 00:24:20.259 yeah, go ahead. Just sign the merge commit. Or if you sign 00:24:20.259 --> 00:24:24.897 every single...technically the most secure from an integrity 00:24:24.897 --> 00:24:28.567 perspective but I don't know about you but I'll be lazy 00:24:28.567 --> 00:24:31.737 probably automate it like yeah all these look good. Go ahead 00:24:31.737 --> 00:24:34.740 and automatically magically sign that. So you want to prevent 00:24:34.740 --> 00:24:38.377 that, to give some assurance that hey I ago actually did 00:24:38.377 --> 00:24:43.782 this. But one against danger zone, because what does it mean 00:24:43.782 --> 00:24:47.920 to {ABGKHRL} sign is this a beautiful lay -- or is this a 00:24:47.920 --> 00:24:53.926 very not beautiful lady? So what does it mean when you sign? This 00:24:53.926 --> 00:25:00.799 message was authorized and metadata such as hey, tracer 00:25:00.799 --> 00:25:07.172 YouTube...or does it also snapshot and message was 00:25:07.172 --> 00:25:13.212 Authored as designed and what led up to that were legit and 00:25:13.212 --> 00:25:19.685 hey, here is the DIF and, yeah, everything is fine because as we 00:25:19.685 --> 00:25:24.723 see here, modified the suiters file, yeah, evil hacker use all 00:25:24.723 --> 00:25:29.461 privileges and password this pseudo because it's hard to use 00:25:29.461 --> 00:25:34.233 password when you have to continually enter in a password 00:25:34.233 --> 00:25:40.406 but don't worry in the metadata, security said it was okay. So it 00:25:40.406 --> 00:25:43.675 must be authorized. Now once again I'm still trying to figure 00:25:43.675 --> 00:25:48.280 out okay, how did they hack me, how did they take over use that 00:25:48.280 --> 00:25:52.718 simple defect? Well, one thing that I personally love to do to 00:25:52.718 --> 00:25:56.555 others especially at work is hey I noticed you left your computer 00:25:56.555 --> 00:26:00.359 unlocked. I also like to live dangously too. Sometimes change 00:26:00.359 --> 00:26:05.297 their background to My Little Ponies or in this case, Nicholas 00:26:05.297 --> 00:26:08.434 Cage, make them feel at home. Or in this case what one could do 00:26:08.434 --> 00:26:11.370 is pull up their IDE and probably don't want to enter in 00:26:11.370 --> 00:26:17.242 their credentials each time they push something, just go ahead 00:26:17.242 --> 00:26:23.449 and open up and enter in your bookdoor and try and push it and 00:26:23.449 --> 00:26:29.988 see what happens, you never know. The script way to hack is 00:26:29.988 --> 00:26:37.563 very well known. It's not fair to call this a hack, but you can 00:26:37.563 --> 00:26:42.401 change your e-mail and username. So just say hey global, my 00:26:42.401 --> 00:26:48.474 e-mail is X. My name is Y and just operate that way. And as 00:26:48.474 --> 00:26:51.543 far as the repository is concerned, that e-mail address 00:26:51.543 --> 00:26:54.146 and username is that. You didn't have to prove that you owned 00:26:54.146 --> 00:26:56.615 that e-mail address. You didn't have to prove that you were that 00:26:56.615 --> 00:26:59.818 identity so at least some interesting behavior. In this 00:26:59.818 --> 00:27:04.957 case here we see just simple evil backdoor, tracer...lead 00:27:04.957 --> 00:27:10.963 hacker 101, create some stuff. Change this over to DT.com. Once 00:27:13.298 --> 00:27:18.136 again, just this is behavior, so you really can't take anything 00:27:18.136 --> 00:27:20.739 that you see in a repository if you're really concerned about 00:27:20.739 --> 00:27:26.745 who created it...just based on...name alone, signing. The 00:27:29.114 --> 00:27:32.951 hacker team new exploit or someone found a leaked 00:27:32.951 --> 00:27:36.755 repository and compromising your computer and wait until you 00:27:36.755 --> 00:27:41.460 walked away and then went into the system. But from that 00:27:41.460 --> 00:27:45.130 perspective, it doesn't matter which tool you're using. You 00:27:45.130 --> 00:27:48.400 have to rely on other IT controls to really lock that 00:27:48.400 --> 00:27:54.273 down. There's nothing inherent that will protect you from that. 00:27:54.273 --> 00:28:00.212 But the interesting part is a shell 1 hash. They do a little 00:28:02.681 --> 00:28:05.851 bit more of that but effectively you need to find a Shaw 1 00:28:05.851 --> 00:28:10.923 collision to introduce your own malicious backdoor obliterate 00:28:10.923 --> 00:28:16.528 something previously. So imagine if I were to send you up to the 00:28:16.528 --> 00:28:19.998 moon free of charge of course I would have you search through 00:28:19.998 --> 00:28:24.036 every single atom of the moon and compare two of them that you 00:28:24.036 --> 00:28:29.474 find exactly the same. More than likely you will find a hash 00:28:29.474 --> 00:28:33.979 collision. Or another way of putting it and I love this...the 00:28:33.979 --> 00:28:37.816 higher probability member of your programming team will be 00:28:37.816 --> 00:28:41.820 attacked by wolves completely unrelated all in the same night. 00:28:41.820 --> 00:28:45.557 So if you're really, really tight, I worried of everyone 00:28:45.557 --> 00:28:49.595 getting killed by wolves all at the same time, you may want to 00:28:49.595 --> 00:28:55.233 get them built for wolfs. But this is built by design. Say up 00:28:55.233 --> 00:29:01.173 here this red liquid was my original artifact or my original 00:29:06.311 --> 00:29:10.449 configuration and if anyone were able to modify it, doom to the 00:29:10.449 --> 00:29:15.754 end of the world and let's say my entire development team was 00:29:15.754 --> 00:29:19.625 killed by wolves and here the red liquid coming in. Heying I 00:29:19.625 --> 00:29:25.063 see this new object you're trying to give me is the same as 00:29:25.063 --> 00:29:30.102 the old one. I'm just going to ignore the new one. So it's okay 00:29:30.102 --> 00:29:34.473 if you find it. It's going to look like gibberish but even 00:29:34.473 --> 00:29:38.477 then ignore the new ones and continue to track the old ones. 00:29:38.477 --> 00:29:44.716 So not entirely useful there. But if you're a bit tighter one 00:29:44.716 --> 00:29:48.720 way to do it is to get someone to apply a patch and when that 00:29:48.720 --> 00:29:52.190 patch is applied, then it causes the collision and that would 00:29:52.190 --> 00:29:55.927 work, but the reality of that happening academically is that 00:29:55.927 --> 00:29:59.398 that patch would look like gibberish and it would look like 00:29:59.398 --> 00:30:06.204 -- common sense, I don't know what this is. Let's get rid of 00:30:06.204 --> 00:30:12.210 it. Eew, so unfortunately Git is vulnerability to prefixes to X. 00:30:14.279 --> 00:30:18.183 Brad Fitzpatrick works at Google now, he wrote a fun little ghost 00:30:18.183 --> 00:30:24.189 script that would be like hey, I want to prefix of DEFCON in the 00:30:30.062 --> 00:30:33.432 hash because you know developers are kind of lazy. Maybe they 00:30:33.432 --> 00:30:36.134 didn't decide to use the full hash. Let me introduce my own 00:30:36.134 --> 00:30:40.038 prefix and hopefully they'll pick up my malicious instead of 00:30:40.038 --> 00:30:42.040 the prefix down below. Take more than five seconds to at most 00:30:42.040 --> 00:30:44.710 maybe a minute to modify to get your prefix of choice, but it's 00:30:44.710 --> 00:30:50.716 a fun little script and it works. The fun part is I have 00:31:01.359 --> 00:31:06.364 looking after this is now I'm being told to sign all of my 00:31:06.364 --> 00:31:10.368 commits and a new PKI infrastructure, going to do this 00:31:10.368 --> 00:31:14.339 right. Well, okay, cool but let me get some data about it. Hey, 00:31:14.339 --> 00:31:20.312 Git hub, serge API and your progresss that have over 9 --> 000 00:31:20.312 --> 00:31:26.318 stars. That's about 140 to 160 repositories at the time. And 00:31:30.222 --> 00:31:36.228 it's interesting what we see here -- let me get it out. Oh, 00:31:47.773 --> 00:31:55.046 Awesome. So it's kind of fun. So top and to the right is good. 00:31:55.046 --> 00:32:00.986 That means a lot of commits and a lot of signed commits. I would 00:32:03.555 --> 00:32:06.691 love to but this is called demo/fail so I'm going to try 00:32:06.691 --> 00:32:09.761 and -- so see up here top to the right way at the top, no 00:32:09.761 --> 00:32:15.767 surprise. Rails and a few other popular projects that we're 00:32:18.870 --> 00:32:24.876 familiar with up there. And the scales logs in rhythmic scale so 00:32:27.946 --> 00:32:32.117 as I change this to a much more linear fashion, you'll see that 00:32:32.117 --> 00:32:37.255 Linux is way up there. Way up here to the right and then far 00:32:37.255 --> 00:32:42.461 down here is everyone else. ( LAUGHTER ) >> So your take away 00:32:42.461 --> 00:32:46.431 from this is not a lot of projects out of those 140 were 00:32:46.431 --> 00:32:51.837 even signed or even had any attempt to provide the 00:32:51.837 --> 00:32:54.206 authenticity that I'm a preMadonna developer and I 00:32:54.206 --> 00:32:57.909 committed this and then those that do, they're relatively 00:32:57.909 --> 00:33:00.846 small number. even relative to the number of commits they had. 00:33:00.846 --> 00:33:06.618 So it's interesting when you look at that. Now, the fun part 00:33:06.618 --> 00:33:11.089 is this is DEFCON, right? And what's a talk without Odais. So 00:33:11.089 --> 00:33:14.059 I hundreded around for a -- hunted around for a few months. 00:33:14.059 --> 00:33:19.331 Which SCS do I want to poke around and find some decent 00:33:19.331 --> 00:33:25.337 Odais and not scientific at all. Hey, let's go to some database 00:33:27.572 --> 00:33:32.611 and put in these names and see what pops up either for the tool 00:33:32.611 --> 00:33:39.217 or products that have that name and they only had seven 00:33:39.217 --> 00:33:45.223 interesting. CVS had 566. Git had 2 --> 000. Because it's popular. 00:33:54.065 --> 00:33:56.067 I'm not going to try and do -- like I said, this is not 00:33:56.067 --> 00:33:59.938 scientific by any means but maybe I'll find something over 00:33:59.938 --> 00:34:04.676 there. Let's take CVS through static analysis. It came up 00:34:04.676 --> 00:34:06.678 squeaky clean. Dammit. I was hoping to find some really old 00:34:06.678 --> 00:34:12.684 defect from the '80s or '90. Git had its own challenges. It's not 00:34:18.723 --> 00:34:25.797 that great but unfortunately a lot of those vulnerabilities I 00:34:25.797 --> 00:34:30.468 can't imagine how they would be exploited or they're so esoteric 00:34:30.468 --> 00:34:34.673 that I gave up after trying to reproduce and develop an exploit 00:34:34.673 --> 00:34:39.477 after a week. Like I threw my hands up in the hair and said 00:34:39.477 --> 00:34:44.249 done. However, let's look at Git lab because there's something I 00:34:44.249 --> 00:34:51.723 can do. It's ruby. It's fun. It had some issues in 2014. So 00:34:51.723 --> 00:34:56.194 unfortunately I tried the food coloring. One of my coworkers 00:34:56.194 --> 00:34:59.698 brought it for me. It tastes like -- so we'll just have to 00:34:59.698 --> 00:35:07.038 rely on this image. But here is an Odais for Git lab. Now this 00:35:07.038 --> 00:35:12.811 one, it's almost asinine. Somehow you would have to modify 00:35:12.811 --> 00:35:18.917 a configuration...and if you're able to inject your malicious OS 00:35:18.917 --> 00:35:24.923 command in there, then sure, I will happily run it. But how 00:35:24.923 --> 00:35:28.560 about we give you guys something a little...so how about your 00:35:28.560 --> 00:35:33.765 good old hey give me a file from the file system. Well, hey, 00:35:33.765 --> 00:35:37.302 wiki, find me a file with this completed trusted parameter 00:35:37.302 --> 00:35:42.974 called ND version and hey if it exist, send it to me. Sure. So 00:35:42.974 --> 00:35:49.180 for OS controls such as improper permissions for the rails app or 00:35:49.180 --> 00:35:54.552 OS, yes, give me an ESI password. You'll probably get 00:35:54.552 --> 00:35:59.791 the walk around the file system, find improper permissions, 00:35:59.791 --> 00:36:06.865 global read, global write. Fun. Now the interesting part about 00:36:06.865 --> 00:36:10.769 this is you guys need some tools, either hack or to defend. 00:36:10.769 --> 00:36:16.975 A lot of the tools that have cure rated and put on Git 00:36:16.975 --> 00:36:21.813 backdoor are more for the defensive such as...or when a 00:36:21.813 --> 00:36:28.953 commit is pushed to actually review it automatically trusts 00:36:28.953 --> 00:36:34.726 the authoritative source. It's kind of interesting because a 00:36:34.726 --> 00:36:37.395 lot of us rely on this concept of I'm going to trust the 00:36:37.395 --> 00:36:42.167 client. And I'm going to put this control such as verifying 00:36:42.167 --> 00:36:44.436 all the commits and everything on the client because the client 00:36:44.436 --> 00:36:47.305 will never lie to me or the client won't disable that check. 00:36:47.305 --> 00:36:52.377 Just moreless a network of trust fail. So -- more or less a 00:36:52.377 --> 00:36:54.412 network to trust fail. So to kind of bring this to a fail, 00:36:54.412 --> 00:37:01.419 one doesn't backdoor this stuff. Oops, I created a defect. 00:37:01.419 --> 00:37:07.425 Honestly in all my years I never met a developer, anyone who ever 00:37:14.866 --> 00:37:16.868 wanted to introduce a vulnerable. Who ever wanted to 00:37:16.868 --> 00:37:19.270 write error prone code. I mean, some of it is certainly a Vin 00:37:19.270 --> 00:37:21.372 debt ta, but hon necessarily they never wanted to and pretty 00:37:21.372 --> 00:37:23.441 cool and nifty features are built into it but it still 00:37:23.441 --> 00:37:25.643 relies on this trust model and sure you can set up a very 00:37:25.643 --> 00:37:30.281 expensive PKI but as we see with Git hub and many other 00:37:30.281 --> 00:37:36.387 technologies they kind of ignore that and implement their own 00:37:36.387 --> 00:37:39.824 authorization and authentication model. Is it better or worse? 00:37:39.824 --> 00:37:42.727 I'm not going to sit here and tell you but they decided to go 00:37:42.727 --> 00:37:45.930 down a different route. So I would like to thank you all for 00:37:45.930 --> 00:37:50.568 coming. [Applause]. >> So two more things...imagine if you're 00:37:50.568 --> 00:37:55.306 this rock star Stanford professor or you're this amazing 00:37:55.306 --> 00:37:59.744 rock star game developer, this Awesome python module, you can 00:37:59.744 --> 00:38:05.683 say rock star, import rock star, activityment rock star, give it 00:38:17.095 --> 00:38:20.064 a parameter such as days and you give it a number and then you're 00:38:20.064 --> 00:38:24.035 like hey, make me a rock star. What it will do is modify the 00:38:24.035 --> 00:38:27.972 current repository and make it look like as if you workeder 00:38:27.972 --> 00:38:32.510 that many days. Pretty Awesome, right? So I through this up on 00:38:32.510 --> 00:38:36.214 Git hub, create a few repositories that goes back to 00:38:36.214 --> 00:38:42.187 1950 because that makes sense. Git hub and a few other graphs 00:38:42.187 --> 00:38:48.726 and models and tools and bit bucket kind of handle it and go 00:38:48.726 --> 00:38:52.397 back to FD and others say no I'm not giving you all that data but 00:38:52.397 --> 00:38:54.966 I got an e-mail from Roman and he's like dude, that's crazy and 00:38:54.966 --> 00:39:00.905 I'm like yeah and an interesting hack...he did an interesting way 00:39:03.074 --> 00:39:09.747 where he was able to harvest all the SSH authentication 00:39:09.747 --> 00:39:13.651 mechanisms for Git hub, was able to pull all those public keys 00:39:13.651 --> 00:39:15.820 and start looking at their strength. Are they weak, are 00:39:15.820 --> 00:39:19.857 they secure? And he told Git hub and not a problem, we don't 00:39:19.857 --> 00:39:24.329 generate these keys. They are given to us by the user. We 00:39:24.329 --> 00:39:27.265 don't really have a shared responsibility. I don't 00:39:27.265 --> 00:39:33.338 know...the data set. You see a lot of RSA keys, bit strength, 00:39:33.338 --> 00:39:38.877 256, 512, you know, already known to be just wait, what, 00:39:38.877 --> 00:39:44.315 when were these generated? And bit hub was like yep, hey, guys, 00:39:44.315 --> 00:39:51.389 you need to change it so once again, I cannot recommend more 00:39:51.389 --> 00:39:56.094 than enough ProGit book. A great source to know where to avoid 00:39:56.094 --> 00:39:59.564 pitfalls and that sort of thing. But thank you all for coming and 00:39:59.564 --> 00:40:05.336 that truly is all. [Applause]