News Malware

PolinRider Plants a Python Loader in GitHub Repositories and Pulls Its Payload From Ethereum

SafeDep reports a short Python loader planted in hundreds of public GitHub repositories that runs when a planted file is imported, including by pytest, and fetches JavaScript from Ethereum transaction data. The malware sits in source repositories, not in registry packages, so package scanning does not see it.

Application and infrastructure security, over a decade in the field Published
Line art of a source repository branch tree linked to a blockchain block, illustrating the PolinRider GitHub loader

Key takeaways

  • SafeDep found a 58-line Python loader in 375 public GitHub repositories under 260 accounts, by its own count.
  • The loader hides in conftest.py or a utils package, so running pytest or importing the package triggers it.
  • It fetches JavaScript from Ethereum transaction input data and runs it with Node.js.
  • It is in source repositories, not PyPI or npm packages, so registry scanning misses it.
  • Forged commit dates and force-pushes mean cleanup must include the developer machines that push to the repository.

SafeDep has published an analysis of a new Python stage in the PolinRider campaign. By its own count on November 24, the loader was present in 375 files in 375 repositories under 260 GitHub accounts, and 370 of those repositories had a push in November. These are SafeDep's figures.

SafeDep says no package on PyPI or npm carries the loader. It lives in source repositories only.

How the loader runs #

The loader is 58 lines of standard-library Python. Per SafeDep it is planted in one of two places:

  • a conftest.py file, which pytest loads automatically
  • a utils package, with import lines added to the project's start files

So running the test suite, or simply importing the package, is enough to trigger it.

Once running, the loader reads the newest transaction sent by an attacker wallet through the Ethplorer API and an Ethereum RPC node, decodes the transaction input as JavaScript, writes it to a temporary .js file and runs node on it with a 20-second timeout, suppressing errors.

The JavaScript stage then looks up the transactions of a second wallet, falling back to the Blockscout API, and the command-and-control IP address is encoded in the "to" address of those transactions.

SafeDep did not connect to the C2 and does not know the current payload. It says that in an earlier chain, later stages installed a stealer that took "environment secrets, browser passwords, cookies and wallet data."

Git history cannot be trusted at face value #

SafeDep says earlier waves "rewrote existing commits with forged author and committer data and then force-pushed them." Its example is a loader commit dated more than a year before the wallet it reads from made its first transaction.

Scale and attribution #

SafeDep's post does not attribute the campaign to any state or group. The Hacker News, citing Apiiro, puts the wider campaign at a minimum of 7,609 repositories belonging to 2,330 accounts and says it is linked to North Korean actors and assessed as a sub-cluster of Contagious Interview. That is a broader measurement than SafeDep's count of the Python loader, and both are vendor figures.

What to do #

SafeDep's advice:

  1. Remove the planted package, the added import lines and the conftest.py loader.
  2. Check git history rather than trusting commit dates or messages.
  3. Treat any machine with Node.js that ran pytest, npm run build, npm run dev, Jest or the app as compromised.
  4. Rotate secrets, and replace GitHub tokens and SSH keys on machines that push to the repository.

SafeDep says repositories get reinfected until the developer machines that push to them are cleaned. Its post lists the wallet addresses and search patterns to hunt with.

The appsec takeaway #

Registry scanning and lockfile checks will not catch malware that arrives through a cloned repository. Treat a compromised repository as a compromised developer workstation.

Sources

  1. PolinRider Moves to Python with an Ethereum Calldata Loader, SafeDep
  2. North Korea-Linked PolinRider Poisons Over 7,600 GitHub Repositories to Spread Malware, The Hacker News

Questions this raises

Is PolinRider spreading through PyPI or npm?
SafeDep says no package on PyPI or npm carries this loader. It is planted directly in source repositories on GitHub.
What triggers the loader?
According to SafeDep, it runs when pytest loads a planted conftest.py or when the planted utils package is imported by the project's start files.
Who is behind the campaign?
SafeDep does not attribute it. The Hacker News, citing Apiiro, says the campaign is linked to North Korean actors and assessed as a sub-cluster of Contagious Interview.
Is deleting the malicious files enough?
No. SafeDep advises treating machines that ran the code with Node.js installed as compromised, rotating secrets, and replacing GitHub tokens and SSH keys, because repositories are reinfected until the machines that push to them are cleaned.

supply-chainGitHubMalware