Malicious RubyGems Turn Dev Machines Into Monero Miners Spread via SSH

A supply chain attack uses RubyGems to install Monero miners that spread via SSH, targeting developer machines.

By Central
Over 136 malicious RubyGems packages were published, with tens of thousands of downloads, turning dev machines into covert miners.
Highlights
  • The attack delivered Monero miners that delayed execution by five hours to evade sandbox detection.
  • Malicious gems spread laterally via SSH credentials, creating a worm-like propagation mechanism.
  • Unit 42 identified two clusters with 136 malicious gems, totaling over 14,000 downloads.

A sophisticated supply chain attack has weaponized the RubyGems ecosystem, transforming seemingly benign developer packages into covert Monero miners that can spread laterally through SSH credentials. The campaign, identified by Unit 42 researchers, leverages the trust developers place in public package repositories to install cryptojacking malware that not only siphons computational resources but also establishes a worm-like mechanism to propagate across networks. With over 136 malicious packages published and tens of thousands of downloads, this operation represents a significant escalation in the tactics used by adversaries targeting the software development pipeline.

The Anatomy of a RubyGems Cryptojacking Campaign

The attack unfolded through two distinct but related clusters of malicious gems. The first operation published 113 trojanized packages that collectively received 14,253 downloads. The second group uploaded 23 malicious gems. A related account had uploaded an additional 309 gems, amassing over 139,000 downloads, though Unit 42 found no harmful code in those packages at the time of their analysis. The sheer volume of packages suggests an automated or highly organized effort to flood the registry with seemingly useful libraries.

Developers searching for common utilities — packages built from simple words such as “ultra,” “smart,” “tool,” and “kit” — would encounter these gems during routine dependency searches. This naming strategy is designed to exploit the haste of development workflows, where a developer might grab a package that appears to be a standard utility without scrutinizing its provenance.

How the Malicious Gems Execute Cryptomining Payloads

The first group of gems employed a sophisticated evasion technique. Each package carried the same Monero mining payload, but it was programmed to wait five hours before executing. This delayed activation is a deliberate measure to circumvent automated security sandboxes, which typically monitor software behavior for only a short period after installation. By remaining dormant during that window, the malware avoids detection by static and dynamic analysis tools commonly used in continuous integration pipelines.

Once the timer elapsed, the payload performed a series of environment checks. It scanned for indicators of virtual machines, containerized environments, or debugging tools. If it detected an analysis setup, the malware could simply refrain from executing, making it significantly harder for defenders to identify the threat during basic forensic investigation. Only when the system appeared to be a legitimate developer machine would the miner activate.

To further hide its presence, the cryptocurrency miner throttled its own resource consumption when the system was busy. This behavior reduces the likelihood of obvious performance degradation that might alert a developer or trigger system monitoring alerts. The miner operates in the background, using only spare processing capacity to generate Monero for the attackers. This approach allows it to persist on a developer machine for extended periods, quietly consuming electricity and CPU cycles without raising suspicion.

What is the specific Monero mining software used in this attack?

The malicious gems deploy XMRig, a well-known open-source Monero miner. The malware either bundles XMRig directly or downloads it from remote servers, including locations on GitHub such as raw.githubusercontent.com/xmrig/xmrig/v6.22.2/xmrig-6.22.2-linux-static-x64.tar.gzcodecodecode. The miner connects to several mining pools, including pool.supportxmr.com:443codecodecode and pool.moneroocean.stream:443codecodecode, to send the mined cryptocurrency to attacker-controlled Monero wallets.

The Second Wave: Typosquatting and Simpler Deployment

A second group of malicious gems used a less technically elaborate but equally dangerous approach. These packages relied on typosquatting — deliberately misspelling the names of trusted, popular libraries to trick developers into installing them. A developer intending to install a legitimate library might accidentally install a malicious gem with a name that differs by a single character. This technique has been used in numerous supply chain attacks across multiple package ecosystems.

The payload in this second group was simpler: a hidden Ruby file, typically named lib.threadpool.rbcodecodecode, that downloaded the XMRig miner when the package was loaded. It launched the mining process directly, without the persistence mechanisms or anti-analysis features seen in the first group. While less stealthy, this approach still posed a significant risk because it required no special conditions to activate — the moment a developer required the gem in their project, the mining code would execute.

SSH Worm Functionality Escalates the Threat Beyond Mining

What distinguishes this campaign from a standard cryptojacking operation is its worm-like propagation capability. The more advanced payload did not limit itself to mining Monero. After establishing itself on a compromised machine, it actively searched for SSH private keys stored in standard locations such as .ssh/id_rsacodecodecode. It also parsed the .ssh/known_hostscodecodecode file to identify systems that the compromised machine had previously connected to.

Armed with these credentials and a list of trusted hosts, the malware attempted to connect to those remote systems via SSH. This mechanism transforms a single infected development workstation into a launching pad for broader network infiltration. A developer’s laptop, already trusted by build servers, staging environments, or cloud infrastructure, becomes the gateway for the attacker to move laterally into more valuable targets. The infection could, in theory, cascade through an organization, compromising one machine after another using the inherent trust established by SSH key-based authentication.

The malware also targeted a wide range of development artifacts to ensure persistence and further spread. It could alter Node.js package files (package.jsoncodecodecode), Python setup scripts (setup.pycodecodecode), Ruby gem specifications (.gemspeccodecodecode), Dockerfiles, Git hooks, and even Visual Studio Code extension files. This cross-language, cross-platform propagation strategy makes cleanup exceptionally difficult. A security team might remove the original malicious Ruby gem from a project, but they could easily miss a modified Dockerfile that will reinfect the system during the next build, or a malicious Git hook that triggers the miner every time a developer commits code.

Practical Implications for Development and Security Teams

This campaign underscores a critical vulnerability in modern software development: the implicit trust placed in open-source package repositories. Developers routinely install dependencies from RubyGems, PyPI, npm, and similar registries without thoroughly vetting each package. The sheer volume of available packages makes manual inspection impractical, yet the consequences of a single malicious dependency can be severe.

For organizations, the first line of defense must be a rigorous package review process. This includes examining publisher history — are they newly created accounts? Scrutinizing download patterns — are the download numbers anomalously low for a package claiming to be a common utility? Inspecting the source code — does the gem require network access or execute external binaries? And verifying exact dependency names — does the package name precisely match the known library?

Security teams should conduct an immediate audit of recent RubyGems installations across all development and build machines. Any gems published by accounts named Prvaz12marscodecodecode, monib110codecodecode, or Andrey78codecodecode should be treated as compromised. Investigate unusual processor usage patterns that persist over time, particularly on machines that are idle during off-hours. Review SSH access logs for connections originating from developer workstations to unexpected internal servers. Assume that any SSH keys present on an infected machine are compromised and should be rotated immediately. Monitor network traffic for connections to known mining pool endpoints on ports 443, 3333, or 9000, among others.

The indicators of compromise provided by Unit 42 must be integrated into detection systems. Block outbound traffic to the identified mining pool domains and IP addresses. Search endpoints for the presence of the XMRig binary and its configuration files. Look for the hidden Ruby payload file lib.threadpool.rbcodecodecode and check for unauthorized modifications to .bashrccodecodecode, which the malware uses for persistence.

What indicators should security teams look for to detect this threat?

Security teams should monitor for the Monero wallets associated with the campaign, specifically 47vT2mcSzKPP2fEnZJ5QaVaF2fEEmvhxZHi26Hn9XixhY6tqNTtpXE8XXhG7Uoj6eta9a9HWmhssuS712s271jFf5vPngnncodecodecode (used by Prvaz12mars packages) and 8Aao1ANqXNeAfreezPgN3HYm5o96Jo8qEACDBZ1aZjjp5sRoP8HGcJwF97GEfP5GXofm9Y5vRMsWrWpxNNmKcQWh9qnqXZ2codecodecode (used by monib110 packages). Network defenders should block connections to mining pools such as pool.moneroocean.streamcodecodecode, p2pool.iocodecodecode, pool.supportxmr.comcodecodecode, and de.monero.herominers.comcodecodecode. File-based detection should focus on the XMRig download URLs from GitHub and the presence of lib.threadpool.rbcodecodecode in Ruby project directories.

The cross-language contamination capability means that the infection could persist even after the original Ruby dependency is removed. A thorough remediation effort must include scanning all project files across the development stack — Python, Node.js, Docker, Git, and IDE configurations — for unauthorized modifications. Any file that can execute code or define dependencies is a potential vector for reinfection.

This campaign also highlights the need for behavioral monitoring rather than signature-based detection alone. The miner’s ability to throttle itself and delay execution makes it harder to catch with traditional antivirus tools that rely on static signatures or immediate behavioral analysis. Endpoint detection and response (EDR) systems should be tuned to flag processes that establish outbound connections to unknown IP addresses on common mining ports, even if the process appears to be a legitimate system utility.

The long-term strategic response must involve the entire open-source ecosystem. Package registries like RubyGems need to implement more aggressive automated scanning, require two-factor authentication for publishers, and provide clearer reputational signals to developers. The community must also develop better tools for dependency auditing that can automatically flag suspicious patterns — such as delayed execution, network access, or file system modification — during the build process itself.

The attack ultimately demonstrates that the software supply chain is only as strong as its weakest dependency. A single overlooked package can turn a developer’s workstation into a covert mining rig and, through SSH worming, become the point of entry for a much wider network compromise. For organizations that depend on Ruby and the broader open-source ecosystem, the time for passive trust is over. Every dependency must be treated as a potential threat vector until proven otherwise.

Share This Article