r/Python • • 15d ago

News microsoft agent-framework on PyPI was compromised twice in 33 minutes last night

1.26.1 and 1.26.2 both ship a credential stealer. It runs from a .pth file, so it executes at interpreter startup. Nothing has to import the package, a pip install in CI is enough. 1.26.1 got pulled, then 1.26.2 went up 33 minutes later with the same payload under different file names. Last clean release is 1.26.0.
complete details- https://safedep.io/blog/microsoft-agent-framework-pypi-compromise

464 Upvotes

57 comments sorted by

View all comments

Show parent comment

25

u/Smallpaul 15d ago

So walk me through how it works. I have a script on my computer that runs any time of the day or night whether I’m at the computer or not and it calls some server like a translation service or an LLM. How does it use my account without a secret?

6

u/flooberoo 15d ago

I think the request was to stop using api keys, not secrets in general. E.g. put a private key in a secure element and sign requests with it. The key can't be stolen. In CI your requests can be signed by the runner, not your code, so you don't need to care about keys at all there.

4

u/Smallpaul 15d ago

Why not put an API key in a secure element and sign requests with it? How is the “private key” more intrinsically secure?

2

u/flooberoo 15d ago edited 15d ago

Because an API key is not used for signing. That's not what is usually understood by API key.

Edit:

Both "API" and "key" are very generic terms, but nowadays, unless otherwise specified, at least I would interpret "API key" as a Bearer token, not a signing key.

2

u/Smallpaul 15d ago

Okay this took me down a rabbit hole with AI.

It seems like what people are gesturing at but nobody is saying explicitly is that API keys should be replaced by something like RFC 7523: JSON Web Token (JWT) Profile for OAuth 2.0 Client Authentication and Authorization Grants.

As opposed to just “Oauth”, which more often simply uses bearer keys like any other API key API. You need Oauth plus a lot more.

1

u/kyngston 15d ago

you could google oauth…

you login once to get an access token and refresh token

access token is good for 1 hour, refresh token good for 90 day

script uses access token to log in

if the access token is expired, it uses the refresh token to refresh both tokens

stolen access token expires in one hour, as opposed to an api token which lasts forever

0

u/Smallpaul 14d ago

Who is the “you” in the case I described? I described a system that runs 24/7 without me around. So a hacker steals the access token and refresh token using a supply chain attack.

If I can run MY system 24/7 from those two tokens then why can’t they run THEIR system 24/7 from the same tokens?

0

u/kyngston 14d ago edited 14d ago

you as in smallpaul. if you did google it, you would learn about refresh token replay detection

look at you downvoting someone explaining something you know nothing about…

1

u/Smallpaul 14d ago

You are quite an unpleasant person aren’t you.

How can you guarantee who will use the token first and who will be considered the replayer?

1

u/kyngston 14d ago

again if you googled, you would learn that both get revoked.

1

u/Smallpaul 14d ago

So you are saying that my service stops working and that’s a good thing from your point of view?

1

u/kyngston 14d ago

yes that a good thing if your refresh token is stolen. if your refresh token is stolen often, you’ve got much bigger problems than having to log in again…

1

u/Smallpaul 14d ago

My service serving hundreds of thousands of people is down. That’s a bad thing.

Are you aware of what API tokens are used for? It’s not unusual that core application functions depend on services associated with tokens.

1

u/kyngston 14d ago

hundreds of thousands of people use your app and you think a stolen api token is better than a stolen access token?

make that make sense

→ More replies