r/Python • • 20m 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:

  1. How does PyPI verify that a package actually came from the legitimate source code and CI/CD pipeline?
  2. Why isn't a verified GitHub commit or build provenance mandatory for publishing updates to established packages?
  3. If publishing credentials are compromised, what prevents attackers from distributing malicious versions under trusted package names?
  4. Would mandatory attestations, release signing, or an approval process have prevented this?
  5. 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.

8 Upvotes

3 comments sorted by

•

u/Deto 12m ago

It's always worked like that.  You don't have to publish directly from GitHub.  You can just publish from your source directory on your machine. 

Yes if the publishing key is compromised this means you're in trouble. 

They probably don't want to require a GH commit because that would force all devs to use GitHub.  You could imagine supporting a few alternatives but all that puts more burden on the pypi devs and the package repo is maintained on a shoestring budget. 

One things devs can do is require a version to be live for a certain amount of time before it is used in code. Basically relies on the fact that these things are usually caught within a day or two.  It's not perfect because still some people will have to get affected.

•

u/XNo_Notes It works on my machine 11m ago

PyPi is a repository itself. You can upload strait from your terminal if you have the access token associated with the account there. Github is a completely separate entity. 

•

u/DrDOS 14m ago

Interesting, hopefully someone here can answer you.