Request for Comment: PyPI Supply Chain Attacks #9252
Replies: 4 comments 3 replies
-
If I understand correctly, the attacker had access to the repo and replaced an URL dependency in a The first question that comes to my mind: The attacker could have changed arbitrary code instead of the URL dependency. Is it worth to implement a mitigation for exactly this attack while being vulnerable to each other change the attacker could have made with their gained access?
It's quite uncommon to use URL dependencies in a library package. As far as I know, common dependencies just use name/version dependencies and changing a name/version dependency to an URL dependency will be more obvious so an attacker might add (obfuscated) malicious code directly instead of changing a dependency.
Poetry does not configure trusted domains. If a dependency requires an URL dependency it will just be resolved during locking. If you already have an existing lock file with the old correct URL dependency you are safe when installing from it because the URL (and the hash) is locked. I suppose it would be possible to add the option to configure trusted domains but I'm not sure if it's worth the effort considering that the attacker had the privileges to do arbitrary changes (not just changing dependencies). |
Beta Was this translation helpful? Give feedback.
-
Thank you for taking a look!
Yes, this is correct. I expected Microsoft to release some comment about how this could have happened but I have not seen anything. From the article: """ Checkmarx only states that the account was "likely" hijacked through stolen cookies but then goes on to treat it as fact. I know next-to-nothing about web security - my approach has always been to use the latest techniques that the math/security people tell me to, probably implemented in libraries - and my brief research suggests that there are many ways to mitigate this kind of session hijacking. I suspect that GitHub's account security is good 💸. So I will tell readers the standard: don't reuse passwords, use 2FA, etc...
This is the advantage that I felt Poetry (or pyproject.toml) has. Assuming that the dependency URL would be resolved by PyPI or some other package repository, then a change from JP |
Beta Was this translation helpful? Give feedback.
-
Does Poetry support configuration of trusted hosts in the pip.conf of the venv? |
Beta Was this translation helpful? Give feedback.
-
It seems like Poetry does support some constraints on the sources of packages. Can you comment on using explicit package sources or package source constraint to require that packages are from PyPI (or other explicit sources)? Is it not capable to pass the requirement to upstream dependencies? |
Beta Was this translation helpful? Give feedback.
-
Hello Poetry Team,
I am working on a series of articles about deploying Python applications with a focus on security. Of course, dependencies and build are managed by Poetry ❤️. This week, as I was working on the security threat modeling for the 2nd article, about deploying to PyPI, news of a very successful supply chain attack was published.
I will be referring to this article throughout, worth the read if you haven't seen it yet: https://checkmarx.com/blog/over-170k-users-affected-by-attack-using-fake-python-infrastructure/
The crux of the supply chain injection was in a
requirements.txt
(remember those? 😢): changing a domain frompythonhosted.org
topypihosted.org
was sufficient to deliver the poisonedcolorama
to 170,000 users. Imagine if a common dependency, rather than a niche dependency like top-gg's python-sdk, was attacked similarly.It got me to thinking, does use of Poetry mitigate some of these risks?
Specifically
In your answer, please specify if I can quote you in the article, and if so, what your role in the Poetry organization is and how you would like to be credited.
@abn Tagging because you kindly helped me here.
Best regards,
JP Hutchins
Beta Was this translation helpful? Give feedback.
All reactions