Hiding in Plain Sight: How a Blatant Cryptominer Survived 3 Years on PyPI
By Paul McCarty
The Uncomfortable Truth
For approximately three years, a package called tensorflow-opt sat on the Python Package Index (PyPI), quietly mining cryptocurrency on victims' machines.

When we analyzed this malware, we expected to find sophisticated obfuscation, clever evasion techniques, or at least some attempt to hide its true nature.
We found none of that.
Instead, what we discovered raises a more troubling question: How did such an obviously malicious package survive on PyPI for three years and across at least 26 versions?

A Malware Sample That Wasn't Even Trying
Let's be clear about what tensorflow-opt was doing. This wasn't a sophisticated supply chain attack with multi-stage payloads and advanced evasion. The entire malicious codebase in optimize.py was 9 lines of Python:
That's it. Nine lines that:
subprocess.Popen and shell=TrueThere's no obfuscation. No dynamic imports. No base64 encoding. No encrypted payloads. The function is literally called start() and it copies files from a /bin/ directory and executes a .bat file.
The batch file itself? Equally blatant:
It's setting GPU environment variables to maximize mining performance and then executing a binary called tensor_core.exe with hardcoded mining pool credentials. The attacker's wallet address is right there in plaintext. The mining pool domain is visible. The executable has GPU optimization flags.
This malware was hiding in plain sight because it wasn't hiding at all.
The Package Structure Red Flags
Beyond the obvious malicious code, the package structure itself was suspicious:
Let's count the red flags:
tensor_core.exe - clearly trying to mimic legitimate TensorFlow componentsAny automated scanning system looking for:
...would have immediately flagged this package.
Who is the threat actor?
A PyPI user named kwanazizmahood published this package way back in August of 2022:

This user only ever published the one package, and while PyPI has removed the package, they haven’t removed the user, which we find strange.
The Three-Year Question
Here's what makes this case study significant: tensorflow-opt existed across 26 versions for approximately three years.

That's three years of:
The package was even actively maintained across multiple versions, suggesting the attacker felt comfortable enough to continue updating it without fear of detection or removal.
What This Reveals About the PyPI Ecosystem
The tensorflow-opt case isn't interesting because the malware was sophisticated. It's interesting because the malware was trivial and it still succeeded.
Detection Gap #1: No Meaningful Binary Analysis
PyPI allows package maintainers to upload arbitrary binaries. While there are legitimate uses for this (C extensions, platform-specific optimizations), there's apparently no systematic analysis of what these binaries do.
An 8.27 MB executable named tensor_core.exe that:
ethash.unmineable.com...should have been trivially detectable with even basic static analysis.
Virustotal knew that this was a cryptominer for years!

Detection Gap #2: No Code Behavior Analysis
The optimize.py file exhibits clear malicious patterns:
shell=True (command injection vector)These are textbook malicious behaviors. Tools like Bandit, semgrep, or even simple pattern matching could detect these issues. Yet the package sat on PyPI for years.
Detection Gap #3: No Network Behavior Monitoring
The batch file connects to a known cryptocurrency mining pool. The wallet address is hardcoded. The worker name identifies the campaign ("tf_opt").
Any post-installation behavioral analysis - even just monitoring network connections during test installations - would have caught this immediately. But there's no evidence such monitoring exists at scale on PyPI.
Detection Gap #4: No Naming Similarity Protection
tensorflow-opt is an obvious typosquat/brandjacking attempt targeting tensorflow, one of the most popular machine learning frameworks in existence. While PyPI has begun implementing some name similarity checks, this package predated those protections and exploited the naming trust users have in the TensorFlow ecosystem.
The Broader Implication: How Many More Are Out There?
This is the critical question. If a package this blatantly malicious can survive for three years across multiple versions, how many others are currently on PyPI right now?
Consider:
The tensorflow-opt case suggests we're only seeing the tip of the iceberg - the packages that are so obvious that they eventually get reported by vigilant users, not caught by systematic defenses.
The Ecosystem Challenge
PyPI faces a genuine challenge:
But the tensorflow-opt case shows that even basic, low-cost security measures would catch the most blatant attacks:
The Technical Reality of Modern Malware
Here's what makes the tensorflow-opt case particularly concerning: the attacker didn't need to be sophisticated.
Modern package repository malware doesn't require:
An attacker can:
The barrier to entry is frighteningly low, and the detection rate is apparently even lower.
Cryptocurrency Mining: Not dumb if it works?
Cryptomining malware has several advantages for attackers:
For the tensorflow-opt attacker:
TRX:TD5TrHLdGyhz85aK9yjQKEKv3sFt5JsRuz.tf_opttf_optethash.unmineable.com:3333Every developer who installed this package and had a GPU became an unwitting cryptocurrency miner, with all profits going directly to the attacker's TRON wallet.
The worker name "tf_opt" allowed the attacker to track exactly how much revenue this specific campaign generated. Based on the three-year timeline and multiple package versions, this was clearly profitable enough to maintain.
What Developers Can Do Right Now
While we wait for ecosystem-level improvements, developers need to protect themselves:
1. Audit Your Dependencies
Run regular security audits:
# Check for known vulnerabilities pip-audit # Static analysis of installed packages safety check # List all installed packages and review them pip list
2. Use Safety Firewall
Traditional vulnerability scanning happens too late - after potentially malicious code is already in your system. Which means that ASPM and EDR solutions don't protect you from this type of threat.
But all is not lost, as the Safety Firewall protects developers and CI pipelines proactively. Every package installation request is analyzed before reaching public repositories. Malicious, vulnerable, and policy-violating packages are automatically blocked before they can enter your systems, preventing rather than just detecting threats.
You can sign up for a free Safety account and try the Safety Firewall HERE.
Feel free to reach out to me with any questions!
Conclusion: The Malware We Can't Afford to Miss
tensorflow-opt wasn't a sophisticated attack. It was nine lines of Python, an executable, and a batch file. No encryption, no obfuscation, no advanced techniques.
And it worked for three years, and was downloaded hundreds or thousands of times.
This case study isn't about appreciating clever malware engineering. It's about recognizing a fundamental truth: if this malware can survive on PyPI for three years, the problem isn't just one bad package - it's a systemic detection and response gap.
Somewhere on PyPI right now, there are packages with:
And if we can't even catch the obvious ones, what hope do we have of catching those?
The tensorflow-opt campaign succeeded not because the attacker was particularly skilled, but because the defenses were particularly absent. Until that changes - until basic security scanning, behavioral analysis, and community reporting become standard infrastructure for package repositories - we can expect many more campaigns just like this one.
The malware hiding in plain sight is bad enough. But the real threat is the malware we're not seeing at all.
Indicators of Compromise
If you've ever installed tensorflow-opt, check for:
Package names:
Files:
Network connections:
Wallet address:
Processes:
Environmental indicators:
About This Analysis: This research was conducted on archived malware samples for educational and defensive security purposes. The tensorflow-opt package has been removed from PyPI. All IOCs are provided to enable detection and blocking.
How can Safety help protect you from these attacks?
Traditional vulnerability scanning happens too late - after potentially malicious code is already in your system. Which means that ASPM and EDR solutions don't protect you from this type of threat.
But all is not lost, as the Safety Firewall protects develoeprs and CI pipelines proactively. Every package installation request is analyzed before reaching public repositories. Malicious, vulnerable, and policy-violating packages are automatically blocked before they can enter your systems, preventing rather than just detecting threats.
You can sign up for a free Safety account and try the Safety Firewall HERE.
Feel free to reach out to me with any questions!