The Python Package Index (PyPI) has announced that it will require all accounts that maintain a project to have two-factor authentication (2FA) enabled by the end of 2023.
The official software repository for Python, PyPI has become the target of numerous supply chain attacks over the past years, in some of which threat actors compromised maintainer accounts to inject malicious code into projects.
By enforcing 2FA for project maintainers, PyPI wants to prevent account takeover attacks, thus reassuring the community that only people associated with a project can upload, modify, or delete code.
“Between now and the end of the year, PyPI will begin gating access to certain site functionality based on 2FA usage. In addition, we may begin selecting certain users or projects for early enforcement,” PyPI administrator and maintainer Donald Stufft says.
PyPI project maintainers can use either a security device or an authenticator application for the second authentication step, and can also switch to using trusted publishing (relies on the OpenID Connect (OIDC) standard for token exchange) or API tokens when uploading to PyPI.
By requiring 2FA to be enabled for all maintainer accounts, including organization accounts, PyPI wants to make sure that all projects on the repository are better protected.
“[It] only takes one compromised project in someone’s dependency set to compromise their computer. […] Once compromised, an attacker can extend that attack to attack other systems, including other projects on PyPI that the now compromised person maintains,” Stufft notes.
In addition to enforcing 2FA, PyPI is working on reducing the amount of IP address data it stores, by evaluating where that type of data is needed on the site and removing its collection where it is not.
Thus, while IP addresses are still used for rate limiting and fallbacks, they are no longer stored in Journal entries, which are accessible to admins only. IP data is still needed to prevent abuse, but the repository is searching for alternative approaches that could also help increase user security.
Following a recent audit, PyPI discovered that the use of PGP signatures when uploading packages to the repository is no longer defensible, given low usage and other issues, and has decided to remove PGP. While existing signatures will continue to work, no new ones will be made available and any newly uploaded PGP signatures will be ignored.