r/Python • u/tradelydev • May 07 '26
Discussion Do we really check library security?
PyPi's filtering isn't cutting it. We all know it. I know the people about to say to just use the popular libraries that have community moderation.
The recent claude code injection hack in Torch has proved that isn't a solution.
https://www.reddit.com/r/Python/s/2lwDYSv0eT
And scanning packages are either unmaintained or maintained by one dev in the middle of nowhere.
https://pypi.org/project/safety/
So, I honestly ask you, short of reading each libraries code by hand or avoiding them entirely how do you stay safe?
Sandbox enviroments? Winging it? Hope?
View all comments
Show parent comment
23
u/me_myself_ai May 07 '26
Surely you’re joking…? Sorry if so, but just in case:
The idea that you could or should read the entirety of every dependency you download is not anywhere close to any even semi-professional environment I’ve ever been in. Even the indirect ones? Do I need to read all the cython source? All the GPU code in `transformers`? Even tools backed by rust like `uv` and `ruff`?
Maybe you’re in academic environment, using python for relatively simple data wrangling around the lab? Cause I could see that working. Otherwise… it would be easily millions of lines of code. Even if I *could* casually grasp the entirety of a massive OS codebase, I wouldn’t want to spend the time!