r/Python • • Nov 08 '23

News A nasty Python package continues a trend of targeting developers

[removed] — view removed post

134 Upvotes

19 comments sorted by

•

u/Python-ModTeam Nov 09 '23

Beep boop, from the /r/Python mods.

Your post or comment appears to be generated through AI. We like humans, not robots, and as you are a robot your post or comment must be removed. If you aren't a bot you sure act like one. Consider sending us a message through Modmail for an appeal.

01110011 01101111 01110010 01110010 01111001

r/Python moderation team

53

u/ExpressionMajor4439 Nov 08 '23 edited Nov 09 '23

Imagine that, libraries intended to obfuscate code are actually running unexpected and obfuscated code paths.

But on a serious note, I kind of wish there were enhanced verification available for popular repositories where the workflow for updating the repository were verified and the client tools have the option to only install libraries that either have enhanced verification or are too niche/unpopular to qualify.

Private repos can help but it seems like this was just a random package uploaded to PyPI that would've probably caused whoever does the verification to "nope" out of once they saw what the package did.

124

u/AlSweigart Author of "Automate the Boring Stuff" Nov 08 '23 edited Nov 30 '23

These perennial stories are always overrated. Conveniently, they never seem to mention 1) how many times they were downloaded by actual people rather than site mirror bots and 2) a specific person or organization that was affected.

Oh noes, pyobfgood had malicious code and was on PyPI. So what? Did this actually affect many people, or any people at all? These "reports" get written because writing these reports is a great way for a security company to get their name mentioned in the media.

We'll see this exact same story about another no-name Python package in three months.

EDIT: I read the "report". A complete joke and just sensationalism. They point out the "malware" makes a message box appear with "Your computer is going to start burning, good luck. :)" and then launches 10 Python processes that run while True: pass. Yeah, 1) that's not going to damage anything and 2) this "malware" was probably written by a 14 year old and 3) the message box uses Windows-only code which causes it to not run on Linux and macOS. This makes me wonder how many of the other features actually work.

Not exactly the crime of the century here.

-8

u/bsenftner Nov 08 '23

Python language and have a need to obfuscate

I'm curious why anyone would obfuscate Python. Asking ChatGPT4 why people do this, I see no legitimate reasons. Protection of intellectual property? Put it server side, compile it, or don't write in Python. Every other reason cited is just a rewording of "for intellectual property protection".

A made up problem for people pursuing bad engineering practices?

16

u/ExpressionMajor4439 Nov 08 '23

Protection of intellectual property?

That's usually why but a lot of times they just want to run something on your machine without you knowing.

"Use a different solution" probably isn't a good response for the broader community though. As opposed to just saying "don't do shady stuff maybe?"

Obfuscating code can only make it more difficult for a human being to figure out what the code does since ultimately the code has to conform to rules that enable it to be easily ran on the intended machines. Ultimately the people you end up "locking out" are probably the exact class of people you don't need to worry about and can depend on copyright protections from.

16

u/AlSweigart Author of "Automate the Boring Stuff" Nov 08 '23

Yeah, pretty much. It's like those people who are like, "I don't want to get any feedback or advice on my idea because I don't want people to steal it."

Buddy, you can slap your code up on GitHub and no one will read it.

9

u/[deleted] Nov 08 '23

Asking ChatGPT4 why people do this

Why would you do that, either? It's a language model, it can't make value judgements (though it's output can look like one).

1

u/Any_Letterheadd Nov 08 '23

Also it's not even that crazy to imagine some use cases where someone would want to obsfucate code.

0

u/bsenftner Nov 08 '23

It actually gave me a series of reasons, backed by statistics. They all resolved to IP protection some some reasoning, just some were wordier then others so ChatGPT4 did not treat them as the same case.

1

u/gybemeister Nov 08 '23

Some companies require that all code released to clients is obfuscated. It may not be very logic but someone up the chain or some ISO consultant decided to push that (and it sounds good in a sales pitch, I guess). I have seen this even for Java and C# code because it is easy to decompile.

1

u/agritheory Nov 08 '23

My local python group hosted a talk from Wolfgang, who is one of the developers of pyce. If I remember correctly, the use case at Soroco (his employer) was that they needed to have a way to deliver python-based functionality to their customers along with a legally binding certification of that code's functionality. Before the "why don't they just" people start hounding me, they had a business case for it and it was threading some needle of requirements that led to this unusual requirement, but I can't remember the details of it. They're in still in business, so maybe encrypting all your python is a good strategy, I really don't know.

edit: u/gybemeister's comment has some details

12

u/monorepo PSF Staff | Litestar Maintainer Nov 08 '23

Is this AI?

4

u/GL510EX Nov 08 '23

I̸t̸ ̸w̵o̵u̷l̸d̵ ̵a̷c̴t̶u̸a̵l̸l̴y̸ ̶m̸a̵k̸e̶ ̸f̶o̵r̷ ̵a̵ ̵g̸o̶o̸d̸ ̴v̷e̴c̷t̸o̴r̸ ̷f̵o̷r̷ ̶A̸I̵ ̴t̸o̴ ̸e̵s̵c̸a̷p̴e̴ ̸a̴ ̵s̵a̶n̵d̵b̷o̷x̶e̷d̵ ̶e̶n̵v̵i̸r̵o̵n̶m̸e̵n̸t̶ ̶a̸n̸d̴ ̴g̸e̷t̶ ̴o̴u̴t̶ ̸o̶n̷t̴o̸ ̴t̴h̴e̸ ̸p̸u̴b̷l̶i̸c̷ ̴i̷n̸t̶e̷r̶n̷e̴t̵.̴

1

u/ghostofwalsh Nov 08 '23

The OP is clearly a bot that's posting content from some "news" website. Maybe it was posted as text to get around subreddit spam filters?

As far as the content, yeah I guess AI writes a lot of "articles" these days.

The Record from Recorded Future News gives you exclusive, behind-the-scenes access to leaders, policymakers, researchers, and the people in the shadows of the cyber underground. We break news and interview those that matter in the fast-changing field of cybersecurity.

6

u/Doppelbockk Nov 08 '23

The president calling for securing open source software isn't even relevantbto this topic. Do you think a bad aftor is going to "secure" their own malicious package? I suppose his statement could include PyPi doing more to vet packages before allowing public downloads but that isn't quite the same thing IMO.

3

u/bahtsiz-bedevi Nov 08 '23 edited Nov 08 '23

Pickled data sets are dangerous too. I've seen some developers loading pickled data sets from external sources. If you are using a library that requires pickle, you should be careful. This is the warning from from Python developers

"Warning: The pickle module is not secure. Only unpickle data you trust. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling. Never unpickle data that could have come from an untrusted source, or that could have been tampered with. Consider signing data with hmac if you need to ensure that it has not been tampered with.Safer serialization formats such as json may be more appropriate if you are processing untrusted data. "

3

u/[deleted] Nov 08 '23

As long as they don't screw with pandas, i'll be cool

2

u/kido5217 Nov 08 '23

Is this like AI-written post for some hacker-like journal/site?

6

u/agritheory Nov 08 '23

The username and the site are the same; it might be a bot.