r/Python • u/enterthearena44 • 14d ago
Discussion Microsoft's PyPI package got compromised without a GitHub code change. How is this even possible?
I was reading about yesterday's Microsoft Agent Framework security incident, and something caught my attention.
Apparently, attackers published two malicious versions (1.26.1 and 1.26.2) of Microsoft's official Python package on PyPI. These versions could steal cloud credentials just by starting Python.
Both versions were removed quickly.
What surprised me was that the malicious code wasn't even checked into Microsoft's GitHub repository.
From what I understand:
- Developers write code in GitHub.
- CI/CD builds it into a Python wheel (.whl).
- The wheel gets published to PyPI.
- When we run "pip install", we download that package.
But apparently, someone with the right publishing credentials can upload a malicious wheel directly, without going through the original GitHub repository.
That raises some interesting questions:
- How does PyPI verify that a package actually came from the legitimate source code and CI/CD pipeline?
- Why isn't a verified GitHub commit or build provenance mandatory for publishing updates to established packages?
- If publishing credentials are compromised, what prevents attackers from distributing malicious versions under trusted package names?
- Would mandatory attestations, release signing, or an approval process have prevented this?
- What protections should developers realistically use beyond simply trusting "pip install"?
I'm still learning about software supply-chain security, so I'd love to hear how experienced Python developers and security engineers think this should work.
View all comments
Show parent comment
6
u/OkCardiologist8006 13d ago
for this incident yeah, it was new version numbers, so an exact version pin in a lockfile is what actually protected people.
hash pinning isn't useless against a stolen token though. pypi won't let you reuse a filename, but it does let you add new files to an existing release, so an attacker could upload an extra wheel with a more specific platform tag under an old version and pip might prefer it. `--require-hashes` (or a uv/poetry lockfile, which records hashes) catches that.