Live data from Hacker News

PyPI: Python packets steal AWS keys from users

blog.sonatype.com

1–10 of 104 posts

Re: PyPI: Python packets steal AWS keys from users

#3
Glad they were able to automatically detect/catch this. There seems to be so much bloat when dependencies get pulled in.

Wonder if something like pledge and unveil around library code could be helpful; perhaps library code needs to be separated out into a separate process that would not have reason to access AWS keys.

Also, looking at the screenshot, could a simple programming searching for URLs in the library code help in this case?

Looks like they removed the modules, so one can't examine them any more.

Re: PyPI: Python packets steal AWS keys from users

#5

Glad they were able to automatically detect/catch this. There seems to be so much bloat when dependencies get pulled in. Wonder if something like pledge and unveil around library code could be helpful; perhaps library code needs to be separated out into a separate process that would not have reason to access AWS keys. Also, looking at the screenshot, could a simple programming searching for URLs in the library code h…

Yeah, I'd love to have a decorator at the top of a file - @env to provide access to env variables or @secrets for some kind of secrets access, nothing else gets this.

Python is tough though, a very dynamic language so probably kind of hard to lock it down.

Re: PyPI: Python packets steal AWS keys from users

#6
post #4

I believe this is something that automated code parsing (a la Github Copilot) could really shine. Those tools are able to explain what a block of code does, so it should be possible to catch many types of malware hidden in source code.

If a human can't figure it out than an AI trained on human behavior (or more specifically, trained on comments left next to code) can't figure it out either. It's not like malware authors annotate their code with nice "here's where I exfiltrate all the user's secret data" comments.

Re: PyPI: Python packets steal AWS keys from users

#7
I wonder if the target of loglib-modules and hkg-sol-utils is a specific company running its own internal PyPi server, or something like a scientific collaboration (which can be thousands of people and billions of dollars, especially in the drugs discovery domain).

PIP is designed to treat all indexes as mirrors, rather than to specify the source of a package: So a higher package version of an internal package name would be chosen whether it is on public or private PyPi. Equally a certain percentage of the time it would choose public over private with the same package version.

Re: PyPI: Python packets steal AWS keys from users

#8
post #4

I believe this is something that automated code parsing (a la Github Copilot) could really shine. Those tools are able to explain what a block of code does, so it should be possible to catch many types of malware hidden in source code.

This is the kind of stuff that antiviruses did for ages, from signature, code simulation to heuristics.

They have a lot of expertise in this, it feels like they could branch out in finding malware in source code, instead of in binaries.

Re: PyPI: Python packets steal AWS keys from users

#9
I've been building tooling to mitigate supply chain attacks like these. Packj [1] analyzes Python/NPM packages for risky code and attributes such as Network/File permissions, expired email domains, etc. Auditing hundreds of direct/transitive dependencies manually is impractical, but Packj can quickly point out access to sensitive files (e.g., SSH keys), spawning shell, data exfiltration, etc. We found a bunch of malicious packages on PyPI using the tool, which have now been taken down; a few are listed here https://packj.dev/malware

1. https://github.com/ossillate-inc/packj

Re: PyPI: Python packets steal AWS keys from users

#10
post #4

I believe this is something that automated code parsing (a la Github Copilot) could really shine. Those tools are able to explain what a block of code does, so it should be possible to catch many types of malware hidden in source code.

If a human can't figure it out than an AI trained on human behavior (or more specifically, trained on comments left next to code) can't figure it out either. It's not like malware authors annotate their code with nice "here's where I exfiltrate all the user's secret data" comments.

That's not going to stop people from trying though. If people keep abusing the package managers like this, then publishing open source code is at risk of ending up like distributing binaries on Windows, where you need to fight dozens of virus scanners arbitrarily blocking your code for no apparent reason. Imagine opening a tab in VSCode only to see a popup warning saying it might be harmful, even though you just wrote it yourself.
Post reply on HN