Latest / Talk Python To Me / #136: Secure code lessons from Have I Been Pwned
Transcript
- 0:00Do you run any code that listens on an open port on the internet?
- 0:03This could be a website, a RESTful web service, or GASP even, a database endpoint.
- 0:08Troy Hunt, a renowned security expert, likes to say that you're doing free penetration testing for that product right there.
- 0:14Join Troy and me on this episode of Talk Python To Me.
- 0:17We discuss lessons learned from running the vulnerability monitoring website Have I Been Pwned,
- 0:22as well as other lessons for developers to keep your code safe while providing public services.
- 0:26This is episode 136, recorded October 26, 2017.
- 0:32Welcome to Talk Python To Me, a weekly podcast on Python, the language, the libraries, the ecosystem, and the personalities.
- 0:52This is your host, Michael Kennedy.
- 0:55Follow me on Twitter, where I'm @mkennedy.
- 0:56Keep up with the show and listen to past episodes at talkpython.fm, and follow the show on Twitter via at Talk Python.
- 1:03This episode has been sponsored by Rollbar and GoCD.
- 1:07Thank them both for supporting the podcast by checking out what they're offering during their segments.
- 1:13Troy, welcome to Talk Python.
- 1:15Hey, thank you very much for having me.
- 1:16Yeah, it's really great to have you on as a guest.
- 1:19I've respected the work you've done in the security space immensely, and I'm looking forward to sharing what you've learned about software security and developers with the audience.
- 1:28Cool. Awesome. Let's do it.
- 1:29Yeah, let's do it.
- 1:30Now, before we get into all the details, let's start with how you got into programming in the first place.
- 1:34What's your story?
- 1:34That's a good question.
- 1:36So I was a little bit anti-computer when I was a kid, probably up until about teenage years.
- 1:43And I was actually very frustrated by my friends who'd be inside on the computer.
- 1:46I'm like, come on, man.
- 1:47I want to go outside and play football or something like that.
- 1:50What are you nerds doing?
- 1:52And then I guess I got into it by, I moved overseas when I was a kid.
- 1:57So this was when I was almost 14.
- 1:59My family moved to the Netherlands.
- 2:01And it's kind of cold over there.
- 2:04And like you get into it.
- 2:05A lot of dark evenings.
- 2:06The sun goes down to what, like 2.30?
- 2:08Yeah, well, this is a little later, man.
- 2:10No, just kidding.
- 2:10Yeah, yeah.
- 2:11But it gets, it's pretty dark in the winter there, right?
- 2:13It is.
- 2:14I mean, for folks in the UK, it's basically like the UK.
- 2:17But, well, I won't say something derogatory about the UK.
- 2:20You can read my Twitter feed for that.
- 2:21No, we love them, honestly.
- 2:22So anyway, there's a lot of time spent indoors.
- 2:25And I just started getting involved.
- 2:26I think I must have started doing a bit of basic back then.
- 2:29So this would have been sort of early 90s as well.
- 2:31And I think really for me, though, so I was doing a bunch of sort of PC-related stuff in
- 2:37my teenage years and doing part-time jobs at PC repair stores and that sort of thing.
- 2:41But the thing that really hooked me was seeing the web.
- 2:44So I started using the web in 95 when I started uni.
- 2:48And it was just like, wow, this is awesome.
- 2:50This is amazing.
- 2:51I want to build stuff for this.
- 2:52And really, that was the start of modern day life as I know it in terms of what I do.
- 2:56That's awesome.
- 2:57Yeah, I had the same experience.
- 2:59I was a sophomore or junior at university when the Mozilla?
- 3:04What was the first before Netscape?
- 3:06Before Netscape?
- 3:07Yeah.
- 3:07Something very real.
- 3:08Mosaic.
- 3:08Oh, Mosaic.
- 3:10Yeah.
- 3:10Yes.
- 3:11When Mosaic came out.
- 3:12And I was just like, oh, my gosh.
- 3:14Like, the entire world opened up.
- 3:17It was such an amazing time.
- 3:18And it seemed like it's funny because technology was so much more limited.
- 3:22And what you can do on the web now is way more impressive.
- 3:24But the world seemed so open back then, right?
- 3:27Yeah, yeah.
- 3:28I don't want to reminisce in so far as, oh, so awesome, McMahon.
- 3:31Because frankly, it's so awesome now.
- 3:32And it's really a lot more awesome by any reasonable measure.
- 3:35Yeah, for sure.
- 3:36But it was just an exciting time where we're sort of seeing stuff that didn't even resemble
- 3:41the things that we'd done before.
- 3:42Yeah, I had the same feel.
- 3:43And that was awesome.
- 3:44So now, what do you do day to day?
- 3:47More stuff on the web?
- 3:48More stuff with security?
- 3:49Yeah.
- 3:50So look, it's a bit of both.
- 3:52It's funny.
- 3:52In fact, I've been thinking the last couple of days because I've had, I don't want to say
- 3:55downtime, but I haven't been rushing somewhere.
- 3:57And I was sort of going, what am I going to do today?
- 4:00Like, I'm entirely independent, so I can do pretty much whatever I want.
- 4:05And that consists of sort of several main things.
- 4:08So I still do a lot of traveling and speaking at conferences.
- 4:11I'm trying to do less of the traveling just because of how much I've been away.
- 4:15But I'm still doing a lot of that.
- 4:17I'm still doing a lot of workshops.
- 4:19I was down interstate last week doing a workshop.
- 4:22I think I've probably done this same workshop.
- 4:24I must have done it 25 times this year.
- 4:2625 two-day events.
- 4:28The workshop is Hack Yourself First.
- 4:31So I usually go into, say last week it was into a large financial institution and then
- 4:37another online retailer.
- 4:38And I'll go in there for two days and I'll sit down with usually developers, but also regularly
- 4:44project management or managers, QA people, DBA, security folks, and go, okay, let's spend
- 4:51two days figuring out the mechanics of things like SQL injection and cross-site scripting.
- 4:56Here's how they work.
- 4:57Here's what you do to be resilient to them.
- 4:58And it's very, very sort of hands-on, active sort of stuff.
- 5:02And it's just like, it's a huge amount of fun for everyone because we get to go in and break
- 5:06stuff in ways that they've never been able to before.
- 5:08And everyone leaves with this sort of new appreciation of the mechanics of how these
- 5:12attacks work.
- 5:14And they end up building better software for it, which is a good win.
- 5:17Yeah, it's definitely a great win.
- 5:18And I think sometimes you just have to see these things in action to really appreciate how your
- 5:24security and the code you're writing is not actually secure.
- 5:27I mean, even something as sort of old school as SQL injection attacks, like when you first
- 5:32start writing SQL strings, you're like, well, I need to put the variable here.
- 5:35So plus, plus quote thing, you know, how could that be wrong?
- 5:38Right?
- 5:38It just works.
- 5:39But I think totally seeing it go, oh my gosh, do we do that?
- 5:43Because if we do that, I just see how horrible this is going to be.
- 5:45That's it.
- 5:46It's the hands-on, you know.
- 5:47It's like the light bulb moments when people do that.
- 5:50And SQL injection is a great example because, you know, like you said, it's something that's
- 5:54been around for a long time.
- 5:55And we sort of think of this as an old thing.
- 5:57It's still number one in the OWASP top 10 most critical web app security risks.
- 6:01You know, it's still up there, even in their 2017 revised edition, it's still number one.
- 6:06And when I do the workshop and I demonstrate SQL injection, I show things like there's a blog post
- 6:12I refer to written by a guy who's trying to teach people how to do password resets in
- 6:16ASP.net.
- 6:17And literally within the one screen, he's got good, resilient, parameterized SQL statements.
- 6:23And we're looking at this going, is this okay?
- 6:25Yeah, yeah, it's okay.
- 6:26Because you've got parameterization.
- 6:27And then like the next line, there's an update statement.
- 6:30And it's just like inline concatenated SQL with untrusted data that you can totally own.
- 6:35And then he connects to the database with a privileged account.
- 6:37And it's like, yep, good night.
- 6:39Like the whole thing's over.
- 6:39And there's still material, new material out there teaching people that.
- 6:43And here's another fun one.
- 6:45You can go and do, and be careful with this, folks, if you go and do this.
- 6:48You can go to Google and do a Google Doc search.
- 6:51So one of these sort of searches that turn up things that aren't really meant to be there.
- 6:55And you can do a search for inurl.php?id equals.
- 7:00And I think about the first half a dozen results have got an integer somewhere in a query string.
- 7:05You load the page up.
- 7:07You put an apostrophe on the end of it.
- 7:08And bang, there's an internal SQL exception.
- 7:10So very, very high likelihood of having a SQL injection risk.
- 7:14And this sort of stuff is just absolutely rampant.
- 7:17Yeah, that's really scary.
- 7:18Why do you think it still is a problem?
- 7:21I mean, it's 2017.
- 7:23We've got ORMs and ODMs that generally protect us against these things.
- 7:28We've got an XKCD, Little Bobby Table.
- 7:31I know.
- 7:32If that doesn't teach people the lesson, I don't know what will.
- 7:34We've had it for years.
- 7:35I got him on a T-shirt, actually.
- 7:37I used to wear it at conferences.
- 7:38People love it.
- 7:39Oh, that's wonderful.
- 7:39I'll have to put a link to that in the show notes.
- 7:41So why does this all happen?
- 7:44I think there are multiple factors.
- 7:46So, you know, I just gave one example.
- 7:48People are still creating training material that's vulnerable.
- 7:51And in fact, one of the reasons why I show this blog post is that I actually left the
- 7:55guy a really nice comment.
- 7:56And I literally said, here's some friendly feedback.
- 7:59And being very constructive, I gave him this feedback.
- 8:02It's just like the comment sitting there.
- 8:03The guy's never replied.
- 8:05And then after that, there's been a whole bunch of people that have chimed in and said,
- 8:08thank you.
- 8:09This is very useful.
- 8:10And I'm going, didn't you just read like the big, long, friendly comment from the Australian
- 8:14guy saying like, this is really just full of holes.
- 8:17Don't do this.
- 8:17So we see this propagate over and over and over again.
- 8:22And ultimately, so many of these risks just fundamentally boil down to the people building the software
- 8:28and not being familiar with how something like SQL injection works.
- 8:31And that is just purely a competency issue.
- 8:33Yeah.
- 8:33I guess that part of it is like you kind of hinted at the copy and paste stack overflow
- 8:37type of thing.
- 8:38Although I suspect it would take a pretty good beating on stack overflow.
- 8:41But you know, this copy and paste sort of thing.
- 8:44And we have so, our technology and languages and libraries we use changes so quickly that
- 8:50people are, I think a lot of people are just scrambling to keep up to make things work,
- 8:54much less be secure.
- 8:55So that the copy and paste thing is funny.
- 8:57In January last year, I was running the workshop we just spoke about in Norway.
- 9:02And part of this workshop, there's a module on looking at mobile APIs.
- 9:06And one of the guys in my workshop says, all right, look, I want to look at the way the
- 9:12app for my Nissan Leaf, or in the US you'd say Nissan, the car.
- 9:17So the way my car.
- 9:19Yeah.
- 9:20So, okay.
- 9:21How does my app talk to my car?
- 9:23Because he could control features of the car from the app.
- 9:27Now, this is not something we have a problem with in Australia, but apparently in some parts
- 9:31of the world, it is so cold, you've got to turn your car on before you get in the car,
- 9:35you know, like turn the heating on.
- 9:36And this is one of the things I have to do in Norway because it's so freaking cold there.
- 9:39So he's like, all right, pulls out his app and he's figuring it out.
- 9:42And what he discovers is that the only thing that the app needs to know about the car is
- 9:48the car's VIN number.
- 9:49Now, for folks who may not be familiar with what a VIN number is, first of all, this was
- 9:53being used like an API key.
- 9:55It was a secret.
- 9:55Second of all, it was printed in the windscreen of every car.
- 9:58So you could literally walk past a car and it had its API key in the windscreen.
- 10:03And it was worse than that too, because they're innumerable.
- 10:05So you can just take the, in this case, I think we could take about the last five digits and
- 10:10just keep randomizing numbers and finding different cars.
- 10:13And based on what he found in the space of literally sort of single digit minutes, we
- 10:18discovered that you could control our climate control features of the car.
- 10:21You could pull back trip history, battery status, all sorts of things.
- 10:24It was just crazy.
- 10:24Shouldn't have happened.
- 10:25That's crazy.
- 10:25And if there's any vulnerabilities, you can, you're like, you can own the car basically,
- 10:29right?
- 10:29Because you're talking to it.
- 10:30Yeah, God knows.
- 10:32You know what I mean?
- 10:32And when we say you're talking to the car, let's be clear.
- 10:35You're talking to, you're basically talking to a web server and not a web server in a car.
- 10:39We can come back to the things people put web servers in later.
- 10:41You're talking to a web server on the web running an API.
- 10:44And then that goes back end over some proprietary GSM network or something to the vehicle itself.
- 10:49So there is a proxy in between.
- 10:51Yeah, that's not too bad then, I guess.
- 10:53Well, so here's where it kind of went worse.
- 10:55I disclosed it to Nissan and we had chats on the phone and, you know, they were like, yeah,
- 11:00we probably should fix this.
- 11:01Yes, you probably should fix this.
- 11:02And then time goes by and they're not fixing it.
- 11:05And eventually we get to like a month after disclosure and they've stopped replying to messages
- 11:10and nothing's happening.
- 11:11So I write about it and then suddenly they decide it's important.
- 11:14So they take the whole thing offline.
- 11:16And it's offline for about six weeks and eventually it comes back online and they've got a new app and everything.
- 11:21The funny thing about the app, and this is the relevancy to Stack Overflow and code reuse,
- 11:26is that down the bottom of one of the screens there's this really odd text.
- 11:31And the text is something like,
- 11:33the spirit of Stack Overflow is developers helping developers.
- 11:36And this isn't an app for your car.
- 11:38And we're looking at this going, what are you doing?
- 11:41Why would you put that in there?
- 11:42And then, of course, we found the Stack Overflow post where they've literally copied and pasted the text from the Stack Overflow post without understanding what it does.
- 11:50Put it in the app that controls features of your car.
- 11:52That's incredible.
- 11:53Honestly, folks, if you Google for this, Google like,
- 11:57Nissan Stack Overflow code reuse, and it's just like, this is insane.
- 12:00How does this happen?
- 12:01I mean, how does this happen at all, let alone in a car or software to control a car?
- 12:06Yeah, I feel like the companies that have these types of IoT-like things that are really valuable, you know, not a light bulb, but cars and humans travel in them at high dangerous speeds.
- 12:18They should really be careful about this, right?
- 12:19Yeah, they probably should.
- 12:20They probably should.
- 12:22Maybe you should send them an email about that or a bunch.
- 12:25Yeah, well, afterwards, they were like, if you find any other stuff, please do send us an email.
- 12:30I sent you an email.
- 12:30We had phone conversations.
- 12:32You were endorsed.
- 12:33What happened?
- 12:33Anyway.
- 12:34Wow.
- 12:36So, do you know if any of these car companies run bug bounty type things?
- 12:39Yeah, no, Tesla does.
- 12:40In fact, Tesla runs a bug bounty through Bug Crowd.
- 12:43Bug Crowd is a bug bounty as a service platform started by a mate of mine who's done extremely well moving over to the U.S. and getting funded and doing wonderful things.
- 12:54And bug bounties are becoming absolutely massive now.
- 12:57It's great to see him doing well, but it's great to see this being a big thing in the industry now as well.
- 13:02Yeah, I totally think it's a very positive thing.
- 13:04I suspect most people listening to know what bug bounties are, but maybe just define it for everyone.
- 13:08Yeah, so a bug bounty is effectively acknowledging that maybe the right way to put this is everyone who has anything online is continually getting free penetration tests.
- 13:18So, there are always people out there probing away at your things.
- 13:21And a bug bounty is a means of saying to people, look, if you find vulnerabilities in our software, if you find things that could be dangerous, like SQL injection, submit them here.
- 13:31And there's usually a formal process.
- 13:34You know, this is the email address to send it to.
- 13:36This is the information we need.
- 13:37Here's how to encrypt your communications.
- 13:39And then, depending on the vulnerability, you may be incentivized.
- 13:42So, you may actually get anything from a T-shirt to a large amount of money.
- 13:45And this is a really neat way of recognizing that we do have flaws in software.
- 13:51This is the nature of building software.
- 13:53And that if someone finds it, it is actually worth something.
- 13:55And the sort of value proposition of the bug bounty is that it incentivizes people to report these things responsibly and allows the organization to handle them and fix them before someone actually goes and exploits nasty things.
- 14:07And obviously, there's some incentivization for that in a monetary sense.
- 14:11And these are becoming really big.
- 14:13So, you know, we mentioned Tesla.
- 14:14The Pentagon has run a bug bounty.
- 14:16Like, these are going really, really mainstream.
- 14:19And there's a lot more to it than just some random hackers sitting in a basement on the other side of the world trying to break into your things as well.
- 14:24They can be very, very carefully managed programs with well-selected testers.
- 14:28Yeah.
- 14:29Like, the Pentagon one, you had to kind of interview and be approved to be part of it.
- 14:33It wasn't just, now everybody go forth and attack the site, right?
- 14:36You couldn't be Australian either or anything else that wasn't American, as I understand it.
- 14:40That's unfortunate.
- 14:42Well, you know, like, it's the freaking Pentagon.
- 14:44Like, I kind of get that.
- 14:46And frankly, just the fact that they ran that and it became such a more mainstream thing that entered into people's psyches in places it just wasn't before, I think is a very positive thing.
- 14:57Yeah, I totally agree.
- 14:57It's a positive thing.
- 14:58And this money can be pretty large.
- 14:59Like you said, it could be a t-shirt, but it could be $100,000.
- 15:02And this incentive has been there recently.
- 15:04Like, if there's not a bug bounty, there's probably some other bad actor who's willing to pay $50,000 for a good O-Day, right?
- 15:11That's the thing.
- 15:12And then we sort of get into this interesting space of who is competing for the dollars of the bugs.
- 15:16And look, some people will argue that there are still actors out there that will pay a lot more than what the organizations with the potential vulnerability will.
- 15:25But then at least you sort of get to have a little bit of weight on the other side of the scales in a monetary sense.
- 15:31And of course, from a legal and an ethical perspective as well, there's always the incentive to try and report things through the formal channels and get money.
- 15:41But yeah, look, there'll always be nefarious parties willing to pay for this stuff as well.
- 15:45Yeah, at least now there's some option to monetize that and make it part of your living and do the right thing.
- 15:50Exactly.
- 15:51Yeah.
- 15:51This portion of Talk Python To Me has been brought to you by Rollbar.
- 15:55One of the frustrating things about being a developer is dealing with errors.
- 15:59Relying on users to report errors, digging through log files, trying to debug issues, or getting millions of alerts just flooding your inbox and ruining your day.
- 16:08With Rollbar's full-stack error monitoring, you get the context, insight, and control you need to find and fix bugs faster.
- 16:15Adding Rollbar to your Python app is as easy as pip install Rollbar.
- 16:19You can start tracking production errors and deployments in eight minutes or less.
- 16:23Are you considering self-hosting tools for security or compliance reasons?
- 16:27Then you should really check out Rollbar's compliant SaaS option.
- 16:31Get advanced security features and meet compliance without the hassle of self-hosting, including HIPAA, ISO 27001, Privacy Shield, and more.
- 16:40They'd love to give you a demo.
- 16:42Give Rollbar a try today.
- 16:43Go to talkpython.fm/Rollbar and check them out.
- 16:48Speaking of looking at breaches and disclosure, you're running a pretty amazing website called Have I Been Pwned that has really grown in terms of awareness for when these breaches happen, right?
- 17:02Tell everyone about Have I Been Pwned.
- 17:04Yeah.
- 17:04Well, Have I Been Pwned has been running almost for four years now.
- 17:08I've got to think about a birthday thing to do, actually, because it will be, I think, late November, early December will be the four-year anniversary.
- 17:14And I started that after the Adobe data breach.
- 17:18So Adobe was about 150 million records from memory.
- 17:21And at that time, I'd been doing some analysis across sort of different data breaches, you know, looking for patterns.
- 17:28Are people using the same password?
- 17:29Well, guess what?
- 17:30Yeah, they are.
- 17:31Are people appearing in multiple different incidents, you know, like the same person?
- 17:34And I was sort of seeing stuff.
- 17:36I thought, like, I find this really interesting.
- 17:38I reckon other people would find it interesting if they could see where they are exposed as well and particularly see things like, you know, you're exposed in these multiple places.
- 17:47So that was sort of the genesis for the project.
- 17:51And I built that out with my 100 and I think it was a total of about 155 million records.
- 17:56So it was basically just about all Adobe when I launched it.
- 18:00And I was like, wow, this is massive.
- 18:01And I was actually, I built it all out on Microsoft's Azure platform as well.
- 18:05And I really wanted to spend time using Azure in anger.
- 18:08So, you know, how can I do something that actually uses a lot of storage?
- 18:13And how can I use things like the table storage construct instead of relational databases to save money and make it go faster and all the rest of it?
- 18:20And that was sort of a bit of a hobby project too.
- 18:23And now sort of fast forward to nearly four years later and there's 4.8 billion accounts in there, which I still find to be a bit of an unfathomable number.
- 18:31That's really incredible.
- 18:33Incredible.
- 18:34That's more than half the population of the earth.
- 18:36I mean, I realize it's not one-to-one person to account, but still, that's staggering.
- 18:41It is crazy.
- 18:41And there's just sort of all sorts of metrics about the project that just exceeded any sort of form of expectation.
- 18:47So that's one of them.
- 18:48The visitor stats, an average day is somewhere between 50,000 and 70,000 people come to the site.
- 18:54A big day is seven figures.
- 18:56So I think I had about 2.8 million in one day the other day.
- 18:59What was the driving factor behind that?
- 19:01That's a good question because there's always a trigger, right?
- 19:04So it's to sort of deviate from that baseline by an order of multiples.
- 19:08In that case, there was this spam bot.
- 19:11So it was called the online spam bot.
- 19:12And a security researcher in France discovered this spam bot where, unfortunately, or fortunately, depending on your perspective, whoever was running the spam bot didn't do a great job of actually securing their data and left 711 million email addresses exposed.
- 19:27So he managed to grab all this data and sent it over to me.
- 19:31And I went, OK, well, let's load 711 million records in here.
- 19:34It's not a breach in the traditional sense, but it is data about individuals redistributed over the Internet.
- 19:40Let's load this.
- 19:42And of course, a huge number of people were then interested in it.
- 19:44And that sort of made a lot of news headlines.
- 19:47And this is the thing that really drives the traffic.
- 19:49It's news headlines because every time there's a data breach, I see a spike because it's on CNN or the BBC or something that faces the masses and not just the tech audiences.
- 20:00So it's sort of really interesting to see how broadly appealing the project has been.
- 20:05Yeah, I think it's a great service.
- 20:06And I've gotten probably five or six emails from your service saying you've appeared in some breach or other.
- 20:13Usually it doesn't freak me out too much because I use one password and my passwords are 40 characters long and they're unique per site.
- 20:21So I hear a lot from people saying they hate getting email from me.
- 20:24So I apologize to everyone that's had an email from me.
- 20:27Don't hate the messenger, right?
- 20:29Come on.
- 20:29Well, exactly, right?
- 20:31Yeah, cool.
- 20:31So the one that really stands out to me that you were pretty well highlighted in, it actually had some interesting ethical components to it, was the Addison Mashley one.
- 20:44Just make it look like you don't know the name.
- 20:46That is a great defense.
- 20:47Well done.
- 20:47Thank you.
- 20:48I've heard of it.
- 20:50Honestly, darling, I've never heard of this site before.
- 20:52I have no idea why my email address is.
- 20:53So this is like an adult friend finder, let's have an affair type of thing.
- 20:57And it got hacked.
- 20:59Because not just people's passwords and possibly reused passwords were leaked, but just the fact that you even existed on the account was a pretty bad data breach.
- 21:07You had to even be a little careful about letting people know or searching for that data, right?
- 21:13Yeah, well, look, I mean, Ashley Madison, just for context for everyone.
- 21:16So this was a data breach that happened in July 2015.
- 21:19And hackers said, hackers, we still don't know who it was, said, look, we've got the Ashley Madison data.
- 21:28These guys, we don't agree with their business model.
- 21:31And OK, many people took an ethical stance on the whole context of this is not like a dating site.
- 21:37It's not like an outright adult site.
- 21:39It is literally their whole MO was helping people have affairs.
- 21:43You know, their strapline used to be life is short, have an affair.
- 21:46So they were, I guess, trying to mainstream adultery.
- 21:49And obviously, a lot of people took issue with that ethically.
- 21:53So whoever it was that got their data, said, look, we got the data.
- 21:57These guys have been bad.
- 21:58We don't like the business model.
- 21:59If they don't shut down in the next month, we're going to dump the data publicly.
- 22:02And this was kind of interesting on many levels.
- 22:06I mean, we do see threats like this, but often we see threats that are more financially motivated.
- 22:10We will see threats that say, you know, give us Bitcoin or we'll dump your data publicly.
- 22:15But in this case, they just obviously took an ethical dislike.
- 22:19And it was kind of interesting as well, because part of the original reasoning was what Ashley Madison did.
- 22:24And this is a this was a real dick movie in anyone's books is they said, look, you know, you sign up to this website.
- 22:30If you want to remove your data, you've got to pay for this full delete service.
- 22:36And from memory, it was about $19 to delete your data.
- 22:38So what would happen is there were a lot of people and I had I had literally hundreds of conversations with people on the site afterwards.
- 22:46And I was learning there are a lot of people who'd maybe have a couple too many red wines one night and go, hey, this might be fun and sign up and then, you know, this wasn't a good idea.
- 22:55And then they'd forget about it.
- 22:57There are a lot of people in there who were single.
- 22:59There are a lot of people who look again, regardless of your ethical position on it, were consenting adults.
- 23:04And they decided they wanted to use the site.
- 23:06And then if they wanted to get off there, they're having to pay money, which is just it's just a reprehensible move.
- 23:11But obviously, they thought they could monetize that.
- 23:13But anyway, one of the things the hacker said, as I said, when you pay for your full delete, you're not actually getting deleted.
- 23:20And what we discovered after we actually saw the data is paying the money would null out your record in the membership table.
- 23:28And then there would be a payment record with a foreign key back to the membership table.
- 23:32And the payment record would have your personal data on it.
- 23:35So it's like, yes, we removed you from the database.
- 23:38By the way, you just created a payment record.
- 23:40And the payment record has your personal info on it.
- 23:43So they took an ethical dislike to it.
- 23:47And in a way, it was kind of fortunate the way it panned out and that we had a month's notice between saying we're going to dump this and it actually happening.
- 23:55And I had time to think about how would I handle this and have I been pwned.
- 23:59Because it turned out to be more than 30 million records.
- 24:00So it was a very large breach.
- 24:02And I kind of went, look, this is going to be valuable data if it does turn up.
- 24:06And I want to make it searchable.
- 24:08But by the same token, this is the sort of thing where I don't want to be the vector through which, let's say, a rightly jealous wife discovers that her husband has been on the site.
- 24:18And incidentally, this was a very, very heavily male-dominated service, which probably comes as no surprise to anyone.
- 24:24And the women that were on there, a huge number of them signed up from IP address 127.0.0.1, which is a little bit suspicious.
- 24:30That is a tiny bit suspicious, yes.
- 24:32Yes.
- 24:33And actually, this is one of the things we learned, right?
- 24:35They're actually FEM bots, you know.
- 24:37So I always think Austin Powers, every time I hear FEM bots.
- 24:40I don't know if it was exactly like that.
- 24:42However, you've got these accounts on there, which are effectively bots, which are trying to engage with men.
- 24:49Because the more you can engage with them, the more you can get them to pay and all sorts of shady stuff.
- 24:53So anyway, eventually the data does get dumped.
- 24:56And by virtue of having had time to think about it, I had decided that I'd introduce the concept of a sensitive breach.
- 25:03And a sensitive breach means the data still goes in Have I Been Pwned?
- 25:06But you can't publicly, anonymously search for someone else.
- 25:10So you've got to actually subscribe to the notification service, which is free.
- 25:14But the reason I use that mechanism is because that sends you a verification email with a unique link.
- 25:19You click the unique link, and then it says, okay, now I know that you control this email address.
- 25:23We'll show you everything.
- 25:25So the public ones and the sensitive ones.
- 25:27Pretty legit way to handle it.
- 25:29Definitely the way the website handled the breach didn't sound like it went well.
- 25:34Let's talk about one more breach before we move on to some developer topics.
- 25:39One that you did write about was Disqus, the comment section, which actually is at the bottom of your show page, right at talkpython.fm/136.
- 25:51I suspect you could find Disqus right there.
- 25:53And you said that these guys, while something happened in terms of a data breach, they handled it right.
- 26:00Yeah, and you know, it's at the bottom of my blog as well.
- 26:02And it's also my data in the Disqus data breach.
- 26:06So I think that the macro picture here is that when data breaches happen, there's a real broad range of reactions from organizations involved.
- 26:16And they range from, on the one hand, being extremely difficult to get in touch with, sometimes denying it, often downplaying the severity, sometimes covering it up, like knowing there was a breach, but not telling people because they're worried about reputation damage.
- 26:30And doing all the sorts of crappy things that you might expect an organization at the receiving end of one of these things might do.
- 26:37And then on the other hand, there's sort of like, this is exactly the way to handle it.
- 26:41And Disqus was very much on that right-hand side.
- 26:44And there's really only a couple of organizations I've dealt with that have been down there.
- 26:48And the things that Disqus did really well, one of them is the speed.
- 26:52So everyone would have seen Equifax in the news only last month.
- 26:56And Equifax took about five weeks after learning of the data breach to advise everyone.
- 27:02They needed to sell their stock.
- 27:03Well, geez.
- 27:04Allegedly.
- 27:06Well, they did sell stock.
- 27:08Allegedly because of the breach.
- 27:10You've got to be careful.
- 27:11Right, right, right, right.
- 27:12People get very litigious in America.
- 27:13I know this.
- 27:14Yes, that's right.
- 27:16Actually, I've heard this.
- 27:17Fortunately, I don't know this through personal experience.
- 27:19But the thing with Disqus is that I got in touch with them.
- 27:24And actually, just to be clear as well, the context we've discussed is someone popped up and gave me seven different data breaches.
- 27:30And they're things that I had never seen anywhere before.
- 27:33It was things like Reverb Nation, Kickstarter, Bitly.
- 27:37And all of these three had previously disclosed where they'd said, hey, we've been hacked, never seen any data for it.
- 27:43And then suddenly they all turn up in this one place and they're all legit.
- 27:46And then one of them as well was this Disqus one.
- 27:49And I'm trying to find references to a data breach.
- 27:52I can't find anything.
- 27:53And there's 17 million email addresses in there.
- 27:55So fortunately, I had a contact there, someone I'd been chatting to only a couple of months earlier on another topic.
- 28:01And I was like, I think I have your data and you probably should know about this.
- 28:06And from the point where I sent that first email to when they had made a public statement and had already reset impacted passwords as well, I think it was 23 hours and 43 minutes.
- 28:21It was just under a day.
- 28:23And it's like, okay.
- 28:23That's awesome.
- 28:24That is awesome.
- 28:25Like you guys have turned this around less than a day.
- 28:27And when I spoke to them, so we jumped on the phone as well and had a good chat.
- 28:31They were sort of really, I mean, obviously they weren't happy about the situation.
- 28:35No one's going to be.
- 28:36But they sort of understood that this is the reality of operating online today where these things do happen very regularly.
- 28:42They prepared communications, which was transparent, candid, honest.
- 28:47They worked with the media as well.
- 28:50So one of the things I was sort of impressing on them is I think it's really important to engage with the media because there's going to be stories on this.
- 28:58And you can either ensure that those stories are representing your point of view and your version of events or you can say, look, we're too busy or we don't respond to the media and you can let them form their own opinions.
- 29:07So they just did all of that right.
- 29:10And the only negative feedback I saw out of any of this was people saying, well, how come it took you four years?
- 29:16Because apparently it actually happened in late 2013.
- 29:18Well, they didn't know.
- 29:20And we still don't know.
- 29:21Well, I haven't seen any press as to how it happened or why it took this long to know.
- 29:27But I guess based on the hand that they were dealt a couple of weeks ago, the way they handled it was just exemplary.
- 29:33One of the things that's always kind of in the back of my mind, I've run a number of websites, have a couple of servers, some backend servers.
- 29:40I talk to those servers.
- 29:41You know, how would I know if I've been hacked?
- 29:44Well, as we've just seen, you may not.
- 29:47And this is sort of part of the problem.
- 29:49We've got to remember as well that the discuss situation is far from being exceptional.
- 29:54So just off the top of my head last year was LinkedIn, Dropbox, MySpace, Last.fm, Tumblr, many others that were in similar boats where they had had breaches years ago and were only just discovering it.
- 30:06And incidentally, that big stash of data that had Bitly and Kickstarter and all the other ones in it, there was another one.
- 30:11I'm thinking very carefully before I say these words because two of them haven't been disclosed yet.
- 30:15But there was another one which was a service called We Heart It, which seems a little bit like Pinterest.
- 30:19That was in there.
- 30:20And there were two others which were still waiting.
- 30:23One of them should be sending their message out any moment now, which is millions of accounts again.
- 30:27And then a final one, which I'm still trying to get in touch with some people.
- 30:31Not everyone replies to an email when you say, hey, you've been breached.
- 30:34They might pretend it went to spam and just go dark, right?
- 30:37Yeah.
- 30:37Well, they won't be able to once I've published the data and have I been pwned.
- 30:40But I'd really like to give them the opportunity to control the messaging themselves first.
- 30:44But what we've got to remember with all these cases is they happened years ago, very often with entirely different people in the organization as well.
- 30:52Very often with different infrastructure, different code bases.
- 30:56Very often you're not even going to have logs that go back, say, four years.
- 31:00You know, do you really keep web server logs that long?
- 31:02A lot of organizations don't.
- 31:03So it can be enormously difficult to know when an incident has actually happened.
- 31:09And I guess your point about how do you know, one of the things that sort of continues to strike me is that there are all of these incidents that have already happened that we don't know about as the public.
- 31:20And then a subset of those, probably a very large subset, where the organization themselves doesn't know about it as well or don't know about it.
- 31:27So we're yet to see so much stuff actually come out of the woodwork that we just haven't even begun to conceive of yet.
- 31:33Yeah, that's kind of daunting.
- 31:35It's sobering, isn't it?
- 31:36Yeah, sure.
- 31:37So it sounds to me like a lot of the time this becomes something that we're aware of because the data is discovered.
- 31:44You're like, oh my gosh, these accounts are all coming from this one place.
- 31:47There might be people that use like their email address, like my email address plus LinkedIn at gmail.com.
- 31:55And you're like, well, I only use the plus LinkedIn at LinkedIn and it's out in this paste bin or something, right?
- 32:00Well, when people do that, so when they use that sort of aliasing pattern where they have this sort of plus after the alias or when they have their own domain and they create custom aliases for every service.
- 32:11Right.
- 32:11LinkedIn at my domain.
- 32:12Yeah.
- 32:13Yeah, right.
- 32:13That does actually help.
- 32:14In fact, one of the ones I'm going through a disclosure with now, and this is sort of the last out of the seven that was in the stash I just spoke about.
- 32:21It wasn't immediately clear where all the data was from.
- 32:24It's labeled one service, but I was actually checking with have I been pwned subscribers saying, hey, look, you're in here.
- 32:31Have you used this service?
- 32:32And a bunch of them were saying, you know, no, I've got no idea what it is.
- 32:35And it was only when I started going through looking at things like the aliases on email addresses where it's like, oh, okay, I can actually see this other thing now.
- 32:43And I was able to kind of join the dots and go, okay, well, I can see that this is actually from multiple different sources.
- 32:49I think it's actually from two different sources.
- 32:51It does seem like at least a little bit of a breadcrumb.
- 32:53I don't do it that often, but sometimes I do.
- 32:56Yeah.
- 32:56No, it can be really useful for that.
- 32:58The other thing that I hear people saying is I say, look, I use this aliasing pattern because then I can see when my data is, say, sold or redistributed or something like that.
- 33:08I can see where the source was.
- 33:10The problem then, of course, is what are you going to do about it?
- 33:12Like we know that this happens.
- 33:14And if you go back to the organization and say, hey, I signed up on your service and I signed up with my name plus your service name at gmail.com.
- 33:21And I've just seen I've just gotten spam trying to sell me Viagra.
- 33:24Okay, now what?
- 33:25You know, like there's not really anything that's actionable.
- 33:28Yeah, I've heard that.
- 33:30And actually, I've been on both sides of that story, not with stuff that I'm doing these days, but previous project.
- 33:35And, you know, how much weight should you put in that?
- 33:39Like on one hand, I feel like, yeah, okay, if somebody really got all the data out of the database, they would have those things that they could email people.
- 33:44But it seems like that's a weird thing to do is just spam folks.
- 33:47On the other hand, if somebody breaks into that person's email and just harvests every email they see and just start sending to it,
- 33:54maybe it's their account that got broken into and just happened to be they kind of loop back.
- 33:59Well, you know, this is also one of the great mysteries, right?
- 34:01Where there are so many different ways that these things can go down.
- 34:04And very, very often, you just simply can't get to the bottom of it.
- 34:08I mean, people say to me all the time, like, I'm getting spam.
- 34:11Where's it come from?
- 34:12I don't know.
- 34:12It's like you put your email address out all over the place.
- 34:14It could be from anywhere.
- 34:16Yeah, that's right.
- 34:16Get a good spam filter and just buck it up, I guess.
- 34:19Exactly.
- 34:22This portion of TalkPath in a Me is brought to you by GoCD from ThoughtWorks.
- 34:26These are the people that literally invented continuous integration.
- 34:29They have a great open source on-prem CDCI server called GoCD.
- 34:34But rather than tell you about the server this week, I want to share a course they created for people who are new to continuous integration.
- 34:39Check out their course called Continuous Delivery 101 from GoCD at gocd.org slash 101.
- 34:47This video series covers the history of continuous delivery, concepts, best practices, how to get started, and popular tools.
- 34:54You'll gain a holistic view of continuous delivery and a deeper understanding and an appreciation of the critical concepts.
- 35:01Be sure to try their course at gocd.org slash 101 and let them know that you appreciate their sponsorship of Talk Python.
- 35:08Speak to the web developers out there.
- 35:10What lessons have you learned from running Have I Been Pwned that you'd like to share with that audience?
- 35:17There are a lot of things, you know, speaking or sort of thinking about it from a pure dev perspective.
- 35:22Going back to what I was saying earlier, one of the main reasons I wanted to do this is because I really wanted to do something in anger on Azure.
- 35:31And I've had a heap of fun, to be honest, building this service out on Azure and sort of experiencing the whole cloud scale thing and commoditized pricing and all the other sort of promises of the cloud.
- 35:44And there's a heap of learning out of that, both good and bad.
- 35:46I mean, some of the good stuff has been things like the ability to have auto scale, you know, so actually provision more infrastructure on evidence of exceeding existing infrastructure resources is fantastic.
- 35:58And I've spoken many times at events about how to run a project like this on a coffee budget.
- 36:04So how do I run a service with 4.8 billion records and sometimes millions of visitors a day for what you'd spend on coffee?
- 36:10And I don't always manage to do that, but I usually get pretty close.
- 36:14And things like really managing your scale very carefully have been great.
- 36:19Things like choosing the right data storage constructs for your use case have been great as well.
- 36:25So particularly in sort of the Microsoft-y world, there's been this traditional view of you're going to store data, you've got to have a SQL database.
- 36:33And a SQL database is a behemoth of a thing, right?
- 36:36I mean, it is a big, big thing.
- 36:39And it's expensive and it's...
- 36:41Especially with four point something billion records.
- 36:43Well, hey, look, if I got to that point, if I was actually trying to put that data in a relational database like SQL Server, I mean, the cost would just be astronomical.
- 36:51But it would also be really unnecessary because the patterns with which the data is used just don't predispose it to needing a relational database.
- 36:59So one of the best things I ever did was to use Azure's table storage, which is basically just a key value pair.
- 37:05And I just petitioned it in a way that worked really well.
- 37:09So those 4.8 billion records are in there.
- 37:12You can create a petition and then a row key.
- 37:15So my petition keys are the domain.
- 37:17So say gmail.com.
- 37:18And then the row key is the alias.
- 37:20And what that allowed me to do is do super, super, super fast lookups.
- 37:24Because when you're searching, you're literally searching by domain and alias.
- 37:28So a very specific petition and a very specific row key.
- 37:31And it also made it really easy to do entire domain wide reports because I just pulled the entire petition.
- 37:37So that works awesomely.
- 37:39And that is still the single best decision I've ever made, I'd say, in terms of the architecture.
- 37:44So for those 4.8 billion records that on disk is some tens of gigabytes, they actually don't have good reporting about actual size.
- 37:52And it always scales infinitely.
- 37:54So it is platform as a service.
- 37:56I've never reached any scale capacity on the storage tier.
- 37:59And it usually returns records within sort of a single digit millisecond range.
- 38:04And that cost me about $40 a month.
- 38:06Awesome.
- 38:06Yeah, which is just like, how cool is this?
- 38:08It just rocks.
- 38:09One of the other really, really big things I've learned is I started using Cloudflare for Have I Been Pwned about a year ago.
- 38:17And look, I've been using them on things like my blog and a couple of other little projects.
- 38:22And it was kind of cool for that in that you get HTTPS for free and a few other little sort of bits and pieces that make things like my blog run a lot better.
- 38:31But it made a massive difference to Have I Been Pwned.
- 38:34And I originally did it because I was getting DDoSed and that sort of, that wasn't fun.
- 38:38And Cloudflare put a stop to that.
- 38:42But then it became really, really awesome because you have things like a firewall that you can control programmatically.
- 38:47So one of the reasons I put it in place was the API I have, I introduced a rate limit because I was seeing some fairly nefarious behavior to it.
- 38:56And I went, oh, look, I'll just put a rate limit in.
- 38:58And if you exceed the rate limit, I'll return a 429 too many requests and say you can retry after two seconds.
- 39:04And they'll see that and they'll stop.
- 39:07But no, they don't.
- 39:08They just kept hammering it.
- 39:10And one of the pennies that dropped was that when you expose that sort of origin server to the world, you have to deal with everything there.
- 39:18So you have to deal with every incoming request on that same infrastructure, which is actually trying to reserve legitimate requests.
- 39:24And when you put a service like Cloudflare in front, suddenly you have this other layer in front where you can start to programmatically exclude nasty stuff and actually free up the underlying resources to do the things they're meant to do.
- 39:37So I've got some great rate limiting implementations.
- 39:40I've got a really neat model I've written about before using Azure Functions where even when I see behavior that's slightly nefarious on the website itself, I just drop in a JavaScript challenge rule on the Cloudflare edge node so that if you go to the site, it just makes sure you're in a browser and you can't automate it with an API.
- 39:56And then you basically get a 24-hour timeout and then you can try again.
- 40:00So it's been awesome for that.
- 40:02That has also been super awesome for reducing my cost because I cached the bejesus out of this thing.
- 40:07So Cloudflare has got 118 edge nodes as of today around the world and everything from the front page to the FAQs to every single image in JavaScript file and CSS file is served from those edge nodes.
- 40:20So the actual traffic that comes through to the site is usually just API requests and a couple of other dynamic things.
- 40:27So it's really, really dramatically reduced my costs and the frequency with which I need to scale my infrastructure.
- 40:33Oh, that's really cool.
- 40:34And Cloudflare is actually in the news recently this week, a couple weeks ago, for announcing basically unlimited DDoS production.
- 40:41So yeah, that's cool.
- 40:43It's the world we live in today, isn't it?
- 40:45And look, that was sort of their traditional thing, right?
- 40:48Like they made their name out of DDoS protection.
- 40:50But they do so much more now because they can sit on the wire and intercept that traffic.
- 40:55And that spins some people out as well.
- 40:57And if you are listening to this and you get spun out by it, I've got a blog post about security absolutism.
- 41:02So if you Google my name, security absolutism, you sort of see me try and put things in perspective.
- 41:07But it means you can do stuff like all these websites that are now going HTTPS because they're being sort of forced down this route.
- 41:14You can go HTTPS for free via Cloudflare within about five minutes.
- 41:19And not only that, but they can also do things like add an HSTS header because when you can intercept the traffic, you can add headers.
- 41:25They can rewrite HTTP references to HTTPS.
- 41:29They can 301 all of your insecure requests over to secure requests.
- 41:34And they can do all of this stuff because they're sitting there controlling the traffic.
- 41:38And that just makes a huge amount of sense for many, many good reasons.
- 41:41Yeah, that's cool.
- 41:42And you don't have to worry about it.
- 41:43Yeah, yeah.
- 41:43It's like literally a turnkey thing.
- 41:45Yeah, that's cool.
- 41:46Yeah, I don't use it, but I've considered adding it.
- 41:49And it seems like it might be a good idea.
- 41:50I should be quiet.
- 41:51Somebody might try to attack my...
- 41:53No, you know what?
- 41:55And it is like a five-minute job too.
- 41:57And people go, yeah, but you can just go to Let's Encrypt and get a certificate.
- 41:59And they're right.
- 42:00And Let's Encrypt is absolutely awesome.
- 42:02But it is just certificates.
- 42:04And there is so much more that you can do with a reverse proxy like Cloudflare.
- 42:08Like once you actually use it in anger on a large-scale site, you go, wow, how would I ever not?
- 42:14You know?
- 42:14Right.
- 42:15And even if it's a small site or a static blog or something, it still makes an enormous amount of sense because of stuff like the caching.
- 42:21Cool.
- 42:21Yeah, it definitely sounds like it's worth checking out.
- 42:25So one thing I wanted to talk to you about is WannaCry, which was a real sad thing that sort of was a ransomware thing that went around just encrypting all the things.
- 42:37And it took out a bunch of places.
- 42:39The most notable one, I guess, was the National Health Service in the UK.
- 42:44That's right.
- 42:44But it also took out things like Maersk, FedEx, a bunch of places, right?
- 42:49WannaCry seems to me like a real lesson in just being vigilant and patching all of your stuff and keeping it up to date.
- 42:57But there's tons of things that were way out of date.
- 43:00What do you think some of the lessons are from WannaCry?
- 43:02Well, just one thing on that, actually.
- 43:03The Maersk one was NotPetya.
- 43:05So NotPetya came, I think it was about a month or six weeks after WannaCry.
- 43:10It wasn't that long.
- 43:11Right, right.
- 43:11There were similar times.
- 43:12Yeah, it was similar.
- 43:13But, yeah, yeah, there's similar times.
- 43:15And look, it's still ransomware.
- 43:16Look, you don't want either.
- 43:18All right?
- 43:18The thing that was really interesting about WannaCry is the sort of sequence of events leading up to that.
- 43:25Without having the exact dates in front of me, from memory, WannaCry hit us in May.
- 43:30And back in March, we had seen Microsoft say, look, there are some critical patches.
- 43:34You really should take these critical patches.
- 43:36And they didn't really elaborate why they knew they were so important or so timely.
- 43:40But, you know, maybe you should just really just do this right now.
- 43:43Exactly.
- 43:44And then a month later, we saw this sort of shadow brokers dump.
- 43:49So this collective that has collected themselves a bunch of zero days.
- 43:54And one of the vulnerabilities in there was this eternal blue vulnerability which exploited SMB.
- 44:00Which we'd normally use for sort of connecting and file systems and sharing information across them.
- 44:04And the problem there was that you could remotely connect to a machine with a vulnerable SMB implementation and have remote code exec on it, which is really nasty stuff.
- 44:13And, okay, now we're saying, all right, so a month ago, Microsoft said patch your things.
- 44:17Now we know why it was important.
- 44:19And then another whole month went by.
- 44:21And then WannaCry hit.
- 44:22So by the time someone got hit with WannaCry that was exploiting Eternal Blue, two months ago, they knew it was a big thing.
- 44:29A month ago, we knew why it was a big thing.
- 44:31And now you still haven't patched your things.
- 44:34And really, the lesson out of this was around patching.
- 44:38And this was just such a sort of, I guess, poignant example of why it was so important.
- 44:44Because this was devastating.
- 44:45I mean, it hit particularly the NHS.
- 44:47But it hit everything from German trains through to other services and other parts of Europe in particular really, really hard.
- 44:54And what sort of stunned me is after that, a lot of the stuff I was writing and talking to people about was this whole patching cycle where there were still people going, I disable Windows updates.
- 45:05And there's literally tutorials out there.
- 45:07How to disable Windows updates because maybe you'll get a bad one.
- 45:10And I would have people sort of justifying turning it off.
- 45:13They're like, well, I don't like it because sometimes you go down, you got to shut down your PC and it says you've got to wait while updates install.
- 45:19And once I was about to get on an airplane and I couldn't close my laptop.
- 45:22That's your reason.
- 45:25But actually, my favorite one was a bunch of people would say, I keep installing all these stupid updates.
- 45:30I've never even had a virus.
- 45:31Yeah, but that's why you haven't because you install the updates.
- 45:36You know, it's certainly an important part of it.
- 45:38So to have that happen and then have NotPetya occur just after that, which again was exploiting a number of exploits.
- 45:45But one of them was an unpatched or rather a patched vulnerability, which people had left unpatched and then got exploited.
- 45:51Right.
- 45:51If they didn't learn from the first two times around, they should have really learned from WannaCry.
- 45:54I know.
- 45:55Exactly.
- 45:56Anyway.
- 45:57Yeah.
- 45:57The reason I bring this up is not to just talk about these crazy viruses and patching.
- 46:01But I think there's a real tension in organizations and the larger the organization, the greater the dissolution of responsibility in this is to say like, look, there's this system that's running our invoices.
- 46:15Nobody knows how really to upgrade it.
- 46:18And nobody wants to be the one to take the responsibility of patching it because if it goes down, their weekend is toast.
- 46:24We're just going to leave it.
- 46:25Not my problem.
- 46:26Someone else's problem.
- 46:27Right.
- 46:28How do you think we address that?
- 46:30Look, it's a good observation.
- 46:31And we've got to be fair here that we don't sort of overly trivialize the complexity that can be involved in actually patching these things.
- 46:39I mean, think about the NHS for a moment and think about what hospitals run and some of the systems they have.
- 46:45Think about an MRI machine.
- 46:47You know, imagine actually trying to patch that thing.
- 46:50And look, there's a bunch of them probably sitting out there still running Windows XP.
- 46:54You know, you don't just like whack in the DVD and upgrade to Windows 10.
- 46:57This is not a simple process.
- 47:00So I'm sympathetic to that.
- 47:01And I suspect that what happened in cases like the NHS is there's budget constraints.
- 47:07In fact, we know there's going to be budget constraints in a hospital.
- 47:10There's budget constraints.
- 47:11The IT managers had to make a call between where that budget gets spent, what's patched when, how much money they allocate into different areas.
- 47:19And it would have been a very hard problem.
- 47:21And large enterprises are not exactly just running Windows update automatically across everything either.
- 47:26I mean, these things are tested and rolled out through standard operating environments.
- 47:29And they're a big thing.
- 47:31And I think, to be honest, like the bigger picture here is that when there is a high friction of updates, it makes the uptake very difficult.
- 47:40I mean, one of the things that Apple's done really well is they've made it such a low friction process.
- 47:45You know, like, hey, iOS 11 landed the other day.
- 47:47A thing popped up on my screen and I said yes.
- 47:49And I never had to worry that it wouldn't work.
- 47:51And if it didn't work, I would have restored from iCloud while I went out and, you know, kicked the ball with the kids or something.
- 47:56And I'd come back inside and I'd be done.
- 47:57So, yeah, that's really the model that we'd love to move towards where these things are low friction and automated.
- 48:04And unfortunately, that's just not the reality with a lot of systems today.
- 48:09Yeah, absolutely.
- 48:10The more complicated they get, like it could be like a library that's compiled into your code that you've got to upgrade.
- 48:17For example, with the Equifax one, right?
- 48:20Yeah, the struts in Equifax.
- 48:21That's right.
- 48:22And like they had to like recompile and, you know, who knows what got deprecated, what had to have been changed.
- 48:28Granted, that doesn't excuse them.
- 48:29They really messed that up.
- 48:31But still, it's not that.
- 48:33It's a little bit hard trying to throw Equifax a bone.
- 48:36But look, I mean, that is something where it's like, okay, let's just be objective about it.
- 48:41I can see where when it struts and you have to like go and recompile some pretty serious stuff as well.
- 48:46It comes back to that point about the friction.
- 48:48And when there is this high friction of change, well, yeah, it's going to be hard to get this stuff done in a timely manner.
- 48:54Yeah, absolutely.
- 48:55Absolutely.
- 48:55So we don't have a lot of time left.
- 48:57Let's talk a little bit about IoT.
- 48:58You wrote an interesting blog post.
- 49:03I think it's a blog post called,
- 49:04What It Would Look Like If We Put Warnings on IoT Devices Like We Do on Cigarette Packs.
- 49:08Tell us about that.
- 49:10Yeah, yeah.
- 49:12That was fun.
- 49:13So the sort of premise of this is a lot of IoT stuff's got some pretty crazy vulnerabilities in it.
- 49:18Now, one of the ones I saw a couple of years ago is that there's these kids' tablets.
- 49:24So imagine if Fisher Price made an iPad.
- 49:27This is sort of my vision of it.
- 49:28So it's plasticky and colorful and all this sort of thing.
- 49:32And these were made by a company called VTech, Hong Kong-based toy maker.
- 49:35And VTech had a vulnerability that someone exploited, sucked out millions of parents' and children's data.
- 49:41And the kids' data included things like their names, their birthdates, their genders, their photos, foreign keys to the parents with the parents' physical addresses as well.
- 49:50So it was like from a stalker perspective, it was kind of the worst possible thing you can imagine.
- 49:56I know, it was like super, super creepy.
- 49:58And, you know, like this was really bad news.
- 50:01And someone did break into their systems, but they had some shockingly bad aspects of their security there.
- 50:08I mean, stuff like, I wrote a blog post at the time.
- 50:10You would log in.
- 50:11And when you log in via, they had a little flash emulator for the tablets.
- 50:16Okay, there's another hint.
- 50:17Some things are going to be wrong.
- 50:18So there's a little flash emulator.
- 50:20It calls an API.
- 50:21The API returns a JSON response, which contains the actual SQL query executed in the database.
- 50:26And it's just really, really weird stuff like that.
- 50:29And it wouldn't surprise me at all if it was just classic SQL injection that the guy got in with.
- 50:33Anyway, they had a bad time out of it.
- 50:37And they were in the news only a couple of weeks ago because a class action against them didn't succeed, which frankly, I agree with.
- 50:44I think people trying to mount a class action against a company where the data was exposed but contained.
- 50:51It was never spread.
- 50:52It was never abused.
- 50:53It was just a bit of a money grab.
- 50:54I think the regulators should be pinging them.
- 50:56That's a different story.
- 50:57But anyway, so they're in the news.
- 50:59And this one story pointed out that their terms and conditions today effectively say you could get hacked.
- 51:05Someone could get your data.
- 51:06That's your problem, not ours.
- 51:08I kind of replied to them or quote tweeted them and said, look, how about you put this on the front of the pack?
- 51:13And it was a little bit tongue in cheek, right?
- 51:15Because if you put that in the front of the pack, no one's going to buy your freaking tablet.
- 51:17And I was thinking about it later.
- 51:20I was like, it's almost like it's a dangerous good, you know.
- 51:22And in Australia, what we do with dangerous goods like cigarettes is we put great big warning signs on the front of the packs.
- 51:28And they're very graphic.
- 51:29And they tell you how bad stuff can be when it goes wrong.
- 51:32This can kill you in slow and horrible ways.
- 51:34Let us list them.
- 51:35I know.
- 51:36And they're super, super graphic in Australia as well.
- 51:38So I thought, all right, well, look, why don't we do this with IoT?
- 51:41We'll literally just put these things on the front of these IoT devices like we would a cigarette pack.
- 51:47So I just did this blog post with a bunch of mock-ups of what would it look like.
- 51:51And it's, you know, there's sort of warnings on everything from the VTech tablets to teddy bears to automated dog feeders.
- 51:58And that was a rather popular post.
- 52:00Yes.
- 52:03Warning.
- 52:03You acknowledge and agree that your child's intimate voice recordings may be placed in an unsecure Amazon S3 bucket.
- 52:09Oh, cloud pencil.
- 52:10Oh, my God.
- 52:11Oh, yeah.
- 52:11That's pretty funny.
- 52:12I think it makes a good point.
- 52:14And I guess maybe just a final thought on IoT.
- 52:17Like, do you think things are going to get better?
- 52:18Or is it just going to continue to be a bunch of unpatched badness?
- 52:21No, of course they're not going to get better.
- 52:22I mean, there's just nothing that predisposes it to getting better.
- 52:27When you look at the factors that are driving the growth of IoT, you know, we want to be first to market.
- 52:31We want to put internet in things that were never meant to have internet.
- 52:35And if you want to know what I mean by that, just Google WeVibe and we'll leave it at that.
- 52:39So there are all sorts of things.
- 52:42Wait, wait, wait.
- 52:42Do that in an incognito window.
- 52:44Look, you know what?
- 52:45You'll find news stories on it.
- 52:47And let's touch on that in a mature, responsible adult fashion.
- 52:51So these are toys for adults and they are internet connected.
- 52:55And what I find fascinating from this in a very kind of mature way is that this is digitizing data we never had before.
- 53:03So it actually stored usage data.
- 53:06And whilst these devices have been around for eons, that the concept of actually recording the use, everything from the modes that was used into the times of day, reference to the identity using it, we never had that before.
- 53:19And now we have this new class of data, which is enormously sensitive by virtue of the fact that we've internet connected the things.
- 53:26And the reason you'll find them in the news is that they recently got fined up to $10,000 per owner of the device because they were collecting this data without consent.
- 53:35And you can imagine for the owners of them, I mean, that must be absolutely gut-wrenching to think that this sort of data about them now exists on a server somewhere.
- 53:43Definitely.
- 53:44It's quite troubling.
- 53:46Yeah.
- 53:47So I don't know.
- 53:48I think you're probably right.
- 53:49I think that there's going to be a lot of trouble with these types of things.
- 53:52Just the incentive to keep things updated is not very good.
- 53:55I did recently get an electric car and I have a charger for the car that's on the internet, which makes me a little nervous.
- 54:02But I logged into it the other day and it had updated itself within the last two weeks.
- 54:07So maybe the higher end devices will be a little bit better off.
- 54:10Yeah.
- 54:11Look, I think the devices that are doing these auto updates are the way we're going, right?
- 54:15And some of them do it very well.
- 54:16Some of them do it still with requiring user action, but sort of very low friction.
- 54:21I hope that's going in the right direction.
- 54:24But geez, there's so many things out there where something has gone fundamentally wrong in order to require the update in the first place as well.
- 54:31Yeah.
- 54:31Yeah, absolutely.
- 54:32Yeah.
- 54:32I mean, there's the danger that you could brick the device.
- 54:35So there's that same type of hesitation to actually put that security patch in like that you have with the big companies, right?
- 54:42Like no one wants to brick everything they've sold.
- 54:44I know.
- 54:45There's also that.
- 54:48So, all right, I think we're just, I have so many questions I'd love to chat with you about and maybe someday we'll do a follow up and I can ask the other ones.
- 54:54But I do want to give you a chance to talk about your courses because you've written a ton of PlutalSite courses and they're actually really, really valuable, I think.
- 55:03So maybe touch on some of the ones you feel are notable for my audience.
- 55:07I think the one which is most notable at the moment is the one that's still pinned to my Twitter timeline.
- 55:13I do intend to leave it there for a little bit, which is what every developer must know about HTTPS.
- 55:18And I love the HTTPS discussion at the moment because there are so many, so many angles to it.
- 55:24And it's such an important time as well.
- 55:26So, for example, back in January this year, we saw Chrome and Firefox start to warn anyone if they went to a login form or a credit card form over HTTP, even if it publishes or posts rather to HTTPS.
- 55:39And that was an important change.
- 55:41We're here recording in October and Chrome 62 has just hit.
- 55:46And in 62, they are gradually enabling the feature, which now does the same thing for any page with an input form as soon as you type a character.
- 55:54So you can go to like CNN, click on the search link, type any character into the search box, and then suddenly you get a big not secure warning.
- 56:03So that makes things really, really interesting.
- 56:05Like that's really starting to push HTTPS.
- 56:07And the sorts of stuff I talk about in the course are things like, I think a lot of people know, you're meant to make sure that all of your embedded resources on the page are done so over a secure connection.
- 56:16Otherwise, you lose your padlock and your green text and your secure in Chrome.
- 56:21But there are tricks to help you do this.
- 56:23So there are things like there is an upgrade in secure requests content security policy.
- 56:27So you can add a response header or you can put it in a meta tag.
- 56:30And if you accidentally put anything in securely on the page, then the request automatically gets upgraded to a secure one.
- 56:36Oh, that's nice.
- 56:37So there are all these neat little tricks like that you can do, which make HTTPS so much more easily accessible.
- 56:44And a lot of time when I hear people saying I'm having problems because of this or that or whatever, it's like there are usually things like response headers, the CSP, also HSTS to enforce HTTPS connections for all requests.
- 56:57You know, those sorts of things are just fantastic.
- 56:59And that's what a lot of the course is about.
- 57:01Okay, cool.
- 57:02I'll definitely link to that and a couple of other ones in the show notes that I thought were pretty cool.
- 57:06You also have a nice article on getting started in ethical hacking as a career.
- 57:11So that's cool as well.
- 57:13Yeah, I guess we're going to have to leave it there for the topics.
- 57:15I always have two questions I ask at the end.
- 57:17So let me ask them to you now.
- 57:19The one of them is if you're going to write some code, what editor do you open up?
- 57:23Usually Visual Studio.
- 57:24Okay, right on.
- 57:25And now normally I ask about libraries and Python.
- 57:29You don't do that much Python.
- 57:30So I'll give you a pass on that one.
- 57:32I'm going to give you a variation on this.
- 57:33So what password manager do you use?
- 57:36So I'm like you.
- 57:37I use the password manager called 1Password.
- 57:40Now, I said the password manager called that because if you just say I use 1Password, people are like, what is wrong with you?
- 57:45Well, people should be like, what is wrong with you?
- 57:46You're using it everywhere.
- 57:47What are you thinking?
- 57:48I know.
- 57:48I know.
- 57:49So look, I still use that.
- 57:51I'm a little bit agnostic in so far as I think, frankly, so long as you're using a mainstream professional password manager like that or LastPass.
- 57:59Honestly, that's going to make your life so much better in so many ways.
- 58:02So use one of those things.
- 58:04Yeah.
- 58:04It definitely makes your blood pressure stay pretty cool when you find that there's been a password breach.
- 58:11Yeah, that was 40 characters random.
- 58:13I'm going to reset it.
- 58:14Not a big deal.
- 58:14That's it.
- 58:15Yeah.
- 58:15Right on.
- 58:16Okay.
- 58:16Well, Troy, thank you so much for being on the show.
- 58:18Any final call to action for everyone listening?
- 58:20No.
- 58:21Look, I mean, if you want to learn any more, go to TroyHunt.com or find me on the Twitters as Troy Hunt.
- 58:26All right.
- 58:26Awesome.
- 58:26I'll be sure to put those links in the show notes.
- 58:28And thanks for being here.
- 58:29Good on you.
- 58:29Thanks, mate.
- 58:30Yeah.
- 58:30Bye.
- 58:30This has been another episode of Talk Python To Me.
- 58:34Today's guest has been Troy Hunt.
- 58:36And this episode has been brought to you by Rollbar and GoCD.
- 58:40Rollbar takes the pain out of errors.
- 58:42They give you the context and insight you need to quickly locate and fix errors that might have gone unnoticed until your users complain, of course.
- 58:50As Talk Python To Me listeners, track a ridiculous number of errors for free at rollbar.com slash Talk Python To Me.
- 58:57GoCD is the on-premise, open-source, continuous delivery server.
- 59:02Want to improve your deployment workflow but keep your code and builds in-house?
- 59:06Check out GoCD at talkpython.fm/G-O-C-D and take control over your process.
- 59:12Are you or a colleague trying to learn Python?
- 59:15Have you tried books and videos that just left you bored by covering topics point by point?
- 59:19Well, check out my online course, Python Jumpstart, by building 10 apps at talkpython.fm/course to experience a more engaging way to learn Python.
- 59:28And if you're looking for something a little more advanced, try my WritePythonic code course at talkpython.fm/Pythonic.
- 59:36Be sure to subscribe to the show.
- 59:38Open your favorite podcatcher and search for Python.
- 59:40We should be right at the top.
- 59:41You can also find the iTunes feed at /itunes, Google Play feed at /play, and direct RSS feed at /rss on talkpython.fm.
- 59:51This is your host, Michael Kennedy.
- 59:53Thanks so much for listening.
- 59:54I really appreciate it.
- 59:55Now get out there and write some Python code.
- 59:57I really appreciate it.