Cryptominers Slither into Python Projects in Supply-Chain Campaign

  • Tara
  • published date: 2021-06-22 15:27:00 UTC

These code bombs lurk in the PyPI package repository, waiting to be inadvertently baked into software developers’ applications.

<div class="c-article__content js-reading-content"> <p>A group of cryptominers was found to have infiltrated the Python Package Index (PyPI), which is a repository of software code created in the Python programming language.</p> <p>Similar to other repositories like GitHub, npm and RubyGems, PyPI is part of the software supply chain. It offers a place where coders can upload software packages for use by developers in building various applications, services and other projects. Unfortunately, a single malicious package can be baked into multiple different projects – infecting them with cryptominers, info-stealers and more, and making remediation a complex process.</p> <p>Researchers at Sonatype found six different malicious packages hiding in PyPI, which have a collective 5,000 downloads, all uploaded by a user with the handle “nedog123,” according to a <a href="" target="_blank" rel="noopener">Tuesday blog post</a>.</p> <p><a href=""><img loading="lazy" class="aligncenter wp-image-141989 size-full" src="" alt="" width="700" height="50"></a></p> <p>These consist of a main package called “maratlib,” along with five others that use maratlib as a component: maratlib1; matplatlib-plus; mllearnlib; mplatlib and learninglib.</p> <p>“Also, some of these packages are typosquats, or programs that are expected to be grabbed by people accidentally typing in the wrong name,” wrote Sontaype researcher Ax Sharma in the posting. “For example, the counterfeit mplatlib and matplatlib-plus are named after the legitimate Python plotting software [called] matplotlib.”</p> <h2><strong>The maratlib Malicious Python Package</strong></h2> <p>In all of the packages, the malicious code is contained in a build script that runs during a package’s installation, dubbed “” This file downloads and runs a Bash script from GitHub.</p> <p>The Bash scripts run cryptominers on compromised machines, including one dubbed “<a href="" target="_blank" rel="noopener">Ubqminer,</a>” and the open-source cryptomining program <a href="" target="_blank" rel="noopener">known as T-Rex</a>. The former mines for UBIQ coins, while the latter uses NVIDIA GPU processors to mine for Ethereum.</p> <p>“Once again, this particular discovery is a further indication that developers are the new target for adversaries over the software they write,” Sharma said. “These PyPI packages have been lurking on the repository for months, targeting developer systems with the goal of turning them into cryptominers.”</p> <p>Sonatype said that it notified PyPI of the packages, which, according to a site search by Threatpost, appear to have been taken down. It’s unclear how many active projects contain the malicious code, however, so the threat persists.</p> <p>“This is a systemic threat, and it needs to be actively addressed on several layers, both by the maintainers of software repositories and by the developers,” explained Ilya Khivrich, chief scientist with Vdoo, via email. “On the developers’ side, preventive measures such as verification of library signatures and employing automated tools to scan for hints of suspicious code included in the project should be included in the CI/CD pipeline.”</p> <p>The threat actor could crop up again using aliases, of course. In examining the URLs serving the scripts, Sharma kept receiving 404 (not found) errors, but eventually discovered an updated alias for the original “nedog123” user: “maratoff.”</p> <p>“The commit IDs associated with update/deletion of these scripts found on GitHub mirrors that mentioned alias nedog123, matched the commits in maratoff’s repository,” he explained. “Also, the newer maratoff repo contains files referencing the deleted nedog123 alias.”</p> <h2><strong>Developers: The New Supply-Chain Target for Malware </strong></h2> <p>As Sharma pointed out, this latest discovery is part of a growing trend of malware infesting software repositories as part of next-gen supply-chain attacks, including recent copycat packages targeting well-known tech companies.</p> <p>In the latter case, malicious packages targeting internal applications for Amazon, Lyft, Slack and Zillow (among others) <a href="" target="_blank" rel="noopener">were found in March</a>, lurking inside the npm public code repository. All of them exfiltrated sensitive information.</p> <p>The packages weaponized an earlier proof-of-concept (PoC) <a href="" target="_blank" rel="noopener">code dependency-confusion exploit</a> devised by security researcher Alex Birsan to inject rogue code into developer projects.</p> <p>Also in March, the PHP project found that attackers <a href="" target="_blank" rel="noopener">were able to gain access</a> to its main Git server, uploading two malicious commits, including a backdoor. Fortunately, they were discovered before they went into production.</p> <p>In January, three malicious software packages <a href="" target="_blank" rel="noopener">were published to npm</a>, a code repository for JavaScript developers, which had the ability to steal tokens and other information from Discord users.</p> <p>Also recently, RubyGems, an open-source package repository and manager for the Ruby web programming language, took <a href="" target="_blank" rel="noopener">two of its software packages offline</a> after they were found to be laced with Bitcoin-stealing malware.</p> <p>“The complexity of modern software development processes and their reliance on large community-maintained codebases introduces a risk for developers to inadvertently include malicious code into the project,” said Vdoo’s Khivrich. “The implications can be severe — in many cases it will be a complete takeover of the developed program or device by an attacker.”</p> <p><strong>Join Threatpost for “</strong><a href=";utm_medium=ART&amp;utm_campaign=June_PaloAltoNetworks_Webinar" target="_blank" rel="noopener"><strong>Tips and Tactics for Better Threat Hunting</strong></a><strong>” — a LIVE event on </strong><a href=";utm_medium=ART&amp;utm_campaign=June_PaloAltoNetworks_Webinar" target="_blank" rel="noopener"><strong>Wed., June 30 at 2:00 PM ET</strong></a><strong> in partnership with Palo Alto Networks. Learn from Palo Alto’s Unit 42 experts the best way to hunt down threats and how to use automation to help. </strong><a href=";utm_medium=ART&amp;utm_campaign=June_PaloAltoNetworks_Webinar" target="_blank" rel="noopener"><strong>Register HERE</strong></a><strong> for free!</strong></p> <footer class="c-article__footer"> <div class="c-article__footer__container"> <div class="c-article__footer__col"> <a href="#discussion" class="c-button c-button--secondary">Write a comment</a> </div> <div class="c-article__footer__col"> <div class="c-article__sharing"> <p><strong>Share this article:</strong></p> <nav class="c-nav-sharing"> <div class="social-likes social-likes_notext" data-title="Cryptominers Slither into Python Projects in Supply-Chain Campaign" data-url="" data-counters="no" data-zeroes="yes"><div class="facebook" title="Share via Facebook"></div> <div class="twitter" title="Share via Twitter"></div><div class="linkedin" title="Share via LinkedIn"></div> <div class="reddit" title="Share via Reddit"></div> <div class="flipboard" title="Share via Flipboard"></div> </div> </nav> </div> </div> </div> <div class="c-article__footer__container"> <div class="c-article__footer__col"></div> <div class="c-article__footer__col"> <ul class="c-list-categories"> <li><a class="c-label c-label--secondary-transparent" href="">Cloud Security</a></li> <li><a class="c-label c-label--secondary-transparent" href="">Malware</a></li> <li><a class="c-label c-label--secondary-transparent" href="">Vulnerabilities</a></li> </ul> </div> </div> </footer> </div>