1 00:00:00,375 --> 00:00:04,167 >> Thanks everyone for coming. I'm going to be talking about cookies but first a couple of 2 00:00:04,167 --> 00:00:10,167 cookie related jokes. What's milk's favorite band? Oreo Speedwagon. [Laughter]. What do 3 00:00:13,458 --> 00:00:21,125 you say when no one laughs at your cookie joke? Doh, sorry that was half baked. [Laughter]. 4 00:00:21,125 --> 00:00:24,958 Ok, so we're going to be talking about why someone would want to steal http cookies off of your 5 00:00:24,958 --> 00:00:29,375 client and we're going to talk about how that could happen and what you can do to protect 6 00:00:29,375 --> 00:00:35,000 yourself. SO, people stealing cookies off of the wire is kind of a well known attack over 7 00:00:35,000 --> 00:00:41,250 plain HTP but I'm going to talk about how they are stored on HTP clients, like your computer, and 8 00:00:41,250 --> 00:00:46,167 how those can be stolen. Just before we get going, the opinions in this presentation 9 00:00:46,167 --> 00:00:51,125 are mine and not my employer's and the security issues I discuss are not vulnerabilities 10 00:00:51,125 --> 00:00:55,458 in particular websites. You'll see some logos from screenshots, I'm not going after particular 11 00:00:55,458 --> 00:01:01,250 websites. This is sort of a systemic issue that I see so don't get too excited and live 12 00:01:01,250 --> 00:01:07,042 tweet "oh my god, google got hacked," that's not what is happening here. Ok, so what is 13 00:01:07,042 --> 00:01:12,958 an HTTP cookie? Cookies are name-value pairs that are transmitted as HTTP headers both 14 00:01:12,958 --> 00:01:18,708 in requests and as responses. A typical use case in one I'm going to focus on for pretty 15 00:01:18,708 --> 00:01:23,292 much the whole talk is a client sends a username and password. So you're in your browser, you 16 00:01:23,292 --> 00:01:28,000 type your user name and password, you send it to a server in the login form. The 17 00:01:28,000 --> 00:01:32,542 server sends back a cookie that is then used as your authentication token going 18 00:01:32,542 --> 00:01:34,917 forward so you don't have to constantly reenter your password. So that is a very 19 00:01:34,917 --> 00:01:41,000 common use of cookies and that's what I'm going to focus on. So, for those of you who have never 20 00:01:41,000 --> 00:01:47,000 seen cookies before they have some attributes besides just some name and value. They are 21 00:01:49,250 --> 00:01:56,250 associated with a domain. This is a fresh request to twitter.com from an incongnito 22 00:01:56,250 --> 00:02:02,750 session in chromium's developer toolbar and their name space into a path so if it only 23 00:02:02,750 --> 00:02:06,500 applies to a part of a site the browser will only send the cookie to a certain path within 24 00:02:06,500 --> 00:02:11,417 the website. They expire, a session cookie. The term session is overloaded, so a session 25 00:02:11,417 --> 00:02:18,292 cookie is both a cookie used an authentication token and a cookie that expires when you 26 00:02:18,292 --> 00:02:24,917 close your browser. So, here the expiration time session means when you close your browser the 27 00:02:24,917 --> 00:02:29,917 cookie is gone. It expires when you close your session. A lot of them have dates sometime in the 28 00:02:29,917 --> 00:02:36,667 future. This just has the size. The HTP only cookies cannot be seen from client side scripting 29 00:02:36,667 --> 00:02:41,750 like java script so this mitigates some cross side scripting attacks where normally 30 00:02:41,750 --> 00:02:47,250 someone could read your cookie in java script and send it to some bad server sites somewhere. 31 00:02:47,250 --> 00:02:52,125 HTP only cookies can't be accessed from java script, it's only part of the HTTP request. 32 00:02:52,125 --> 00:02:56,917 And secure cookies are only sent over HTPF connections, not HTP. So if you accidently type in 33 00:02:56,917 --> 00:03:03,875 http://g‑mail.com, you will connect there and be redirected to the https version but your 34 00:03:03,875 --> 00:03:09,417 cookie won't be sent if it is marked as secure. That is another security feature. So, 35 00:03:09,417 --> 00:03:13,792 every one knows it is bad if someone takes over your machine. I'm going to deep dive into that 36 00:03:13,792 --> 00:03:19,208 a little bit. And something that I heard other people talk about too much. So any process that 37 00:03:19,208 --> 00:03:23,375 runs your user within the default configured system can read your private keys, which 38 00:03:23,375 --> 00:03:28,375 hopefully you have passwords for that reasons. Some softwares stores passwords in plain texts 39 00:03:28,375 --> 00:03:33,708 so like IM clients and FTP clients will often, when you say save my password for pigeon or 40 00:03:33,708 --> 00:03:39,458 whatever your ftp client is, that is in a text or XML file. It's just your password that you 41 00:03:39,458 --> 00:03:43,167 had typed in and it will send that to the server each time to authenticate. So it is on your 42 00:03:43,167 --> 00:03:48,000 hard drive somewhere. And web browser cookies are generally stored as plain text, but they 43 00:03:48,000 --> 00:03:52,875 are always readable as a user. I gave a five minute talk at another conference on this 44 00:03:52,875 --> 00:03:59,083 called the readable data and multiple personalities because they are illustrated the same. 45 00:03:59,083 --> 00:04:04,208 And the whole idea here is the data infiltration attacks. Someone gets on the machine, 46 00:04:04,208 --> 00:04:08,917 they see the data they want and take it to a server somewhere and then they are done. They 47 00:04:08,917 --> 00:04:13,917 don't need to ask for privileges and they don't need to persist. So this kind of the crux of my 48 00:04:13,917 --> 00:04:20,083 talk. I believe that cookies can be more valuable than passwords some of the time. I will go into 49 00:04:20,083 --> 00:04:24,458 a little more detail in the next couple of slides. Usually people think I got to protect my 50 00:04:24,458 --> 00:04:30,458 password, what is a cookie? Especially to an attacker. But I think they are pretty valuable. 51 00:04:33,917 --> 00:04:38,750 Counterpoint, cookies expire, whereas passwords sometimes expire but for web applications, 52 00:04:38,750 --> 00:04:44,417 often don't. A lot of sites will make you reenter your password, before you do something special, 53 00:04:44,417 --> 00:04:48,667 like change your password. You'll have to reenter the initial one or before you enter 54 00:04:48,667 --> 00:04:53,208 an ssh key on gethub you'll have to reenter your password. So in that sense passwords are more 55 00:04:53,208 --> 00:04:59,208 important than cookies you cannot do everything with a cookie, but you can do a lot. So 56 00:04:59,208 --> 00:05:04,000 how many people use g‑mail, but do not have two factor authentication enabled? Raise 57 00:05:04,000 --> 00:05:10,000 your hands. How many passwords start with the later A? Just kidding. Kind of. So two factor 58 00:05:12,875 --> 00:05:17,417 authentication for people who are not familiar. There is a password, one factor something 59 00:05:17,417 --> 00:05:23,208 you know. And another factor something you have, like a phone. So the idea is, a bad 60 00:05:23,208 --> 00:05:26,125 guy is going to take over your account they need both your password, something you know and 61 00:05:26,125 --> 00:05:33,000 something you have. So you enter your user name and password and then get a text to your phone 62 00:05:33,000 --> 00:05:37,292 after you a ‑‑ authenticated successfully, and then you enter the code sent to your phone in a 63 00:05:37,292 --> 00:05:44,000 text or a little app into the web browser to verify this is the account, the person that 64 00:05:44,000 --> 00:05:49,792 owns the account. If you have a cookie you bypass this, because it is already 65 00:05:49,792 --> 00:05:56,000 authenticated. So if someone sends you a g‑mail cookie they have a bypass two factor. That 66 00:05:56,000 --> 00:06:00,458 is interesting. Usually if you steal a password you cannot get in, but steal the cookie you 67 00:06:00,458 --> 00:06:06,458 can. And similar for Facebook. If you log‑in, authenticate from a new location or new ip address 68 00:06:10,250 --> 00:06:17,708 you get an e‑mail to your account e‑mail and will say, hey, someone new logged in, is 69 00:06:17,708 --> 00:06:22,583 this you? But if you have a session cookie and you log‑in with the session cookie, you 70 00:06:22,583 --> 00:06:29,250 just make it part of your HTP request, which I will show later. You don't get this e‑mail 71 00:06:29,250 --> 00:06:34,125 triggered. So in that sense, again, the cookie is more valuable to an attacker than the 72 00:06:34,125 --> 00:06:40,125 user name and password. So, we're going to take another little cookie joke break. And be 73 00:06:43,333 --> 00:06:49,250 ready, prepare yourselves, brace yourselves. What do cookies have in common with stoners? Both are 74 00:06:49,250 --> 00:06:55,542 freshly baked. So we're going to talk about the way that browsers store cookies. Because the idea 75 00:06:55,542 --> 00:07:01,625 is that someone takes over your machine or on it for a temporary period of time, how do they read 76 00:07:01,625 --> 00:07:07,833 your cookies? What is involved in doing that? So most browsers store cookie as plain text. And 77 00:07:07,833 --> 00:07:13,875 http only and secure flags I talked about earlier are only inside of browsers so it is up 78 00:07:13,875 --> 00:07:18,667 to HTTP client to store them, to protect you. So malware does not need to inforce them, malware 79 00:07:18,667 --> 00:07:21,750 doesn't need to respect them. The cookies are stored in the same place. So your secure 80 00:07:21,750 --> 00:07:27,625 cookies are stored along side unsecured cookies. FireFox is one of the popular browsers I'm 81 00:07:27,625 --> 00:07:33,875 going to talk about, I'm going to talk about five, it stores cookies in the SQL database. So 82 00:07:33,875 --> 00:07:39,458 that means you can use a SQLite free command line tool. Python has a SQLite baked in, you can 83 00:07:39,458 --> 00:07:46,958 link to SQLite libraries. So an example of SQLite connection. We, on Mac, open the database 84 00:07:46,958 --> 00:07:53,250 just by passing the path to the SQLite 3 command line tool. And can you read this? Yeah. Cool. 85 00:07:53,250 --> 00:08:00,375 And ‑‑ schema just shows how the table is created. You can see the name and the value are both 86 00:08:00,375 --> 00:08:07,292 text columns at the end of the second row and the third row on the second command. And all it 87 00:08:07,292 --> 00:08:13,167 takes to read the cookies out of the FireFox cookie database is select value from most cookies 88 00:08:13,167 --> 00:08:19,000 where name equals gx. Where gx is the gmail cookie. It would be pretty ironic if my dummy 89 00:08:19,000 --> 00:08:23,625 account got taken over, because I posted my cookie here, but it is a dummy account, I don't 90 00:08:23,625 --> 00:08:28,792 care. There is a second SID cookie that google accounts uses. I'm not too worried but I 91 00:08:28,792 --> 00:08:34,500 would love if someone took over the account and sent me e‑mails. If you get bored you can try 92 00:08:34,500 --> 00:08:39,792 doing that but I think you'd need another cookie. IE is interesting. It sorts cookies at 93 00:08:39,792 --> 00:08:45,000 text files not in a database. The folder where the cookies are stored depends on the IE 94 00:08:45,000 --> 00:08:50,083 version. And the file names are random. In order to get the value you're looking for, like 95 00:08:50,083 --> 00:08:54,125 the GX cookie for g‑mail. You need to iterate through the files. So your programmatically 96 00:08:54,125 --> 00:08:58,667 on the machine, you run a script, loop through thhe files in the directory that have 97 00:08:58,667 --> 00:09:06,292 random names, that you will see here, and pick out the one that you want. So I'm reading a bunch 98 00:09:06,292 --> 00:09:11,375 of cookies, one of them has a GX in a place where I put the name, okay. That's the one that I 99 00:09:11,375 --> 00:09:16,292 want. You cannot just do index search, you have to loop through them all, as far as I know. I 100 00:09:16,292 --> 00:09:19,958 blocked it out, its the Google analytics cookie, it's not a big deal but I'm paranoid because 101 00:09:19,958 --> 00:09:25,958 it's DEF CON. Yes? [crowd question]>> In that case how does a company know which 102 00:09:29,458 --> 00:09:35,458 cookies are theirs? So, lets say I'm shopping on Amazon, I go back on, how does Amazon know 103 00:09:37,542 --> 00:09:44,458 which cookie to utilize, i.e. know which cookie is associated with Amazon? >>So only the ‑‑ 104 00:09:44,458 --> 00:09:49,167 the web browser says, you said on the twitter slide ‑‑ this is an Amazon.com cookie, this is a 105 00:09:49,167 --> 00:09:52,750 twitter cookie. So the only cookie that are sent to the site are one that are marked by the 106 00:09:52,750 --> 00:10:00,167 client as belonging to the site. Make sense? The question was how do you know ‑‑ how are 107 00:10:00,167 --> 00:10:06,167 particular cookies sent to the right site? Okay. So Opera and Safari use custom binary formats 108 00:10:09,542 --> 00:10:13,375 to store their cookies. But they are freely available software tools for parsing them. It is 109 00:10:13,375 --> 00:10:19,375 not hard to read safari is binary cookies, in case you didn't think cookies are in 110 00:10:22,208 --> 00:10:26,083 there and opera it's called cookies4.dat. So just a quick example of the free software 111 00:10:26,083 --> 00:10:31,625 tools that I didn't write. One is a github, and one is a blog post. Python script to read 112 00:10:31,625 --> 00:10:39,250 cookies and find Yahoo ones is not that interesting compared to anything else. Opera is the same 113 00:10:39,250 --> 00:10:42,833 thing. They just put a bunch of debug info in their parsing, they didn't clean it up because 114 00:10:42,833 --> 00:10:48,042 this is just a demo. Okay. Chromium is by far the most interesting browser for cookies 115 00:10:48,042 --> 00:10:53,833 I'm going to focus on the most. So chromium, in recent versions, encrypts cookies. It got a lot 116 00:10:53,833 --> 00:10:58,500 of press in January for doing that so it's been there for a little while. It was in the 117 00:10:58,500 --> 00:11:03,167 diversion for months before it made it into the main line chrome. When I say chromium I'm 118 00:11:03,167 --> 00:11:07,208 talking about the open source version of the chrome browser. They are pretty much equivalent. 119 00:11:07,208 --> 00:11:13,708 Chrome just has Google branding. So it stores cookies in the SQLite database. Before, just 120 00:11:13,708 --> 00:11:18,583 like Firefox there was a name and a value text column but now there is an encrypted value blob 121 00:11:18,583 --> 00:11:24,542 column which means binary data can go in there. It was still use the text column, the value, 122 00:11:24,542 --> 00:11:31,708 but it will look in the encrypted value field and see if there is an encrypted cookie set 123 00:11:31,708 --> 00:11:38,750 and I'll show more about that. In Linux there is no single standard key chain. KDE, Gnome, 124 00:11:38,750 --> 00:11:42,375 the different desktop environments all have their own key chain. There is no Linux key 125 00:11:42,375 --> 00:11:47,833 chain. The key chain being a place where you type in your password and you want to save 126 00:11:47,833 --> 00:11:53,333 this in a secure place that is encrypted. There is one master password for all of your system 127 00:11:53,333 --> 00:11:59,708 passwords for the user. So Linux doesn't have a centralized one. So on chromium what they did for 128 00:11:59,708 --> 00:12:05,708 Linux encryption of cookies they used AES, which is symmetric key encryption and used a hard coded 129 00:12:08,208 --> 00:12:12,750 key in salt in the course code. If you encrypt your cookies on one machine they can be 130 00:12:12,750 --> 00:12:17,583 decrypted on any machine because you can just read the source code, the key in salt and 131 00:12:17,583 --> 00:12:25,000 decrypt the cookies. So I say it is offuscated and not encrypted. There are comments in their 132 00:12:25,000 --> 00:12:29,958 source code about that they just haven't fixed that yet. So reading, what I did was ‑‑ I 133 00:12:29,958 --> 00:12:35,083 linked against the chromium libraries. So you can just call code to decrypt, undo the 134 00:12:35,083 --> 00:12:42,250 encrypt they are doing, but I decided to reuse their code because I'm lazy. The way that 135 00:12:42,250 --> 00:12:48,917 works is ‑‑ there's a binary blob that looks like garbage here, but when you call the code 136 00:12:48,917 --> 00:12:54,917 to decrypt it is the same DQAA prefix cookie, it was on FireFox. The GX cookie again. 137 00:12:59,458 --> 00:13:06,708 You don't have SIDS you can't take over my account I don't think. So what this means, the 138 00:13:06,708 --> 00:13:12,833 black shell, one computer reads the cookie out of the database, you're some malicious actor, 139 00:13:12,833 --> 00:13:17,333 then you bay 64 code it, send it over the wire and in my case just copy and paste it into 140 00:13:17,333 --> 00:13:21,000 a text file because it's in a VM. You can read it on another computer and decrypt it on 141 00:13:21,000 --> 00:13:27,583 another computer. It is not really encrypted. Windows is encrypted. It uses a 142 00:13:27,583 --> 00:13:33,417 Crypt/Protect/Data function to encrypt cookies for chromium on windows. That's a windows 143 00:13:33,417 --> 00:13:40,042 cyrptography API so it's part of the system libary, it's standard stuff for windows. It uses login 144 00:13:40,042 --> 00:13:45,083 credentials as part of the encryption. If you have access to someone's computer, power it 145 00:13:45,083 --> 00:13:50,042 off, you need their login credentials to decrypt the cookies. Whereas on Linux that 146 00:13:50,042 --> 00:13:55,417 is not the case, you can just implement them on any machine. So crypt/unprotect/data is sort 147 00:13:55,417 --> 00:13:58,625 of the twin function of crypt/protect/data, you must call it as the same user that 148 00:13:58,625 --> 00:14:05,000 encrypted on the same machine. Chromium on mac is perhaps state of the art of cookie storage in 149 00:14:05,000 --> 00:14:10,375 browsers. So in the system key chain they store an encryption key. If there is not one at the 150 00:14:10,375 --> 00:14:14,083 beginning they have a random one to put in there. And use AES to encrypt/decrypt with that 151 00:14:14,083 --> 00:14:20,083 protected secret. One thing to note, if you an unsigned app and try to access the key chain 152 00:14:24,000 --> 00:14:27,917 there will be a pop up for users. If you have some random Malware on your computer trying 153 00:14:27,917 --> 00:14:33,208 to access your key chain you will get notified. It will look like that. In that sense it is 154 00:14:33,208 --> 00:14:39,917 harder for an app that you don't trust to read secrets out of your key chain in general, it's 155 00:14:39,917 --> 00:14:46,042 a mac security feature, which is cool. Okay. So in summary, chromium encrypts cookies on 156 00:14:46,042 --> 00:14:51,542 windows and mac, it offuscates them on Linux and other popular browsers for the cookies as 157 00:14:51,542 --> 00:14:57,333 plain text. And FireFox, Opera and safari store them in plain text in a binary file format, 158 00:14:57,333 --> 00:15:03,333 they are just there to read. Okay. So we're going to talk about some attack vectors. I try 159 00:15:05,917 --> 00:15:13,125 to come up with more cookie jokes but they are all too crummy. So the first one, which 160 00:15:13,125 --> 00:15:16,417 I alluded to earlier is physical access, which is someone gets access to your powered off 161 00:15:16,417 --> 00:15:20,750 machine. You don't have dis-encryption on, they turn it on and read the cookies. 162 00:15:20,750 --> 00:15:26,917 Chromium actually protects you from this on Windows and Mac; do the encryption, that is cool, 163 00:15:26,917 --> 00:15:32,625 that is novel, that did not exist until eight months ago. That cool. So social engineering 164 00:15:32,625 --> 00:15:40,542 is another attack vector. So someone gets you to run an excel or Word document with a macro in 165 00:15:40,542 --> 00:15:47,083 it, they can run visual basic for applications code on your computer and then call code from 166 00:15:47,083 --> 00:15:52,750 the Internet to read the cookies and just read the cookies and ship them somewhere else. I have 167 00:15:52,750 --> 00:15:59,792 a demo of this later, or slides of the demo. So again you don't need to install anything, it's a 168 00:15:59,792 --> 00:16:03,792 data filtration attack, if someone is attacking you where they just get on your machine, 169 00:16:03,792 --> 00:16:11,250 get the cookie, leave and then reuse it before it expires. It is kind of scary. Malware is 170 00:16:11,250 --> 00:16:16,208 similar to social engineering, it kind of overlaps. Someone drops and runs an executable 171 00:16:16,208 --> 00:16:21,500 there is a whole metasploit. You've got code execution on the machine. Again, any process that 172 00:16:21,500 --> 00:16:27,583 runs with a user for the cookies. The idea from attacker perspective would be I 173 00:16:27,583 --> 00:16:33,125 want to send the cookies over HTTPS or just plain HTP to a server somewhere and then use 174 00:16:33,125 --> 00:16:39,125 them myself. Does that make sense? Cool. So here is a proof of concept that I did. So what I 175 00:16:45,417 --> 00:16:52,250 did was I wrote some code to read cookies off of the client in various situations. So 176 00:16:52,250 --> 00:16:58,750 chromium on windows, for chromium on Linux and for Firefox. And I ran that in other 177 00:16:58,750 --> 00:17:06,250 machines, so one is a VM, these are both VM's, the top one, Google one is a windows VM and 178 00:17:06,250 --> 00:17:12,250 the other one is a Linux VM. So I ran the malicious code that I wrote for myself and then sent 179 00:17:14,500 --> 00:17:20,000 the cookies to my listening server, which is a cookie capturing server and ‑‑ then 180 00:17:20,000 --> 00:17:27,167 when I, in the admin interface clicked use cookies in browser and pressed the go button. It 181 00:17:27,167 --> 00:17:34,250 creates a temporary profile with cookies in it in chromium and logs in to the accounts from 182 00:17:34,250 --> 00:17:40,250 another setup. So you're able to use the cookies to login, kind of semi automated. Bypassing two 183 00:17:42,625 --> 00:17:48,625 factor, bypassing the new login location notification email. At this point, I milked all of the 184 00:17:51,458 --> 00:17:57,958 cookie jokes for all they are worth. So dis-encryption prevents against physical 185 00:17:57,958 --> 00:18:04,167 access. That is kind of good idea from a security perspective in general. With data 186 00:18:04,167 --> 00:18:08,292 exfiltration or just someone reading your comptuer that you don't want to and in this 187 00:18:08,292 --> 00:18:14,083 particular situation, it is good if you have dis-encryption that will protect you from physical 188 00:18:14,083 --> 00:18:20,750 access. Application firewalls are an interesting tool. The idea you can block or allow 189 00:18:20,750 --> 00:18:28,042 traffic based on server port pairs per application. You can say this application can access 190 00:18:28,042 --> 00:18:33,583 this server and this port. So if another application tries to do the same thing you will get 191 00:18:33,583 --> 00:18:41,333 a pop up. So, example, chromium can access google on port 443 for HTTPS. Little snitch is a 192 00:18:41,333 --> 00:18:45,542 popular way for doing this for mac. It's a commercial product. Windows I think that limiter is 193 00:18:45,542 --> 00:18:50,500 one thing that does the same thing. Linux is an interesting case. There are not any stable 194 00:18:50,500 --> 00:18:55,125 currently maintained application firewalls for Linux that I know of. I would love to hear if you 195 00:18:55,125 --> 00:18:59,667 know. There are a couple different products that are supposed to do it open source, 196 00:18:59,667 --> 00:19:04,708 but there is a currently maintained one on stable, and not currently maintained. So 197 00:19:04,708 --> 00:19:11,583 that would be great to see going forward. Little snitch here, is an example of it, just to 198 00:19:11,583 --> 00:19:16,917 illustrate when I tried to read from an HTP request from the command line it says hey your 199 00:19:16,917 --> 00:19:22,917 command line is trying to access reddit, do you want to allow it permanently or just once. 200 00:19:25,667 --> 00:19:30,833 SELinux is another thing that helps with this kind of attack. It segments your applications 201 00:19:30,833 --> 00:19:37,167 from each other. Before I was saying if a process runs the user can read all of your files, 202 00:19:37,167 --> 00:19:43,250 SELinux and other tools like it have sort of extra access controls that you can apply on 203 00:19:43,250 --> 00:19:50,292 top of normal UNIX access control. You can say I own these two files, but only one process 204 00:19:50,292 --> 00:19:54,333 can access this one and only this process can access that one. If a third process spins up 205 00:19:54,333 --> 00:19:58,875 it's just Malware, it's random, they will not be able to access, even if they are all owned as my 206 00:19:58,875 --> 00:20:04,875 user. One idea I have, I don't know it will be implemented for cookies is a master password for 207 00:20:08,250 --> 00:20:13,625 cookies. The idea is your cookies are stored encrypted on your hard drive. It's kind of a 208 00:20:13,625 --> 00:20:16,958 two factor idea, you need to enter a password at the beginning of your browser 209 00:20:16,958 --> 00:20:21,167 session to decrypt your cookies before you can access them. It is not too inconvenient, you 210 00:20:21,167 --> 00:20:26,625 only have to enter your password once per session and FireFox actually does this to protect 211 00:20:26,625 --> 00:20:32,625 passwords. Cromium doesn't, they made an intentional decision not to. So here's what it looks like 212 00:20:34,750 --> 00:20:40,083 for Firefox's password manager and you can imagine sending similar cookies. So the idea 213 00:20:40,083 --> 00:20:43,833 here is if the passwords are stored on the hard drive they can be read by any process or 214 00:20:43,833 --> 00:20:49,833 user, but they are encrypted unless you enter this password. Then one interesting defense is 215 00:20:52,375 --> 00:20:58,333 tying a session cookie to the login ID. So when someone authenticates initially the 216 00:20:58,333 --> 00:21:04,458 first time, they authenticated from this IP address. If they try to log in from a different 217 00:21:04,458 --> 00:21:08,917 IP address later with that cookie, it will reject and make them re-authenticate, it will 218 00:21:08,917 --> 00:21:13,875 only work with that IP address. cPanel, which is a web hosting configuration tool actually does 219 00:21:13,875 --> 00:21:17,292 this optionally. The bunch of people who are actually confused on their forums. They log‑in, 220 00:21:17,292 --> 00:21:23,833 and they go to somewhere else, they have to relogin everytime they go to the coffee shop and 221 00:21:23,833 --> 00:21:29,417 come back home. So it is a trade‑off of a security versus convenience. I think that is a 222 00:21:29,417 --> 00:21:34,958 little bit too extreme. But you can do, which g‑mail does, you can say, where have I logged in 223 00:21:34,958 --> 00:21:41,250 from recently? So I have logged in from five countries this month. I haven't been traveling, 224 00:21:41,250 --> 00:21:47,250 I should probably do something about that. Okay. I think I blew those these pretty fast. Cookies 225 00:21:49,708 --> 00:21:55,042 should be handled with care. And client side cookie security is not a solved problem, it is 226 00:21:55,042 --> 00:22:00,875 something that I think needs more thought going forward. And that is how the cookie crumbles. 227 00:22:03,167 --> 00:22:09,167 Any questions? Yeah? So the question is how do you protect the hard drive? With cookies or 228 00:22:20,458 --> 00:22:26,458 in general? Okay. So having an encrypted hard drive is a form of protection, and how does that 229 00:22:35,833 --> 00:22:43,125 work is the question. The way it works, if someone accesses your computer, before they can mount 230 00:22:43,125 --> 00:22:45,792 the hard drive, before they can read the files on your hard drive, they need to enter the 231 00:22:45,792 --> 00:22:50,792 secret, the password, the key. If that password is strong they have to guess that key before 232 00:22:50,792 --> 00:22:54,833 they can read the files on the computer. Dis-encryption prevents someone from accessing 233 00:22:54,833 --> 00:23:00,083 your computers and opening up and reading the files. If it is not encrypted, someone can put 234 00:23:00,083 --> 00:23:06,083 in a Linux live CD and they'll be able to read all of the files on your hard drive. Correct. So 235 00:23:12,167 --> 00:23:16,250 the question ‑‑ if they have physical access, this encryption helps. If they are accessing you 236 00:23:16,250 --> 00:23:22,250 remotely, encryption doesn't help, everything is in memory, anyway. Yeah? So the question, 237 00:23:36,250 --> 00:23:43,625 is the encryption on chromium enough for this type of attack? Mathematically it is. So it is 238 00:23:43,625 --> 00:23:49,625 good encryption, but on Linux they use a hard coded key. So ‑‑ in that sense, the encryption 239 00:23:52,583 --> 00:23:58,542 doesn't matter, because you can traverse it trivially, on the other two, it should be, it 240 00:23:58,542 --> 00:24:04,542 should be good. I think. Yeah? So the question is, why didn't the encryption prevent the 241 00:24:26,375 --> 00:24:34,208 cookie from being exfiltrated? So the reason the cookie was exfiltrated it is decrypted on 242 00:24:34,208 --> 00:24:40,917 the client where it lives. You call code to read the cookie and decrypt it and then you send it 243 00:24:40,917 --> 00:24:46,917 somewhere. No. It's, it's, actually I e‑mailed the chromium security team about why it is 244 00:24:50,833 --> 00:24:55,750 different on Linux. They said the main reason they wanted to protect people on windows 245 00:24:55,750 --> 00:25:02,542 without full dis-encryption, that was their main intention. So it's ‑‑ by design in some 246 00:25:02,542 --> 00:25:08,542 sense. So the question, does Cserve protection help? Ah ‑‑ I'm not sure I understand how ‑‑ 247 00:25:27,583 --> 00:25:33,583 okay. So the question is does Cserve protection which invalidate sessions in that in 248 00:25:48,542 --> 00:25:55,958 sense, does that protect people from this kind of attack. I would say no. Once you get the 249 00:25:55,958 --> 00:26:01,292 cookie into the browser like in the proof of concept, then you are just that user. You are in 250 00:26:01,292 --> 00:26:06,250 the browser as that user. So it will do all of the normal Cserve stuff, it will read the tokens 251 00:26:06,250 --> 00:26:12,250 and send them along with the request. I'm sorry. Can you repeat that? So the question is, 252 00:26:30,208 --> 00:26:36,208 could you have cookies that belong to multiple sites? I think the browser, the way 253 00:26:52,333 --> 00:26:55,583 cookies are stored probably doesn't support that. I think domain is just a column one 254 00:26:55,583 --> 00:27:00,083 right now and just one thing. And I think the secure implications these that are kind 255 00:27:00,083 --> 00:27:07,333 of scary if you sent ‑‑ well ‑‑ it would be ignored by the site unless there was some 256 00:27:07,333 --> 00:27:12,125 collaboration between the two sites on the back end. If I had Yahoo! and Google cookie that 257 00:27:12,125 --> 00:27:15,208 goes to both of them, it is from Yahoo!, Google would need to know about that, it would need 258 00:27:15,208 --> 00:27:21,583 to have something on it's session on the server saying this is a valid cookie. So in 259 00:27:21,583 --> 00:27:27,583 that sense, it wouldn't get too much more with having just two separate cookies. Anyone else? 260 00:27:31,083 --> 00:27:37,083 Yes? Does client side JavaScript have access to non HTML in the cookies. I think that is the 261 00:27:40,875 --> 00:27:46,875 main idea, I think that's what HTML means for that site. Not just for any is site in the 262 00:27:49,167 --> 00:27:55,167 world. Someone else over here? Right. So if you're really paranoid, what you do is you 263 00:28:02,667 --> 00:28:06,750 just don't save cookies. You have everything via session cookie and it expires when you 264 00:28:06,750 --> 00:28:10,125 close your browser and then you are happy. Again, it is annoying, you have to 265 00:28:10,125 --> 00:28:16,583 reauthenticate all of the time. I think application firewalls are a good choice for. No one is 266 00:28:16,583 --> 00:28:21,750 doing this kind of attack, but if it happened, application firewalls would be a good 267 00:28:21,750 --> 00:28:28,208 choice, like SELinux to segment the applications from each other would be a good choice. I think 268 00:28:28,208 --> 00:28:31,458 application firewalls performance because you have to inspect packets as they go out 269 00:28:31,458 --> 00:28:37,750 saying hey, does this meet all of the rules. That will slow you down, I think encrypting the 270 00:28:37,750 --> 00:28:43,750 cookies, the master password is a decent idea. I have not seen discussion of that. I know 271 00:28:45,750 --> 00:28:51,833 chrome said this is not a good idea, it is not really extra security. If someone is on your 272 00:28:51,833 --> 00:28:55,667 machine, you're in trouble anyway. We don't want to give you a false illusion if someone 273 00:28:55,667 --> 00:28:59,833 is on your machine your are going to be ok because you have a password; a master password 274 00:28:59,833 --> 00:29:04,875 for your passwords. That's why they didn't implement that in chrome as far as I know. So ‑‑ 275 00:29:04,875 --> 00:29:10,875 um ‑‑ but I think a master password for cookies is decent. So question is how can you help 276 00:29:24,583 --> 00:29:30,583 the client be as secure as possible with cookies as a developer? So sending cookies as 277 00:29:32,708 --> 00:29:37,500 secure and HTML only, you don't need the java script to read it, they are accessible from 278 00:29:37,500 --> 00:29:43,500 JavaScript. That is the thing that everyone should be doing all of the time. HTPS versus 279 00:29:45,667 --> 00:29:52,000 HTP. If you have any login or any sensitive information, you definately want to use HTPS. 280 00:29:52,000 --> 00:29:58,000 There are a couple of older attacks sniffing Wi‑Fi on the network. And a cookie going HTP 281 00:30:00,042 --> 00:30:06,042 you can sniff the cookie and steal it that way, that is fairly well known. Using HTTPS 282 00:30:08,458 --> 00:30:14,458 and sending you cookies HTP only and secure and using HTTPS are sort of the fundamental things 283 00:30:27,000 --> 00:30:33,000 you can do. Everything more is that browser‑implementer level. So I thought about that. The 284 00:30:38,458 --> 00:30:42,833 question is, has someone thought about going down a layer to the Mac address rather then time the 285 00:30:42,833 --> 00:30:47,750 session cookie to the IP tying it to the mac address. I think there are two problems. One is 286 00:30:47,750 --> 00:30:52,375 if you are just a web server listening the cookies are mostly set at the web server level. You 287 00:30:52,375 --> 00:30:58,875 don't want to try to read the packets as they come in for Mac addresses. The more fundamental 288 00:30:58,875 --> 00:31:02,125 thing is that someone on your computer is sniffing a Mac address and spoof it when they 289 00:31:02,125 --> 00:31:08,417 are trying to login as you from another machine. They can render commands to read the Mac address 290 00:31:08,417 --> 00:31:12,917 that you're using now, possibly try it with multiple interfaces if your computer has ethernet 291 00:31:12,917 --> 00:31:18,917 and wi-fi and then spoof it later. So I don't think that will protect you. So the 292 00:31:46,667 --> 00:31:52,042 question is, if a cookie is used multiple times, is there a way for the server to know it is two 293 00:31:52,042 --> 00:31:58,500 different sessions? And ‑‑ I think the IP way is one, unless you are the same network, and 294 00:31:58,500 --> 00:32:04,500 then it just looks like the same IP and the host, but ‑‑ right now I think most sites just look 295 00:32:07,000 --> 00:32:12,208 for the same session and it looks like one user because what happens is you log in and get 296 00:32:12,208 --> 00:32:15,917 the cookie back. You log in again and get the different cookie back. If you use the same 297 00:32:15,917 --> 00:32:21,917 cookie it is the same entry in the session store usually in the database. I think. Anyone else? 298 00:32:38,625 --> 00:32:43,250 Question is, can cookies from the client extend their expiration date. The answer is 299 00:32:43,250 --> 00:32:49,875 usually it is set on the server. You would not want people be able to steal them and to extend 300 00:32:49,875 --> 00:32:53,750 them like that. I haven't seen any applications are like, when you log in, do you want to stay 301 00:32:53,750 --> 00:32:59,750 logged in for two weeks, four weeks or a year. I haven't seen that. Yeah. Are we done? Okay. 302 00:33:07,208 --> 00:33:12,417 Thanks guys. [ Applause ] "This text is being provided in a rough draft format.  303 00:33:12,417 --> 00:33:16,208 Communication Access Realtime Translation (CART) is provided in order to facilitate 304 00:33:16,208 --> 00:33:20,708 communication accessibility and may not be a totally verbatim record of the proceedings."