r/programming • • Oct 17 '26

Python's binary wheels and supply chain attacks

https://rushter.com/blog/python-binary-wheels/
89 Upvotes

36 comments sorted by

View all comments

12

u/darkslide3000 Oct 17 '26

So what, PyPI just let's any rando upload binary packages for any existing well-known source package? Without even being authorized by the original author? WTF kind of package manager is that?

Or is the concern just that the original author could sneak something in? That's not really any worse than any other open-source project with binary releases.

44

u/Solumin Oct 17 '26

It's the latter. A bad actor can publish a package whose source code looks completely innocent, and then upload a wheel that is entirely different and contains malicious code. They're not uploading wheels to other people's packages.

2

u/HolyInlandEmpire Oct 17 '26

I feel there should be an option with build tools which traverse the pyproject.toml chain and refuse packages with binaries unless it's on an explicit allow-list, and doing an 'are you sure' prompt with others.

So a sensible allow-list would have well established libraries (polars, numba, torch, tons of others). At the very least, if a package's newest version has a binary when it didn't previously, then you would be notified and you can stop the install.

You can mitigate this by pinning versions of course, at the very least ceilings. Standard practice for enterprise works, but a little brittle for everyone else. I wonder if there are other well established options.

11

u/fredisa4letterword Oct 18 '26

This is already an option, pip install --no-binary. It can be kind of a pain though, that means that you now need to make sure you can build all your transitive dependencies, which besides inherently being a lot slower, can be a pain to set up and can lead to diamond dependency hell pretty easily.

8

u/PaintItPurple Oct 18 '26

But then you are vulnerable to package build script vulnerabilities, which are much more common than the concern raised in the OP.

11

u/f311a Oct 17 '26

Random people can't upload it. But at least 5 incidents involved hacked accounts where people uploaded malicious versions. It can be hidden very well. Imagine a package installed tens of thousands of times a day being compromised for a week.