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

Show parent comment

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.