Latest / Talk Python To Me / #435: PyPI Security
Transcript
- 0:00Do you worry about your developer data science supply chain safety?
- 0:03All the packages for the Python ecosystem are much of what makes Python awesome,
- 0:08but they are also a bit of an open door to your code and machine.
- 0:13Luckily, the PSF is taking this seriously and hired Mike Fiedler
- 0:16as the full-time PyPI safety and security engineer,
- 0:20not to be confused with a security developer in residence,
- 0:23tapped by Seth Michael Larson.
- 0:25Mike Fiedler is here to give us the state of PyPI security
- 0:29and their plans for the future.
- 0:31This is Talk Python To Me, episode 435, recorded September 18th, 2023.
- 0:36Welcome to Talk Python To Me, a weekly podcast on Python.
- 0:54This is your host, Michael Kennedy.
- 0:56Follow me on Mastodon, where I'm @mkennedy,
- 0:58and follow the podcast using @talkpython, both on fosstodon.org.
- 1:03Keep up with the show and listen to over seven years of past episodes at talkpython.fm.
- 1:09We've started streaming most of our episodes live on YouTube.
- 1:12Subscribe to our YouTube channel over at talkpython.fm/youtube to get notified about upcoming shows and be part of that episode.
- 1:20This episode is sponsored by Sentry.
- 1:22Sentry.
- 1:23Don't let those errors go unnoticed.
- 1:25Use Sentry.
- 1:25Get started at talkpython.fm/sentry.
- 1:28And it's also brought to you by us over at Talk Python Training.
- 1:33Did you know that we have over 250 hours of Python courses?
- 1:38Yeah, that's right.
- 1:39Check him out at talkpython.fm/courses.
- 1:43Hey, Mike.
- 1:43Hey, Michael.
- 1:44Welcome to Talk Python.
- 1:45I mean, it's awesome to have you here.
- 1:46Oh, thanks for having me.
- 1:48I'm really excited to be here.
- 1:49Yeah, I'm excited to have you.
- 1:51Always interesting to talk about security.
- 1:53I got to tell you, talking about security just makes me nervous.
- 1:57Oh, why is that?
- 1:58Well, two reasons.
- 2:00I feel like when you talk about security, you're kind of sticking your head up and people are like,
- 2:03let me see if I could whack that.
- 2:05You know, not everybody, but a few people in the world, right?
- 2:07But it is the internet.
- 2:09So if you take a very, very small percentage and multiply it by billions, it becomes non-zero.
- 2:15And then, you know, it's just one of those things.
- 2:18It's like trying to prove the absence of something.
- 2:22It's very hard to prove that you're not missing stuff some step.
- 2:27It's very hard to prove that you haven't, that there's not a, you know, you've got all the
- 2:30controls and there's not one control you forgot, right?
- 2:33In that regard, probably more so.
- 2:35It's pretty tricky.
- 2:36The way I've often thought about security is it's a spectrum, right?
- 2:40I used this quote a million years ago.
- 2:42I don't know who said it first, but the most secure computer is powered off and buried in
- 2:47six feet of under concrete, right?
- 2:50Like, but it's useless, right?
- 2:52Like it's very secure, but nothing in there is useful.
- 2:55So if we take that as like a crazy extreme of secure and say the most insecure computer
- 3:01is, you know, powered on, has zero password control connected to the internet and auto
- 3:06publishing IP data.
- 3:08So that way anyone can come and do whatever they want.
- 3:10All right.
- 3:11So that's the other end of the spectrum.
- 3:12That's a really bad situation.
- 3:14There's a fine balance that every software application system company has to kind of navigate
- 3:22to figure out where along those two crazy extremes, where do they fall and where are their kind
- 3:28of risk thresholds of tolerance are?
- 3:31Like, what would it cost me to add more security?
- 3:34Well, I could, you know, lock down all of my users and not allow them in unless they come
- 3:39to the front door and show a picture ID, right?
- 3:43Like, okay, if that's how we want to secure our building, that's one way to do it, but
- 3:48that'll slow down the ingress to our building.
- 3:51So we issue our employees badge cards and we assume that they act in good faith and they
- 3:56don't kind of lose them and report if they lose them.
- 3:58Oh, great.
- 3:59So that's kind of a middle ground where you kind of delegate some of the security to the
- 4:05individuals and, and just kind of, you have to figure out where, where your security
- 4:10is and what you're willing to do and sacrifice in order to get it.
- 4:15Yeah.
- 4:15I totally agree.
- 4:17Wild sidebar.
- 4:18I can't believe the internet in its early days was like you described, like no NAT firewalls
- 4:24that stopped direct access, no passwords, just, we might want to know who you are just
- 4:30so we can assign the files more conveniently to you, you know?
- 4:34Yeah.
- 4:34I hearken back to like the bulletin board days where you would dial up into somebody's random
- 4:39computer and you would do stuff in there.
- 4:41And I hosted a BBS and I interacted with others and it was like, we were all generally operating
- 4:48in good faith because we wanted to kind of play together.
- 4:51And not until much later did, you know, bad actors saying, you know what?
- 4:56I see how I could take advantage of this in a way that suits me and not you.
- 5:01Yeah.
- 5:01To which we started to say, all right, well then how do we control for these things today?
- 5:06That conversation comes into, you know, modern systems development of secure by design, right?
- 5:11Or, you know, a lot of folks will say shift left, right?
- 5:14Take security into account much earlier into the life cycle as opposed to, oh, we have
- 5:20to tack this on at the end.
- 5:22So I think, you know, the evolution of the internet was necessary for us to get to here.
- 5:28But as we're seeing newer protocols develop, those are taking this more secure by design approach.
- 5:35Yeah.
- 5:35In depth with layers.
- 5:37Were you a trade wars fan?
- 5:39Oh man.
- 5:40That's a name I have not heard in a very long time.
- 5:43That was a good one though.
- 5:44Yeah.
- 5:44I was very much a news and mail kind of relay kind of kid.
- 5:48Just wanted to see what was going on.
- 5:50Got very much involved in like understanding how the pretty good privacy would allow you to
- 5:57sign your messages.
- 5:59So that way other folks could believe that those were you.
- 6:02Right.
- 6:02And kind of like attest to truth.
- 6:04And that kind of fell apart because again, these are all imperfect systems.
- 6:08They were, but it was such a world full of possibilities back in those days.
- 6:13I remember even just sending a mail and getting it back through that whole systems of relays
- 6:18was, was mind boggling.
- 6:19At the time I was living on top of a mountain in, you know, in the middle of, of Israel and
- 6:25having that ability to connect with other people who there's no way I was ever going to see
- 6:33this variety of people back then, like, Oh, this opened the world.
- 6:37Right.
- 6:37Yeah.
- 6:38And that kind of fueled my, my desire to like, okay, what else can I do with these computers,
- 6:43with these systems?
- 6:43And Oh wait, there's this internet thing.
- 6:46All right.
- 6:46Well, my mom's going to be ticked off because I'm tying up the phone line for hours and like,
- 6:52all right, well, let's just have some fun.
- 6:54Yeah.
- 6:54That's when call waiting was the nemesis.
- 6:57So I bring, I kind of focus on that a little bit because while we're going to talk about
- 7:03things that are not necessarily positive or people trying to do negative things to something
- 7:08that we all love and has been a very positive thing for the Python ecosystem.
- 7:12I do want to point out mostly technology is doing really awesome things for people like
- 7:16opening these doors and educating and connecting.
- 7:19It's just some of the bad people, they like to connect and bad ways.
- 7:23So before we get too far down that let's, let's just have you give people a quick introduction
- 7:27about yourself.
- 7:28So, so they all know you.
- 7:29Hey everyone.
- 7:29I'm Mike Fiedler.
- 7:30I'm in New York city and that's where I've been living for the last 15 years, I say, I
- 7:36think.
- 7:36And I've been working in software development systems engineering for over 30 years across
- 7:42a couple of continents, variety of different companies.
- 7:45And for the past two years, I think, or three, I've been an active contributor to pypi.org.
- 7:53Prior to that, I was contributing to a lot of Ruby projects, the chef ecosystem, and I've
- 7:59worked at a variety of different companies, both startups and enterprises.
- 8:04You may have heard of some like Datadog, Warby Parker, MongoDB, Capital One, just kind of like
- 8:10working through different scenarios and learning different industries along the way.
- 8:14For the past year, I've been, well, since January, I've been focusing pretty much purely
- 8:20on pypi.org.
- 8:22You work for the PSF officially or what's the story?
- 8:25Yeah.
- 8:25As of August, I was hired to come on full-time.
- 8:28We thank you to our grants from Amazon Web Services, AWS, and some other folks that are
- 8:33chipping in to fund this PyPI safety and security role.
- 8:37But the PSF got some funding and I am the first full-time engineer to focus on pypi.org as a
- 8:46full-time.
- 8:46In the past, you've spoken to some other folks who were contracted out to build out different
- 8:52aspects or features.
- 8:53But now I'm a full-time maintainer.
- 8:56Yeah.
- 8:57That's really cool.
- 8:58You know, the developer in residence that Lucas Lange is playing, working in that role now.
- 9:03I feel like that was the first one of these types of roles, but now there's a couple, right?
- 9:07Yeah.
- 9:08I mean, the PSF is a nonprofit organization, very small staff.
- 9:13I think we number a total of 12.
- 9:16And of those 12, I think only about five of us are engineers.
- 9:20And everything else is volunteer-based.
- 9:22The first developer in residence program, which is Lukash, has been successful enough that we got
- 9:28another organization and grants to fund the security developer in residence, which Seth Larson is doing.
- 9:35And he's kind of focusing on the wider Python ecosystem as a whole.
- 9:40Whereas my role is very much more narrowly focused on PyPI.org and the ecosystem surrounding that.
- 9:48So that way, you know, we can focus on specific targets around security for the packaging world, as opposed to the Python core.
- 9:59Okay.
- 9:59Well, I do believe if you talk to people about why they like Python and especially why they stick with Python, the language is good.
- 10:07You can do cool stuff with it, but it's pip install, say your name.
- 10:12Say the name of your useful library that just brings so much and makes it so sticky and useful and productive.
- 10:21And so making sure that we have trust and pip install is really important.
- 10:26Last year, I think Dustin Ingram came on and talked about some of the stats that he had pulled together that speak about, like how much PyPI.org is used.
- 10:37That doesn't even count for the countless folk out there who are mirroring PyPI packages.
- 10:44So that way they can have a local cache, you know, deal with corporate firewalls or whatever need, right?
- 10:50But it's true.
- 10:51There's the very popular request library or the Django project.
- 10:56Pip install Django and you have all the things that you need to start a Django project, right?
- 11:02And the speed at which the folks who are kind of working on the tooling like pip or some of the other alternatives out there to enable users to get those packages is such a wonderful tool in anyone's toolbox.
- 11:17But then very often folks forget that there is an entire kind of package universe behind what they just did as a consumer, right?
- 11:27So pip install Django is, yeah, I got this thing.
- 11:30It installed it.
- 11:31Where did it install it from?
- 11:32How did it get there?
- 11:33Who put it up there?
- 11:35Why is it there?
- 11:36All of those questions, most people go their entire career with not even having to worry about or think about.
- 11:41They're just like on the consumer side.
- 11:43But then on the producer side or the package maintainer or project maintainer, there's a whole other slew of things that one has to worry about.
- 11:52Yeah, there's some stuff we'll talk about in there, which will be really fun.
- 11:55I think also there's the third level of just the people who run PyPI and the infrastructure and the stats behind it.
- 12:02I mean, maybe give us a quick, I kind of started us off down this path.
- 12:06Maybe give us a quick statement for those who don't necessarily know what PyPI is, but I think more interestingly, maybe try to give us some of the stats about the scale of things behind that.
- 12:15Sure.
- 12:15I mean, I haven't I haven't computed the runtime stats in a little bit, but PyPI.org stands for the Python package index.
- 12:23And it's distinct from other things that have PYPY in their name, which is a different runtime.
- 12:30But PyPI.org is a package index, very much kind of a grocery or a store where you would pick up ingredients for the thing that you want to bake.
- 12:41Right.
- 12:42If you wanted to bake a cake, you need your ingredients.
- 12:44What kind of flour are you going to use?
- 12:46What kind of sugar?
- 12:47Sure.
- 12:47There's different kinds of flour and sugar.
- 12:49Which one do you want?
- 12:50How do you know?
- 12:51You go and find one and where the package index helps is we store and publish all the different kinds of flour and sugar that you might want that other people have spent time developing.
- 13:03That doesn't mean that there is only one type of flour, but there is a variety.
- 13:08And we just make it easy for people to publish their projects.
- 13:13And as you've highlighted, there's over 480,000 projects live on PyPI right now and over 4.8 or almost 4.9 million releases.
- 13:24And a release is not a one-to-one to a project.
- 13:27A project may have many releases.
- 13:29So, for instance, if there is the requests library and they publish a new version, that comes as a release.
- 13:36And then beyond that, we have files.
- 13:39And files map to releases as you could have a source distribution.
- 13:43So, there's like literally the source code of a given release.
- 13:47Or you could have compiled wheels for different platforms.
- 13:51So, there's a lot more files than there are releases.
- 13:54And there's a lot more releases than there are projects.
- 13:57Yeah.
- 13:57And then on the last stat that we show on the front page is the users.
- 14:01We do have over 740,000 users on PyPI.org.
- 14:06That doesn't mean that these are active users, but they have at some point signed up for an account on PyPI.org.
- 14:13That's a huge number.
- 14:14And these are not people who might pip install a thing.
- 14:16These are people who, for some reason or other, are interested in potentially creating content for others to use.
- 14:22Exactly.
- 14:24Today, the only way you can publish a project on PyPI is by having a user.
- 14:29Or, you know, it starts with a user.
- 14:31There's other ways to publish.
- 14:32But you have to have a user to kind of start the process.
- 14:35And a lot of folks have started to kind of get the idea that if this project needs long-term maintainership, right, it's not just me.
- 14:46Maybe I should ask somebody else to help co-maintain this.
- 14:50So it's also not a one-to-one mapping of users to projects or releases or something like that.
- 14:55For sure.
- 14:57This portion of Talk Python To Me is brought to you by Sentry.
- 15:00You know Sentry for their error tracking service.
- 15:03But did you know you can take that all the way through your multi-tiered and distributed app with their distributed tracing feature?
- 15:09Distributed tracing is a debugging technique that involves tracking requests of your system, starting from the very beginning, like a user action, all the way to the back-end, database, and third-party services.
- 15:21This can help you identify if the cause of an error in one project is due to the error in another.
- 15:26Every system can benefit from distributed tracing, but they are especially useful for microservices.
- 15:31In this architecture, logs won't give you the full picture, so you can't debug every request in full just by reading the logs.
- 15:38Distributed tracing with a platform like Sentry gives you a visual overview about which services were called during the execution of certain requests.
- 15:47Aside from debugging and visualizing architecture, distributed tracing also helps you identify performance bottlenecks.
- 15:53Through a visual like a Gantt chart, you can see if a particular span in your stack took longer than expected and how it could be causing slowdowns in other parts of your app.
- 16:02Learn more and see some examples in the tracing section at docs.sentry.io.
- 16:07To take advantage of all the features of the Sentry platform, just create your free account.
- 16:12And for all of you Talk Python listeners, use the code TALKPYTHON, all one word, and you'll activate a free month of their premium paid features.
- 16:20Get started today at talkpython.fm/sentry-trace.
- 16:25That link is in your podcast player show notes and the episode page.
- 16:28Thank you to Sentry for supporting Talk Python To Me.
- 16:33Some of the changes coming, I think, allow for almost like a GitHub organization within PyPI, right?
- 16:40Rather than, well, we're going to create an account and that one account is for all of AWS, for example.
- 16:45Which is not really the right granularity, probably.
- 16:48It definitely isn't, but it historically has been, right?
- 16:51Like, that is just a feature we had never built.
- 16:54It was never a focus.
- 16:55But over the past year or so, I think we got funded to build out some of the organization's aspect.
- 17:04We have launched the community organizations.
- 17:08So that way, if you're running an open source project or an ecosystem there, you can sign up today and get an organization name.
- 17:16We are still working through a long backlog of organizations in order to approve them.
- 17:21It still requires an admin to do so.
- 17:24But we are still working through some of the complexities around corporate organizations when it comes to just as a nonprofit,
- 17:32how can we kind of figure out how to support corporations properly?
- 17:36Yeah, I've always thought that that was something of an opportunity to work with corporations more closely on PyPI and indirectly through the PSF.
- 17:47Your role exists because of these grants, because connections with certain high profile and high consumers of Python tech companies, right?
- 17:54Like AWS and others.
- 17:56But there's tons of companies that have things that support their product and at least their developers work with.
- 18:04And having a way to make them feel more at home on PyPI, I think is a good idea.
- 18:09Beyond what lots of organizations may do is, you know, have some of their in-house engineers contribute to PyPI.org, to the warehouse code base.
- 18:19It's open source.
- 18:20Everything you're looking at is open source.
- 18:22That's where I started.
- 18:24And that's the easiest way of like, oh, you want this thing?
- 18:27Open an issue.
- 18:28Talk about it with us.
- 18:29You know, if you want to go ahead and put some effort behind it, we'll welcome that too.
- 18:34But there is a wiki page out there of like packaging fundable improvement projects of like, all right, if you're considering throwing some money at the problem,
- 18:45here are some things we've thought about and would love your assistance with beyond that.
- 18:48Like there's other ways of just like straight up funding a role that can focus on a particular thing.
- 18:54Excellent.
- 18:55All right.
- 18:55Let's talk about supply chain issues.
- 18:58We were talking before we went live here that probably the biggest side of security or the biggest, at least from my perspective,
- 19:07what seems like a very huge opportunity for people to do bad things is to just upload malware basically of different ways, right?
- 19:15Sure, you could talk about hacking PyPI.org itself or other stuff, but I think that that's probably quite well covered.
- 19:22And it's more about, can I get tricked somebody and through various ways of installing something that they didn't.
- 19:29And that generally falls under the supply chain security sort of thing.
- 19:33So I wanted to just point out three examples that just show this is a industry wide problem, not necessarily a PyPI problem, but there is a PyPI manifestation of it, right?
- 19:43Yeah.
- 19:44And just to kind of lay the groundwork for folks who aren't familiar with supply chain attacks, the notion is that instead of an attacker trying to get onto your computer,
- 19:55they're going to go after something that they have a high probability of knowing is going to be on your computer through for the SolarWinds as kind of an administrative action.
- 20:07Well, you know, many, many SolarWinds were installed on servers, on computers.
- 20:12That's part of the supply chain that it's not, I'm not going directly after you.
- 20:16I'm going after something you consume, right?
- 20:19Right.
- 20:19And it can be very, very meta, right?
- 20:22So one of the examples that I would say that that falls under is this thing called Xcode Ghost.
- 20:27And so I believe this was primarily a Chinese problem,
- 20:30basically because in China there were a lot of App Store developers who weren't,
- 20:35either weren't registered as Apple developers or for whatever reason didn't go,
- 20:39maybe it's just a latency thing, didn't go through the App Store to get their Xcode or go through the developer portal.
- 20:44They just found like a local mirror.
- 20:46And what are those local mirrors?
- 20:48What could go wrong?
- 20:50I'll just get it from, you know, this IP address instead of apple.com.
- 20:54Right.
- 20:54Yeah.
- 20:55So what it did was it was a backdoored version of Xcode.
- 20:59So they weren't attacking even the things that people were using.
- 21:03They said, let's take over the developer's tool chain.
- 21:06So whatever they happen to be building, we don't know what that is,
- 21:09but we'll install a virus into their app.
- 21:11That app will go in the App Store.
- 21:12Then whoever installs that app will have it, right?
- 21:14These things get very indirect.
- 21:16This is kind of the challenge is like nobody until somebody surfaced this as an attack, right?
- 21:23Nobody thought this was a problem.
- 21:25This is kind of earlier to your comment of like, how do you disprove the existence of a problem?
- 21:32And a lot of it is just like, all right, we got to think about every aspect that goes into producing a given piece of software.
- 21:41But like the strongest answer here is don't download random stuff from people on the internet, right?
- 21:47Like I'm sure that this one in particular had a good reason for having a local mirror.
- 21:52But if you're going to local mirror it, then who is the local mirror and what is there?
- 21:57What are they doing, right?
- 21:58What kind of attestation or assurances do you have that they haven't modified anything in the process?
- 22:05It's very tricky because I might absolutely trust some company out there that's building a very popular.
- 22:10They have 10 million downloads like that.
- 22:12Surely that's fine.
- 22:14But one of their developers or one of their consultants to one of their developers may have, you know, misappropriately gotten their tools.
- 22:21And it's very hard from the outside to even know that that could be a problem.
- 22:26So these things are tricky.
- 22:27Yeah.
- 22:27I mean, the good news is that there's a large volume of security companies out there who, you know, make their bread and butter by scanning and looking for patterns that looks, you know, sneaky, tricky.
- 22:39And they spend a lot of investigative time digging into these.
- 22:43We get lots of reports from those types of folk of like, here, this is a new package.
- 22:49It looks, you know, fishy and here's why.
- 22:51And then we take action on those.
- 22:53I hear you.
- 22:54Hypo squatting was a big issue for a while.
- 22:58That's a form of supply chain attack.
- 23:01Like here, this Xcode ghost is we're going to get people to use a fake Xcode or a broken bad Xcode that they think is fine.
- 23:10Right. Instead of trying to say, take over Django, the package and do some malicious to it, try to take over Django or, you know, whatever.
- 23:19Right. Some common misspelling of that and upload that package.
- 23:24And you could even embed Django.
- 23:26Right.
- 23:26And so it still functions.
- 23:28It's like, I don't remember it being spelled this way, but it's working.
- 23:32So it got to be fine.
- 23:33Yeah.
- 23:33Typo squatting is, is, is very much a prevalent problem.
- 23:36Right.
- 23:37Because like, I can't prevent you from making a typo.
- 23:40Like I literally can't.
- 23:41If you type in Django, that's it.
- 23:43Game over.
- 23:44Right.
- 23:44What I can do is look or receive reports that Django exists.
- 23:50It looks malware.
- 23:50And let's just take that down.
- 23:52Let's not do that.
- 23:53Right.
- 23:53Yeah.
- 23:53The other sides we can do when it comes to type of, oh, well, you talked about typoscutting.
- 23:59And I was reminded of a, of, of an article I remember reading around DNS record bit flipping, where some computers, some browsers would not properly process a given bit in a memory register for a DNS record.
- 24:16So this author figured out what those bit flips would be for popular DNS names, registered those DNS names and started just harvesting traffic and said, you know what, this is not anything you can do.
- 24:28This is just how browsers and memory work.
- 24:30And that was, I don't know, about six, seven years ago.
- 24:33And I believe it's been fixed since, but it was like, yeah, there's sometimes there's just not anything that you did wrong.
- 24:39It's the ecosystem you're in is doing things in a way that you don't expect for something as nefarious as, as like DNS bit flipping.
- 24:49Like this is where like having outbound firewalls can help a whole lot to say, don't allow traffic that I didn't initiate in some manner.
- 24:58And if I did, have I, have I initiated the traffic to this address before?
- 25:03Do you remember zone alarm from the early two thousands?
- 25:07Yes.
- 25:08So this is before, this is, this harkens back to a slightly less naive version of, I can't believe there was no passwords on the accounts, just on the open internet.
- 25:17But windows 95, 98, there were no firewalls.
- 25:22And I was at a company that was based inside of a university where we all got ethernet and every computer that plugged in got its own IP address and all sorts of crazy stuff.
- 25:34But there were no firewalls.
- 25:35And I remember when that thing came out, I thought, you know what, maybe I'm just gonna go around and put this on all the dev machines.
- 25:41Like it's kind of insane that we have this incredibly insecure software just on the open internet.
- 25:47Yeah.
- 25:47And so I did in all the, when I started, it used to say, do you want to let such and such thing act as a server?
- 25:53Do you want to let IIS or, you know, engine X or this type of thing?
- 25:57Act sure.
- 25:58That can be a server.
- 25:59Then the next pop-up was, do you want to let notepad.exe be a server?
- 26:03I'm like, huh, that's not probably what it should be doing.
- 26:06Yeah.
- 26:07That doesn't sound right.
- 26:08That doesn't sound right.
- 26:09I said no.
- 26:10And then the next one and the next one, the whole company's notepad.exe were being servers.
- 26:15And I'm like, this can't be good.
- 26:17And it turned out they had something had infected it.
- 26:20And until I put on one of those outbound firewalls, how do you know?
- 26:23Right.
- 26:24No one knew there was no indication.
- 26:25We had, you know, super fast internet.
- 26:27It wasn't like it was dragging it down.
- 26:29I don't even remember what it was doing, but it was bad.
- 26:31The number one thing that I think we can learn from all of those things is that awareness is the biggest part of security.
- 26:38Because if folks aren't aware that downloading something from the internet could be a danger, then they're just going to download it and run it.
- 26:46If somebody who had a previously version of, you know, software working on their machine suddenly pop up and say, this has been modified.
- 26:56Are you sure you want to open it?
- 26:58So many of us just click OK without reading the dialogue.
- 27:01It's like, well, wait, think about that for just a second.
- 27:04Because you are the biggest kind of enabler and disabler of security, the human behind the keyboard.
- 27:11Because you probably have some administrative rights on your computer that allows you to do some stuff.
- 27:16And in the example with Notepad.exe, I think today, if we were to try to do that on some popular developer environment like VS Code,
- 27:27VS Code does act as a server in a lot of cases.
- 27:30So it's like, I don't know, should this work as an inbound server or not?
- 27:34I don't know.
- 27:35Maybe this is just part of the local language server that I need for autocomplete.
- 27:39Yeah.
- 27:39Or maybe it's not.
- 27:41It's getting more subtle every day.
- 27:43It is absolutely getting more subtle.
- 27:45Even Zoom had like a local loopback web server thing, I think, for a while.
- 27:48All right.
- 27:49So before we move off of this typo squatting part of the conversation, out in the audience, we have a pretty decent question here.
- 27:55What's the possibility of something like a verified badge for popular packages?
- 27:59I mean, if Twitter can charge $8 a month.
- 28:02No, I'm just kidding.
- 28:04I don't think they're called Twitter anymore.
- 28:06But...
- 28:08The artist formerly known as Twitter.
- 28:09Yeah.
- 28:10The challenge there is, what does verified mean, right?
- 28:14This is something that we kind of introduce some features later on that we'll talk about.
- 28:18But this notion of verified is like, well, verified by whom?
- 28:22Where does the level of trust?
- 28:23Because if a supply chain attack happens for Django, so if you were to like search Django here in PyPI.org, and we get Django, all right, we've got Django, the second line, Django 425.
- 28:35And if we were to enter there, like, how do we know?
- 28:38Yeah.
- 28:38This is a thing, right?
- 28:40So I could add a badge here, but that doesn't give me any confidence that any of the Django folk, which are, you know, great people, that one of them didn't get compromised and suddenly a new version was pushed.
- 28:50So verified, I guess, it's what does that mean to whom and why?
- 28:56Because the last thing I want to do is tell people, give them a false sense of security when, honestly, you're downloading software from the internet.
- 29:04If you don't have a process to vet what it is you're doing is doing the thing, then you should probably look at that aspect of a, we vetted this version of Django.
- 29:15We got these hashes.
- 29:16We got these hashes.
- 29:16We got these releases.
- 29:17We pin this dependency.
- 29:19We're happy with this.
- 29:20And then when you upgrade, you kind of do a similar evaluation.
- 29:25There's a bunch of projects out there like PiUp and safety and others that will publish, you know, and scan for advisories.
- 29:32There's also the PiPA advisory database for packages that we know have some problems with them.
- 29:40So that way you can use other tools to audit what you have installed to see if you have something smelly.
- 29:46But we are thinking about what it would look like to add a, this release and these files of a given project have been published under, you know, stringent, you know, more secure methods.
- 30:00Yeah, I certainly see that a verified wouldn't prove that the Django devs hadn't, you know, somebody could have taken over their computer and swapped out like twine or poetry or whatever they're using to upload the package and do exactly what they did with Xcode ghost, basically.
- 30:17Right.
- 30:17Right.
- 30:17Something equivalent to that.
- 30:19So the last part we want to do is like, we don't want to give people a false sense of security and say, well, PiPI told me this was okay.
- 30:26And then they find out it wasn't because then that looks really bad for us.
- 30:31But on the flip side, we are looking at how do we provide mechanisms and measures to publishers to reduce the potential for the situations that you described to happen.
- 30:46This portion of Talk Python To Me is brought to you by us over at Talk Python Training.
- 30:51Let me tell you about one of our really popular courses.
- 30:55HTMX plus Flask, modern Python web apps hold the JavaScript.
- 30:59HTMX is one of the hottest properties in web development today.
- 31:03And for good reason.
- 31:04You might even remember all the stuff we talked about with Carson Gross back on episode 321.
- 31:10HTMX, along with the libraries and techniques we introduced in our new course, will have you writing the best Python web apps you've ever written.
- 31:17Clean, fast, and interactive.
- 31:19All without that front-end overhead.
- 31:20If you're a Python web developer that has wanted to build more dynamic, interactive apps, but don't want to or can't write a significant portion of your app in rich front-end JavaScript frameworks,
- 31:30you'll absolutely love HTMX.
- 31:33Check it out over at talkpython.fm/HTMX or just click the link in your podcast player show notes.
- 31:39All right, let me throw some ideas out to you and tell me what I think.
- 31:46So as I think about this, especially when the very first news a couple years ago, I can't remember exactly the time frame, but not very long ago, the first malicious PyPI package.
- 31:55You know, npm had been getting whacked on for a while because JavaScript, YOLO.
- 32:01But, you know, when it came to PyPI, I was like, okay, this seems to be a little more serious, a little more pervasive.
- 32:06And they were often typo-squatting type of issues.
- 32:10Or people would introduce some package and say, here's a cool thing, you should check it out, and it's really a virus.
- 32:16Or one of those types of things.
- 32:17So one of my thoughts, one of the metrics I would have liked, or maybe in the future will like to apply to my local Python environment is,
- 32:27don't let me install packages that are too new.
- 32:31Or don't let me install packages that have too few downloads.
- 32:35And give me a mechanism to say that.
- 32:37Like, I don't want to ever say pip install something and that something has not existed on PyPI for less than a week.
- 32:43I don't ever want to be able to say pip install something and that thing has less than a thousand or ten thousand, whatever, downloads.
- 32:51Unless, and they could say, nope, you can't install that.
- 32:53It breaks your rules.
- 32:54You could say, okay, no, I actually uploaded this.
- 32:56I really need to, you know, you could do like a pip install of force, --force.
- 33:01You know, some kind of override.
- 33:02But by default, if I could just say, you know, it has to have at least 5,000 downloads.
- 33:06Or I just don't want it.
- 33:07I feel like at that point, somebody would have discovered, oh, you know what?
- 33:10Is actually using 100% CPU usage and crypto mining or whatever it happens to be doing.
- 33:15I don't want to be the first guinea pig in the world to discover this.
- 33:18What do you think about this idea?
- 33:19The download count one is always an interesting one, right?
- 33:22It's a topic that comes up a lot.
- 33:23And like, I can tell you personally from experience that writing a little loop to increase download counts is super easy.
- 33:32Interesting.
- 33:32Like, write a wild true pip install something and like, you'll drive up download counts.
- 33:39It will be meaningless in the grand scheme of things.
- 33:41So you could say, well, maybe make it like, it's got to have, you know, a thousand distinct IP addresses.
- 33:46But then, you know, if you own a botnet, then you're good to go.
- 33:48Okay.
- 33:49Fair.
- 33:49This becomes like the cat and mouse game of like, all right, well, what is something that is good?
- 33:55Today, we have a mechanism where we don't advertise new packages that have been there for, I think, under a week to any kind of crawlers.
- 34:05So any search engine crawlers.
- 34:07So if you were going to like Google for Python Jangu and it was a brand new package, you wouldn't find it via Google because we wouldn't advertise that for indexing yet.
- 34:18Right.
- 34:19But after a week, like we do.
- 34:20So that's one method that we have for preventing some of these like newer packages from getting widespread visibility because they, you know, everything is a webpage.
- 34:32They are all subject to search engine optimization.
- 34:34Somebody could craft their readme to, you know, be the best hit on Google and therefore they'll show up first.
- 34:41And with all this crazy AI stuff, it's only getting easier.
- 34:44Hey, ChatGPT.
- 34:45I would like to create a page that is like the Django pypy page, but I wanted to rank highly for this.
- 34:51Something that we are talking about internally of like, how do we put packages that are brand new, either from some heuristic of a brand new user or a brand new version or differs enough from the previous versions and kind of put those in kind of a holding or a timeout zone to let our security research partners who are really excellent at like just listening to the package feeds and going after and just running all their analysis on them.
- 35:19To give them first crack, right?
- 35:49What was the kind of reference there just a moment ago?
- 35:51Having like published allow lists, right?
- 35:54These are very prevalent in large corporations that have very strong security policies and they have teams of folks that will maintain internal mirrors of a package index.
- 36:04So they will disallow any pip install of anything unless you're using their package index.
- 36:11And I think that is another tool in the security toolbox to have people who are that like security focused to say we will only allow in the things that we have already tested to be true.
- 36:25We vetted them.
- 36:26And those kind of match our heuristic.
- 36:29If you scroll down a little bit on the Django page, almost every sidebar to every one of these has these statistics.
- 36:37This particular one shows GitHub statistics because this package has a GitHub URL.
- 36:41But there's also libraries.io, which is not affiliated with PyPI.org.
- 36:47They're just a really great service.
- 36:49And you can search for packages of any shape, kind of any ecosystem.
- 36:53But they have a really good kind of ranking system.
- 36:57Again, if it works for you, the crux of it, don't install garbage off the internet, right?
- 37:01Check out what you're doing.
- 37:02But by using something like libraries, which I don't know why that didn't load.
- 37:07Probably was just getting a virus.
- 37:08I probably misspelled it.
- 37:09Oh, yeah.
- 37:09It's good.
- 37:11But they offer a nice set of stats around a given package so you can try and be a little bit more informed on your own.
- 37:21The challenge there remains that nothing is going to tell you on libraries.io or PyPI if somebody has uploaded malicious software and this is a bad one.
- 37:32The best we can do is once we know about it, we handle it.
- 37:35Yeah, I feel like PyPI has been pretty on top of it.
- 37:39We try.
- 37:39I published a blog earlier today where I pulled together a lot of analytics and stats from our inbound malware reporters.
- 37:47And it's looking pretty good.
- 37:50We handle over 80% of inbound reports in under 60 minutes.
- 37:54You know, I go into the article about like the whys and wherefores, the timeliness matters and the response time.
- 38:00Because the longer something is out there, the worse it can contagion to other, you know, other folks.
- 38:07Yeah.
- 38:07So we try and do as quick as possible, often under like five to 10 minutes.
- 38:12But we also have to do some investigation and kind of like confirm that the report is accurate.
- 38:17We don't want false positives.
- 38:19Most of our research researchers don't give us false positives.
- 38:22So shout out to all those folk.
- 38:24But it's hard and time consuming.
- 38:27I remember one of the more recent PyPI supply chain issues where somebody uploaded something bad was attributed to all these different ATP and hacking groups have cutesy names like the SolarWinds was by something bear.
- 38:43Which bear?
- 38:44Which bear?
- 38:44Cozy bear.
- 38:45That's the kind of bear it was.
- 38:46Which is really Russia state actor hacking, right?
- 38:50And one of the PyPI ones was North Korea.
- 38:53And I think they were doing crypto mining on computers, which seems like a real big waste of I have access to the server in a bank.
- 39:01But anyway, it works for them.
- 39:03It works for them, you know?
- 39:04But the reason I bring this up is like, it's you all have a serious challenge in that if you're up against state actors from a security perspective, like that's not just script kitties or some weird automation or, you know, like those are you guys got to be on top of top of your game, right?
- 39:21This is, again, where I think relying on our ecosystem of security partners is so important because they will corroborate intelligence that they've garnered from other ecosystems that are beyond PyPI and be able to identify these kinds of actors.
- 39:37Me, I see kind of just a slice of what the universe has.
- 39:41They're going to see a different slice, but broader in spectrum and not necessarily as focused on one particular ecosystem.
- 39:50So working together, we can kind of do the best that we can for all the users out there.
- 39:56Excellent.
- 39:56So we talked about hyposquatting, which is serious, but also kind of the silliest, kind of not that big of a deal because recommendations could be like, you know, actually use a requirements management system rather than just every time you create a new environment, just type pip install X, Y, and Z.
- 40:14Like the chances you might fat finger that versus pip install -r requirements.txt or, you know, poet, something with poetry or whatever.
- 40:22Right.
- 40:22So that helps a lot, although it's not perfect.
- 40:25The other one is more the Xcode go style.
- 40:28Like what if somebody were to take over one of the other systems and you all had over here, you have a new two factor requirement for PyPI.
- 40:39Do you want to talk about that?
- 40:40Yeah, absolutely.
- 40:41This also was covered on an earlier podcast of Talk Python where I think in 2022, we had announced that we were starting to ratchet down the amount of potential.
- 40:55I think you got the wrong link there.
- 40:57I do have the wrong link.
- 40:58Keep going.
- 40:59It's Dustin.
- 41:00Dustin Ingrams.
- 41:02Yes, exactly.
- 41:03I thought I pulled it up.
- 41:04I put the other one twice.
- 41:05There we go.
- 41:05The 2FA story is largely, again, we talked about there's about 740,000 users, right?
- 41:11These are the publishers of packages, right?
- 41:14So if in our use case, we talked about Django devs, right?
- 41:18And I'm sorry to pick on Django.
- 41:20They're just the one that's up there.
- 41:21But if one of the Django devs was using a classic problem, which is an email expiry or a domain expiry attack.
- 41:29So let's say I'm a Django admin maintainer and I use MikeTheMan.com as my email address, right?
- 41:36And that's great.
- 41:37Because we don't want to use Gmail.
- 41:39We don't want to use or, you know, the .me or Outlook.
- 41:43I'm a good citizen of the internet, so I got my own domain.
- 41:46Yeah.
- 41:46I just haven't been paying attention, right?
- 41:48I haven't been paying attention this year.
- 41:49Right.
- 41:50And then let's say I let it expire.
- 41:52Whoops.
- 41:53You know, like that happens.
- 41:54People forget to pay their bills.
- 41:56Or your credit card gets stolen and canceled.
- 41:58You forget to renew it there.
- 41:59And then the other thing goes to spam.
- 42:01Like it could actually be super easy that that happens.
- 42:04And it happens all the time, right?
- 42:05Like people, there are numerous domains that I've registered over the year that I was like, yeah, I don't need that anymore.
- 42:10Hopefully I have never used anything from that domain to sign up for anything securely that's there.
- 42:16But then someone else can come along and register, MikeTheMan.com, set up an email server, request a password reset, get that email.
- 42:24And now they can do anything I could have done before.
- 42:28With 2FA, that entire set of problems goes away.
- 42:32And we're not even talking about like phishing.
- 42:34If somebody phishes my password or if they use the same, if I made the mistake and use the same password on two websites and one website stored it in securely and they pop that in a breach.
- 42:45And, you know, now they have my username and password.
- 42:472FA just solves.
- 42:49Do you discourage that using the same username and password?
- 42:51I absolutely discourage that.
- 42:53I find it very inconvenient to have a separate password.
- 42:55I just use the letter A.
- 42:56Yeah.
- 42:56That's a choice, right?
- 42:58It's a bad choice.
- 43:00No, like the amount of tooling out there today, both free and paid for password management is just so pervasive.
- 43:09It's almost like irresponsible to not use one.
- 43:12I 100% agree.
- 43:13Yeah.
- 43:14I always use one password.
- 43:15I think, I don't know if it'll tell me how many I have in here, but I think it's coming up on like 1,500 and not quite, just under a thousand different distinct passwords and accounts.
- 43:28You know, a lot of people don't want to pay for it.
- 43:30Bitwarden.
- 43:30Bitwarden is fantastic.
- 43:32It's open source.
- 43:32I don't know if you got a recommendation, but you're right.
- 43:35It's irresponsible.
- 43:36I mean, I'm a 1Password fan.
- 43:37It's just a great tool.
- 43:39I used it back when, when it was like a single thing.
- 43:42Then, you know, I used it as a, as a organization account, right?
- 43:46Like the, I was an admin for our org and like managing that life cycle was pretty sweet.
- 43:51And then it's like, okay, we have this as an organization.
- 43:54We have over 400 employees.
- 43:55Why doesn't everyone have this right now?
- 43:57So, you know, it became a good rollout, but, but having a second factor, a 2FA or multi-factor MFA, I think is this notion of something you have versus something, you know.
- 44:10So let's say that even by using a password manager, you don't know that password anymore, right?
- 44:15Like you don't remember it, but let's say you do, right?
- 44:18Like, let's say somebody gets your entire vault of passwords.
- 44:21They still don't have this second factor, which is often a time-based one-time password or web authentication device, which could be a hardware device or a browser fingerprint.
- 44:34Like they don't have that, right?
- 44:36It's a defense in depth kind of problem that is solving where it's like, you need, you need to have two things in order to get through this door.
- 44:45And if you only have one, that's not good enough.
- 44:49Using that capability and having that ability on PyPI user management has enabled us to roll out a higher grade of security for the packages and maintainers of those packages by attesting that, well, we know that this maintainer or this publisher of this package has already secured themselves.
- 45:14So against these kinds of attacks.
- 45:17Yeah.
- 45:18I can just hear the voices.
- 45:20In fact, they don't come through an audio form.
- 45:22They come in email.
- 45:23Like, you know, on that last episode, sometimes they come through on the artists formerly known as Twitter.
- 45:28Sometimes they come through an email, but like, you know, Michael, you said that two factor will help.
- 45:33You realize, you don't seem to realize, I'm saying I realize, so I don't get this email.
- 45:38Please don't email me.
- 45:39That this doesn't stop phishing.
- 45:40Like people could still phish you.
- 45:42You could go in, they could ask for your username and password, then they'll ask for your time-based authentication.
- 45:47And then they're in.
- 45:48Yes, that's true.
- 45:49But it stops some things.
- 45:52And stopping some things rather than going, well, it's not good enough, so I'll do nothing is certainly not a responsible way to go, I think.
- 46:00It's kind of like making the argument that if nothing is perfect, don't do anything at all.
- 46:05Yes, exactly.
- 46:05Right.
- 46:06That's a fallacy.
- 46:07If you're going to die, don't get out of bed.
- 46:09Right?
- 46:10Like, no, like, we get out of bed, we go to work, we do our things, right?
- 46:13We ultimately, as sad as it is, right, we have an end date.
- 46:17We hopefully don't know what that is.
- 46:19But like, do the best you can while you can.
- 46:21That's where I come to from.
- 46:23Like, this is the best we know.
- 46:25Yes.
- 46:26Will there be something new and exciting tomorrow that is even better?
- 46:29Maybe.
- 46:30But until then, let's do the thing that we know to be the best that we can do right now.
- 46:35Right.
- 46:35Maybe Pasky's will be awesome.
- 46:37I don't know about that.
- 46:38But for example, you know, from a phishing perspective, things like 1Password and Bitwarden have plugins for your browsers, and they will suggest to autofill on the right domains.
- 46:49But if you're on pypi.io, is it a pypi.org or, you know, whatever, right?
- 46:56If they're on some kind of phishing domain, they will not suggest to autofill.
- 47:00Right.
- 47:00If you find yourself going to your password manager and going, God, why does this not work?
- 47:04Like, let me just copy this over.
- 47:06Stop.
- 47:07Figure out why it's not working really, really, really well before you somehow subvert this broken extension that won't autofill.
- 47:15Right.
- 47:15So there are ways to limit phishing through these mechanisms, even if they're not perfect.
- 47:21Exactly.
- 47:22I think I said this before, but like, I'll reiterate it.
- 47:25You, the human, are the best defender.
- 47:29Use your logic.
- 47:30Use your sense.
- 47:31Like, don't just click at things mindlessly.
- 47:33Take a moment.
- 47:34Take a look.
- 47:35See, that error message, that looks weird.
- 47:38Why does that look weird?
- 47:39The domain I'm on looks a little odd.
- 47:42The little browser lock symbol isn't locked.
- 47:45Why is that?
- 47:46Hmm.
- 47:47Take a moment.
- 47:48Nope.
- 47:48Had not exe once stacked at the server.
- 47:50Yes, I want to load it.
- 47:51Come on.
- 47:51Yes, let it.
- 47:52Just, I got it.
- 47:54Yeah.
- 47:54The reason, I think the news around the 2FA for PyPI.org is not that it exists, but that it's required now.
- 48:03I think that's what's different since I spoke with Dustin.
- 48:05We've been on a path, and as you've got this blog post open, we've been on a path of like, starting with the carrot.
- 48:12We want to like, provide as many people in the packaging ecosystem, all the incentive, all the time, all the kind of expectation that they could have in order to set this up voluntarily, right?
- 48:24Like, there was even a wonderful giveaway of hardware security keys that like Google sponsored, which is excellent.
- 48:32That doesn't mean you need a physical security key.
- 48:35You can use them.
- 48:36You can use software security keys.
- 48:38Google Authenticator or any other tool.
- 48:40Duo Labs has a nice one.
- 48:42But like, anything in order to kind of move the bar on this 2FA engagement.
- 48:48And we've seen some decent adoption.
- 48:52And it's like, okay, well, now let's set a timeline.
- 48:55This post by Donald kind of starts the clock on that.
- 48:59And we are basically drawing a line in the sand that's saying at the end of 2023, if you want to publish a new package, like, that's it.
- 49:08You need to have 2FA.
- 49:09We've started on that process by requiring 2FA for new users.
- 49:17So if you registered today, you need to set up 2FA.
- 49:20Like, if you've been around for a while and you don't have it yet, we'll still allow you to upload, but we'll send you a notice that's saying, here's what's going to happen at the end of this year.
- 49:30And we've slowly been kind of ratcheting down the areas at which 2FA is not required with the intent on basically January, December 31st, January 1st, 2024, enabling the requirement on all accounts.
- 49:46So that way we can kind of walk away from the problem of, well, I guess one of the Django maintainers got fished.
- 49:54And that's why we had a big issue in the ecosystem.
- 49:57Like, I don't want that to be the problem.
- 49:59And again, apologies to Django.
- 50:00Y'all are awesome.
- 50:01It's because they're so popular and loved that you pick on them, I can tell.
- 50:04Yes, yes.
- 50:05Again, this doesn't completely solve all fishing attempts, but it certainly is another layer of defense.
- 50:13So I think it's certainly worth doing.
- 50:15Now, there was a bit of a pushback.
- 50:18I think somebody even like rage quit their package temporarily and then said, oh, no, I want it back on PyPI when this came out as if it was a big deal.
- 50:26And this is, you know, this blog post was from May.
- 50:30The deadline is end of 2023.
- 50:33In between those two times, GitHub just comes out and goes, everyone gets 2FA right now.
- 50:37I don't care.
- 50:37Right.
- 50:38And this is such a broader, broader, more impactful thing in terms of the many people use Python who are not creating packages.
- 50:46But almost everyone who uses Python is also in some way using GitHub.
- 50:49And so it just touches so much more of the ecosystem and people are like, oh, OK, I don't know why there was so much blowback in one and not the other.
- 50:56But it's an odd thing.
- 50:59Right.
- 50:59Because on the one hand, PyPI or the index itself, right, has been around for about 20 years.
- 51:06This is a long lived concept in the Python ecosystem of having a place where people can publish software freely, no charge, and others can install that software.
- 51:19This requirement is a shift.
- 51:23Right.
- 51:24Yeah.
- 51:24And a lot of folks are like, well, what else is going to happen?
- 51:27It's like, well, probably nothing.
- 51:29Right.
- 51:29I don't see us talking about other requirements or enforcements unless they're necessary.
- 51:36Again, I can't predict the future.
- 51:37And if somebody says that pass keys are the best way and TOTP is broken and proves it and the industry-wide decides, oh, wow, this is not a good idea.
- 51:49Let's do this other thing.
- 51:51Then maybe we'll do that.
- 51:52But until then, this is the best we've got.
- 51:56The requirement for 2FA is even on the OWASP top 10 list of why you should be doing this.
- 52:05And it's like, this is what governments use, companies use, and auditors use to say, we are adhering to the best practices.
- 52:13Because if you had a security vulnerability reported to your company because you weren't using 2FA, you know, auditors will say, well, why not?
- 52:21It's in the, like, top 10 list.
- 52:22It's like the SQL injection of yesteryear.
- 52:26Yeah.
- 52:26Just like, just do this.
- 52:28Right.
- 52:29Just solve this class of problem.
- 52:31You will have other problems.
- 52:32We all have problems.
- 52:33But solve the ones that we know are relatively easy to solve.
- 52:37Good advice.
- 52:38I feel like, you know, when the two-factor software problem, like, that's not good enough.
- 52:44You know, these YubiKeys and stuff are too tricky.
- 52:47We're just going to go back to SMS.
- 52:49Like, that's, that's where it's, what?
- 52:51I cannot believe that my bank will let me use 2FA.
- 52:54They forced me to use.
- 52:55SMS.
- 52:55SMS.
- 52:56You might want to check out for different banks.
- 52:58Well, it's like one of the top four banks in the US.
- 53:01It's nuts.
- 53:01They also have limits on the length, not lower bounds, upper bounds on the length of the password.
- 53:07My, ooh, that.
- 53:09That, that, I understand why.
- 53:11Right.
- 53:13Upper bounds, I understand why.
- 53:14But it usually boils down to, like, database design and, like, the cost of doing a database migration.
- 53:19I hear you.
- 53:20Like, I think it's like 12 or something.
- 53:21It's very short.
- 53:22Oh, that's short.
- 53:23That's way too short.
- 53:23But here's the thing.
- 53:25Do you know, it doesn't matter if you have one letter or a hundred letters.
- 53:27The hash is still the same length.
- 53:29Depending on how you're hashing it.
- 53:30Yeah.
- 53:30Yeah.
- 53:31But they will not be stored.
- 53:32Like, if they're not storing the hash, it makes me extra nervous.
- 53:35Yeah.
- 53:36Anyway.
- 53:36Onward.
- 53:37I'm glad they got the SMS 2FA backing it up.
- 53:41Yeah.
- 53:42Another thing that I, that I, that I, that I do want to kind of plug on the, the, like, the security spectrum and kind of to address the question around, like, verifiable releases is something that we launched earlier this year, which is called trusted publishers.
- 53:54That's right.
- 53:55That's alluded to, or linked to in the, there we go on, on our docs.pypi.org of what it is.
- 54:02Links in the show notes.
- 54:03People can check it out.
- 54:04Yeah.
- 54:04So, you know, it's a great thing where we leverage an open standard called OpenID Connect.
- 54:08And today we only implement this with one publishing tool called, you know, GitHub Actions, where the service GitHub Actions is now delegated to be a trusted publisher for your project.
- 54:22When you set this up, you have to opt into this completely.
- 54:25We didn't do this for you, but you can now opt in to say GitHub Actions is allowed to publish my project.
- 54:31And then you can say, you know what?
- 54:34None of my humans are allowed to publish the project.
- 54:37The computer that is getting a short lived token for like five minutes or 10 minutes, whatever it is, is allowed to publish this package and no one else is.
- 54:46And that's how we can start to build the levels of attestation and kind of the software supply chain security to say, I know where the source code is.
- 54:57I know the source code that built it.
- 55:00I know the builder who built it.
- 55:01I know the builder who published it and no one else tampered with it in the, in the interim.
- 55:07We're not there to like prove that nobody else tampered, but we are there to say, I can now delegate authority to GitHub, GitHub Actions to perform this release for me, as opposed to me creating a token in PyPI and giving that token to GitHub Actions.
- 55:25That's how we did it before.
- 55:26Right.
- 55:27A long lived permanent token that you put in plain text somewhere, right?
- 55:32What could go wrong?
- 55:33I mean, usually like an environment variable or secrets and GitHub Actions, they have pretty good ways of securing data.
- 55:40But again, it's long lived.
- 55:41So if anything ever happened over there, if anybody dumped a debug log that they shouldn't have, that token could be there.
- 55:48So by using a trusted publisher flow, you can now have your GitHub Actions deployed directly to PyPI.org once the artifact is complete and not have to do that token management.
- 56:03So we're getting short on time, Mike.
- 56:04What else do you want people to know about what you all, in particular, what you're doing at PyPI and some of the initiatives and maybe how they can help?
- 56:14The top of mind for me right now is the malware reporting project that we're engaged in.
- 56:19And that's kind of linked to at the very bottom of my blog from today, the Inbound Malware Reporting Blog, where we are looking to establish what a kind of machine readable protocol would be to interact with security researchers.
- 56:33A few of them have chimed in already on what they think of, and we're just kind of building the conversation around what it would look like to report, how do you like to report?
- 56:42And then we'll proceed with whatever guidance we get there and kind of build out the payloads and stuff like that all the way at the bottom, very bottom, all the way at the bottom.
- 56:53There we go.
- 56:54And once we have this format in place, we're going to be building out like the infrastructure and ecosystem in order to submit those payloads and then figure out how to kind of put packages in timeout while these payloads are being investigated.
- 57:08So that way we can continue to provide a secure ecosystem for all users of PyPI.org.
- 57:15I think that's great.
- 57:16Certainly, you know, these companies that are checking out and just monitoring the flow of packages and scanning them, that's a huge service.
- 57:24Is there, there probably is, never will be like a bug bounty equivalent?
- 57:30Is there?
- 57:30I mean, never say never, but.
- 57:32Never say never.
- 57:32From that perspective, it becomes a bit of a challenge because then you could start funneling money through a bug bounty program because we are offering an ability for people to create packages.
- 57:44And then saying, we're giving you a monetary incentive to report them to us.
- 57:49So it's like, well, now we've given you a pipeline for money.
- 57:53There's a whole shadow industry of like, you first create it, then you get it popular, then you report it.
- 57:58Yeah.
- 57:58Yeah.
- 57:59Yeah.
- 57:59No, I hear you.
- 58:00Yeah.
- 58:00But, you know, no, no idea is too far fetched.
- 58:04We like talking about ideas and figuring out what, what makes sense.
- 58:07And kind of, again, with, with a lot of security work is like, okay, well, how can this go wrong?
- 58:12How can this fail?
- 58:14Right.
- 58:15How can it be gamed?
- 58:16Yeah, absolutely.
- 58:18Well, I, for one, feel better that you're putting all your time and energy into focusing on these problems and seeing how we can make PyPI better for everyone.
- 58:26Almost everyone.
- 58:27Not for everyone.
- 58:28For the 99.9% of us.
- 58:30For most people.
- 58:31Just wanting to use it in a solid way to build Python software.
- 58:34That's kind of why I was drawn to it, right?
- 58:36Like, to contributing to it is such a foundational piece of modern day infrastructure that it's important that it be safe, secure, convenient, useful to anybody who wants to use it.
- 58:50Because Python itself is such a ubiquitous language across the planet and beyond that, you know, we want to make it the right thing.
- 58:58Yeah.
- 58:59Surprisingly, every time you say that statement, it's more true.
- 59:02Like, that graph continues to go up in surprising ways.
- 59:06All right.
- 59:07Before we get out of here, I'll ask you one of the final questions.
- 59:09Notable PyPI package, not malware-ridden, but a good, useful one.
- 59:15What do you recommend?
- 59:16Anything you come across that's awesome lately?
- 59:18A huge fan of pytest.
- 59:19And I know that, you know, you're big pals with Brian Okken.
- 59:22Hey, Brian.
- 59:23Who talks a lot about testing.
- 59:24And pytest plugins are a wonderful extension to pytest.
- 59:29Yes.
- 59:30And there's so many of them out there.
- 59:32And there's even like an awesome pytest aggregator of these.
- 59:37And I think I have one on here, which is called pytest Socket.
- 59:41Nice.
- 59:41Which I maintain till today.
- 59:43But the one that I want to point out is one that I recently learned about, which is called ICDiff.
- 59:49I, the letter C, diff.
- 59:51I don't even know if it's on this.
- 59:53It's the letter C.
- 59:54I gotcha.
- 59:55Yeah.
- 59:55There it is.
- 59:56So that's not the pytest package, but there's an extension pytest ICDiff.
- 1:00:02We'll get there.
- 1:00:03So this uses that other one.
- 1:00:04But the notion here is a lot of times you get big pytest output if you're comparing, you know, dictionaries, lists, or stuff that has lots of data.
- 1:00:13Sometimes detecting the difference is very hard in the terminal.
- 1:00:18And the pytest ICDiff extension will help highlight a lot of these with colors, with spacing, which makes finding the problem much easier.
- 1:00:28Yeah.
- 1:00:28That seems super helpful right there.
- 1:00:30And it does a partial character by character diff and line by line diff with different colors.
- 1:00:35Yeah.
- 1:00:36And here's what we expected.
- 1:00:37Here's what you got.
- 1:00:38Yeah.
- 1:00:39Yeah.
- 1:00:39Also, I'm learning that there's even more madness to the pretty print.
- 1:00:44So it could say from Pprint, import Pprint.
- 1:00:47But there's also apparently a Pprint PP with PPI.
- 1:00:51Okay.
- 1:00:52Yeah.
- 1:00:53I don't know.
- 1:00:54It's more things to explain.
- 1:00:55It's always, it's going to be in one of those 400,000 packages on PyPI.
- 1:00:59Right.
- 1:00:59It's got to be there.
- 1:01:00It's got to be there.
- 1:01:01And it might be a little different.
- 1:01:03It might be just enough different to meet this use case that is, you know, perfect.
- 1:01:09Yeah.
- 1:01:09Yeah.
- 1:01:09This is Pprint++.
- 1:01:10That's what the PP is like.
- 1:01:13CPP at the end.
- 1:01:14Okay.
- 1:01:14Got it.
- 1:01:14Notepad++.exe.
- 1:01:16It wants to access the server.
- 1:01:18All right.
- 1:01:19Let's leave with that.
- 1:01:19I guess a final thing.
- 1:01:21People are excited to hear about this.
- 1:01:23They want to get engaged.
- 1:01:25You know, they have ideas.
- 1:01:26They want to reach out to you.
- 1:01:27What do you say?
- 1:01:28Open an issue for us on, you know, the warehouse repository.
- 1:01:31If it's relevant to the warehouse code base.
- 1:01:34If you need to reach me directly, I'm on GitHub as Mike, the man.
- 1:01:38I'm on Mastodon as Mike, the man at hackyderm.io.
- 1:01:41Or if all of that fails, go ahead and email me at mike at python.org.
- 1:01:47Awesome.
- 1:01:48Thank you so much.
- 1:01:49Thanks for being on the show and giving us a status report here.
- 1:01:52Absolutely.
- 1:01:52Thanks for having me, Michael.
- 1:01:54This has been another episode of Talk Python To Me.
- 1:01:57Thank you to our sponsors.
- 1:01:59Be sure to check out what they're offering.
- 1:02:00It really helps support the show.
- 1:02:02Take some stress out of your life.
- 1:02:05Get notified immediately about errors and performance issues in your web or mobile applications with
- 1:02:10Sentry.
- 1:02:10Just visit talkpython.fm/sentry and get started for free.
- 1:02:16And be sure to use the promo code talkpython, all one word.
- 1:02:19Want to level up your Python?
- 1:02:21We have one of the largest catalogs of Python video courses over at Talk Python.
- 1:02:25Our content ranges from true beginners to deeply advanced topics like memory and async.
- 1:02:30And best of all, there's not a subscription in sight.
- 1:02:33Check it out for yourself at training.talkpython.fm.
- 1:02:36Be sure to subscribe to the show, open your favorite podcast app, and search for Python.
- 1:02:41We should be right at the top.
- 1:02:42You can also find the iTunes feed at /itunes, the Google Play feed at /play,
- 1:02:47and the direct RSS feed at /rss on talkpython.fm.
- 1:02:51We're live streaming most of our recordings these days.
- 1:02:54If you want to be part of the show and have your comments featured on the air,
- 1:02:58be sure to subscribe to our YouTube channel at talkpython.fm/youtube.
- 1:03:02This is your host, Michael Kennedy.
- 1:03:04Thanks so much for listening.
- 1:03:06I really appreciate it.
- 1:03:07Now get out there and write some Python code.
- 1:03:09Bye.
- 1:03:09Bye.
- 1:03:10Bye.
- 1:03:11Bye.
- 1:03:12Bye.
- 1:03:13Bye.
- 1:03:14Bye.
- 1:03:15Bye.
- 1:03:16Bye.
- 1:03:17Bye.
- 1:03:18Bye.
- 1:03:19Bye.
- 1:03:20Bye.
- 1:03:21Bye.
- 1:03:22Bye.
- 1:03:23Bye.
- 1:03:24Bye.
- 1:03:25Bye.
- 1:03:26you
- 1:03:27Thank you.
- 1:03:29Thank you.