A warm DEF CON welcome for Ian Foster and Dylan Avery, or Avery? Avery. Avery, sorry. Lost and found certificates. So, just as a quick introduction, as mentioned, this is Ian. He's a motorcycle hobbyist and DNS nerd. And this is Dylan, electrical bike enthusiast and cat owner. Did you say cat owner? Yeah. It's true, though. So, basically, the problem that we're going to be talking about today is what happens when an SSL certificate from a previous owner is still valid for the next owner of the domain. So, the previous owner gets a real SSL certificate that they're allowed to do for their domain. The domain either expires or transfers ownership. And then the new owner of the domain, they maybe don't realize that the previous owner still has a valid SSL certificate. And prior to 2013, there was really no way whatsoever to get any visibility of this. And really, like, when you think about it, it seems kind of silly that this is even an issue. Yeah. So, the example we have here at the bottom, we say, like, Alice registers a domain name, in this case, foo.com, for one year and gets an SSL certificate, in this case, three years, more than the one-year domain name, our registration. foo.com gets unregistered because Alice doesn't renew it. And then Bob later registers foo.com, gets his own SSL certificate, completely unaware that Alice is SSL. So, in order to help try to identify these certificates, we have certificate transparency. This was created as a publicly auditable log of all SSL certificates to help catch misbehaving certificate authorities. It's currently about half a billion certificates and growing. And basically, we can use certificate transparency to identify this issue, which gives us way more visibility than we had before. So, basically... So, basically, if the previous owner has an SSL certificate and it gets logged in CT, we can see it, and we know from that that there are still certificates for our domain that we don't have control of. So, we looked for, like, really notable examples of this, and we were able to find some. One particular example is for Stripe. So, if you're not familiar with Stripe, they're a really big online payment processor. And a large percentage of transactions that you may have conducted online... ...on e-commerce websites may have actually used Stripe under the hood. What we found was that the previous owner of Stripe.com still had a valid SSL certificate when Stripe bought it. And now, the crossover was relatively short, but it didn't have to be. It could have been a five-year cert. It could have been all the way up to today. So, we tried to set out to figure out how big is this issue. So, we searched certificate transparency to look for certificates that overlapped multiple domain ownerships or arbitrations. And the hard part... ...of this is trying to figure out when a domain name changed hands. There's no easy way of doing this. The best way we could look at was historical whois, historical nameservers, and the Wayback Machine. And we surveyed three million random domain names from the internet. And they're associated with 7.7 million certificates, which makes up just about 1% of the entire internet. So, it's a fairly small study, which should give a general idea of what the whole entire internet looks like. And we looked for changes like expiration date, email, contacts, registrar changes... ...to try to determine whether or not a domain name has changed hands or not. And this type of analysis... ...is not perfect. There are both false negatives and false positives. But it should still give us a good idea of what we're looking at. And we found that on our data set, about 40.45% of the domain names had pre-existing SSL certificates. Which, extrapolated to the internet, is about 1.5 million domain names. And of the certificates for these 1.5 million domain names, about 25% have not expired and are still valid right now. And so, we were calling this problem bygone SSL. Which is, we were defining as... ...a certificate created before and supersedes its domain's current registration date. This is just another way of saying that the SSL certificates bans multiple domain name registrations. So, could this be any worse? So, as many of you might know, a certificate can be valid for multiple domain names. In this case, we have a certificate for both foo.com and bar.com. And a certificate can be good for domain names that may have changed ownership... ...and some of the domain names may have not changed ownership. In this example, bar.com has always had the same owner... ...and foo.com may have changed ownership. But the domain names may have changed ownership one or more times during the existence of this certificate. So, if it's not immediately clear, a lot of CDNs will actually shove a whole bunch of customers on the same cert. And in this kind of extreme case, we found one instance of a CDN putting 700 of their customers on a single certificate. And we've made the decision to blur this out because this is still a valid issue. But if we were to show the domains used on the certificate, I promise everyone in this audience would recognize some of them. And what we found is that... ...the one unblurred domain there was actually currently unregistered and expired. And it was available for purchase. So, basically, we have two options here of whether or not we can revoke these certificates. You know, the question is like, should we have the right to revoke these certificates? If you say no, then you can imagine shelling out a whole bunch of money for a new domain, maybe for your new startup. And you find that there's an old SSL certificate in CT that's going to last for another five years. You just can't do anything about it. You just have to live with that fact. You can imagine a scenario where a bad guy might squat on a whole bunch of desirable-looking domains and just selectively only give them out to e-commerce websites so that they could maintain SSL certificates and be the man in the middle of that traffic and steal financial data. On the other hand, if we say yes, if you can revoke these certificates, you get these situations where certificates have both bygone domains on them and non-bygone domains on them. A lot of cases are still used in production. And if you give the new owner the right to revoke these certificates, then all of a sudden they have the power to denial of service the websites that are still using that certificate for legitimate reasons. So it's really a lose-lose scenario. So we dug a little deeper and we learned about the CA and browser form. And this is a group of people made up of representatives from both web browsers and certificate authorities who create the baseline requirements for the issuance and management of public certificate certificates, which is just a long document that specifies how CAs and browsers should operate so that the certificate authorities can be trusted by the web browsers. And inside this very long document, in section 963, subsection 5, it talks about revocation and the reporting of revocation. And it does specify that if any information in a certificate becomes inaccurate or incorrect, that the certificate authority must revoke the certificate. So, like, on the previous slide, like, inaccurate, that's kind of an ambiguous term. Like... We found this other section, though, 4.9.111, and this one, in my opinion, is a lot more explicit. It basically says if the domain name registrant fails to renew the domain name, then if the certificate authority becomes made aware of that, that certificate authority has to revoke the certificate within 24 hours. Now, we're caveating this with the fact that we were warned by CAV members that this document is very ambiguous and sometimes self-contradictory. The people that draft this document, oftentimes lawyers, not actually engineers. That being said, to the best of our knowledge, we have the right and the power to revoke these certificates, and we have the power to do so within 24 hours. So, going back to the previous example of the certificate for food.com, bar.com, where one domain name has changed owners and one has not, this now means that if bar.com is still using the certificate that was valid for food.com, bar.com, the new owner of food.com could reach out to bar.com's certificate authority and revoke their certificate and cause a denial of service on them, or at least their users will get an SSL warning. And so, looking at cases of this where domain names share a certificate with other domain names that have changed ownership, that number skyrockets or goes up four times, increased up to 7 million domain names on the internet are potentially affected, about 2%. And of this sample set, about 41%, just under half, still haven't expired and are still valid and potentially still being used. So, I mean, at this point, Ian and I are realizing we can break stuff, like a lot of stuff. Ian and I had the power to revoke something like 3 million certificates, and the CAs had a legal obligation to do so within 24 hours. And most of those certificates, well, I shouldn't say most, a lot of those certificates were still being used in production. So, it would have broken all kinds of websites, all kinds of places. A lot of the websites are definitely ones that you all are familiar with. And so, we thought that this basically, there's no real clean fix to this. So, we have to just introduce a new class of vulnerability. And there's two flavors to this. The first flavor is the one that we first introduced. It's when you get a new domain and you notice or don't notice, you see in the CT log, that the previous owner still happens to have a valid SSL certificate. We're calling that variant the bygone SSL man-in-the-middle variant. And the other type is the type I was just talking about, which is the bygone SSL denial of service, where you share a certificate and are still using it with an alt name, which is expired or been acquired by someone else. And that gives them the power to remove the certificate that you're using. And if they were to do that, that would take down your site. So, if you remember back from a couple of slides ago, there was that CDN that showed 700 customers on one cert. We now realize that if we bought that domain and reached out to the certificate authority, we could say, hey, the previous domain owner failed the certificate, we have to renew, you have to revoke this thing. And we now have the power to revoke it and break 700 customers' websites. Now, for our demo, I'm going to be tabbing over to an email client and in real time revoking this cert. Not really. But we totally have the power to do that. So, for our pre-recorded demo, we have a couple of certs here that we did reach out to the certificate authorities just to see whether or not they would actually revoke them. And so, for the first example here on the left for DigiCert, I should mention this cert had a subject alt name on it and the subject alt name was using that certificate in production. We reached out, we said, hey, one of the domains on this certificate belongs to us. Can you please revoke this cert? And the way we framed the email, it seemed like we didn't own the other domain. And within 24 hours, DigiCert verified that we did own the one domain, didn't verify that we owned the other domain, they had no problem revoking the cert. So, another example here, we reached out to Amazon. And I should mention also, usually certificates have a little field on them called the CPS contact. And the CPS contact is basically the email contact you want to reach out when you want to revoke the certificate. That's the contact that starts the 24-hour timer when you reach out to that. So, we did that for DigiCert. For Amazon, they actually didn't have a CPS contact on their certificate. And it's kind of hard to reach out to AWS if there's not, if you're not like a customer. So, we tried to do this the best we can without actually creating an AWS account. And we found this public email, ec2abuse.amazon.com. And that's the one we reached out to. It took a little bit of back and forth and a little bit of routing. But eventually, that got us to the right certificate people. It took a couple of weeks, but again, they had no problem revoking the certificate for us. So, this is our pre-recorded demo that failed. We reached out to Komodo. And same thing, we reached out to the CPS contact. Asked them to revoke the certificate. And to this day, they still haven't revoked the certificate. They basically said, you're not the original owner. Like, you didn't generate that certificate. We're not going to pay attention to you at all. And on the bottom there, you can see they actually tried to use it as an upselling opportunity. Saying, forget about the old certificate. We'll sell you a shiny new one. You just forget about the one that the previous owner still has. So, next we tried the revoked certificates using Let's Encrypt, which is a slightly different type of certificate authority. They use the Acme protocol to try to automate as much as they can with no human interaction. And currently, if you use the Acme protocol to try to revoke a certificate, they require you to prove ownership of every domain name in the certificate in order to actually have the revocation happen. So, we reached out to their CPS contact and asked them about this. And they specified that this is their current policy, that they require you to prove ownership of all domain names in the certificate to revoke. And recognize that it is a slight conflict with the CA browser form. And that they are currently considering a change of policy to prevent this from happening. There might exist a case where someone has a certificate for a domain name that you might have that domain name for because you lost the domain name required from them. So, currently with Let's Encrypt, we were not able to revoke this certificate. But it could be possible in the future. And if Let's Encrypt implements that, it's also worth pointing out that that will be real-time replication. It won't be like 24 hours while the CA reaches out kind of thing. Because their whole system is real-time automated, if you use Let's Encrypt and one of your domains on your cert becomes bygone, instantly somebody on the internet will be able to revoke your certificate. Very true. So now I'd like to talk a little about CertGraph. This is a tool I made a while ago. It's an open source intelligence gathering tool that crawls the graph of certificate alt names. It works by you give it a domain name, it finds all the SL certificates for that domain name, goes through, gets all the alt names of all the certs, gets all the certificates for all those alt names, and continues to grow and grow until you get a complete graph of all domain names and certificates for a given domain name or property. It was built with the idea of domain name enumeration for Red Team targets, but it's very useful for trying to find vulnerable domain names for bygone and settled denial of service as well. This is an example of a graph generated with this tool on the EFS website. So one particular example where we found this was at Salesforce. So we ran this on Salesforce.com and created this nice graph and we ended up at Squarespace.com, which is nothing new to Salesforce. And this was because Salesforce.com used to own do.com, lost that domain name somehow, Squarespace got it, not sure if it expired. But they kept in the Salesforce.com SSL certificate, the one that red dot in the center of the circle of green on the left, that SSL certificate was good for do.com. It was good for do.com far after they owned it and after Squarespace had it. So Salesforce had a valid SSL certificate for another company at this time. And this gives one, Salesforce, the ability to potentially in the middle of Squarespace.com and also Squarespace.com could have revoked Salesforce's SSL certificate taking down their site. And if you look on the left side, all those like green encircled domains around that certificate, those are all of the websites that would all of a sudden break if Squarespace decided to revoke this thing within 24 hours. Yeah. So this is digging a little deeper into the do.com example. We can see on the right is the certificate in question. The top part we have in red, the dates that it was valid before and after. You can see there's between the two different owners and all the domain names of those valid for Salesforce and do.com. And on the left, we have historical and S lookups for this domain name. The screenshot was taken after the domain name had been transferred to where it currently is right now. I believe it's like a for sale auction site. Someone else can go buy that domain name if they want. But on the circled red part is when Salesforce had the domain name in the past. You can see historical name services being hosted at Microsoft, AWS, and a few other places as well. So we wanted to also introduce a tool specifically crafted for finding this. So CertGraph is a nice visualization tool. We created a new tool. That uses the Facebook Certificate Transparency API to both detect bygone SSL denial of service and bygone SSL man-in-the-middle. Now that's caveated with the fact that you have to give it accurate information. So to detect bygone SSL man-in-the-middle, you need to give it the list of all domains you own with an accurate date on when you first registered it. So maybe you renewed it a couple times, and the created date on the Whois record doesn't actually reflect the first time you created it. You need to make sure that actually reflects the first time you bought the domain. And then to detect bygone SSL man-in-the-middle, you give it a list of all domains that you own, and it will go through and see if any of those domains share certificates with domains that you don't own. So for this to be accurate, you need to give it a complete list of all domains you own. As long as you do those two things, have an accurate registration date, and a complete list of all domains you own, you don't get any false positives, and it can very accurately detect both flavors of the problem. The two downsides to using this tool, first, you have to create a Facebook developer account and give them the token. And the second downside is Facebook actually will rate limit you if you hit it too aggressively. And lastly, we've created another tool, the bygone SSL certificate transparency log monitor, and this acts as a certificate transparency actual log. We use certain... SSLmates search bar tool and added in bygone SSL detection to that, so you create a config file for the domain names for the certificates you want to be alerted for, specify a valid app date, which is the date that you acquired the domain name, and then whenever it finds a matching shirt, it'll print out or notify you the following information like in the screenshot right here. And if it happens to notice that the certificate is valid both before and after the date that you acquired it, it puts this little bygone SSL equals true flag, and those changes have been accepted upstream into SSLmates search bar, so you can grab that from them if you want to run your own certificate transparency log monitor. Although note that we'll look through all the half a billion certificates in CT, and it will take some time, but if you want a completely self-hosted solution, this will work great. So if you want to try to protect yourself from being vulnerable from bygone SSL or someone else having a SSL certificate for your domain name or potentially revoking one that you're using, the best you can do right now is to use the expect CT header with the enforce flag on your HTTP server. This will protect you from someone else having a SSL certificate for your domain name that's not in CT and using it on you. However, this will not protect you if the case for the certificate has already been logged in CT. There is no current protection against that. The best thing you can do is monitor CT logs using our tools or others for all SSL certificates for your own domain names, and if you see a certificate for your domain name either issued before you got it or after, reach out to the CA and ask them to revoke it. And I should also point out that not all certificates will be in CT logs. CT was only required for browsers like Chrome as of April, which is the first level this year for non-EP certificates. Certificates issued before then, a lot of them are in there. I've seen certificates as early as 2009 and before in certificate transparency logs, but it's not a requirement to be trusted by browsers. So now we've got some requests for the general internet as well. We realize this issue isn't going away. We have some basically band-aid asks. So for example, registrars could notify new, when you first register a domain name, the registrar gives you a heads up and say, hey, we checked CT and the previous owner still has a valid certificate. They might even also consider auto revocation in certain cases. Another ask is if these certificates are much shorter lived, like the let's encrypt 90 day policy. The issue is still there, but it's there for a shorter period of time. We don't have to deal with the five year issue that we talked about before. When you do your revocation, it's kind of courteous to give a heads up to the other people using certificates with subject alt names so you don't accidentally break production websites. But as mentioned before, there's no mechanism stopping you from breaking a production website. And CAs could also not issue certificates that go on beyond the expiration date of the domain. So if you do who is on the domain, you see the expiration date. There's no reason why the certificate should ever outlive that. So CAs could just not issue certs that outlive the lifetime of the domain. And then the last bullet point here is really targeted at CDNs specifically, but also just generally companies. You've got to be really careful with the way you use subject alt names. If you shove a whole bunch of domains on the same certificate, in kind of the worst case there, 700, one of them might become expired. And that's going to open yourself up to a stranger revoking your certificate. So a recommendation there is kind of, you could do what GitHub is doing with GitHub pages. They have every single customer on their own. Let's encrypt cert if you use a custom domain. But if you share customers on the same cert, you're opening yourself up. All right, that concludes our talk. Here are the links to the tools that we talked about and our Insecure Design website where we have more information on this topic. Thank you all very much. And we'll take questions outside.