Critical RubyGems Vulnerabilities Let Attackers Mine Monero and Spread via SSH
Key Takeaways A sophisticated campaign involving malicious RubyGems has been uncovered, transforming developer machines into covert Monero cryptocurrency miners. Beyond cryptojacking, some of these...
Key Takeaways
- A sophisticated campaign involving malicious RubyGems has been uncovered, transforming developer machines into covert Monero cryptocurrency miners.
- Beyond cryptojacking, some of these compromised packages can steal SSH credentials and propagate across a network, posing a significant lateral movement threat.
- Researchers identified two distinct groups of malicious gems, with one exhibiting advanced anti-analysis and persistence mechanisms, including delayed execution and VM detection.
- The attackers leveraged common library names and typosquatting to trick developers into downloading trojanized packages.
- Immediate action is required for organizations to audit RubyGems installations, monitor for unusual system activity, and secure SSH credentials.
A troubling new campaign is exploiting the RubyGems ecosystem, weaponizing seemingly innocuous developer packages to facilitate illicit cryptocurrency mining and enable network-wide propagation. These malicious gems are designed to hijack computational resources, silently generating Monero for attackers while significantly degrading system performance for unsuspecting developers.
Table Of Content
This threat extends beyond typical software supply chain attacks. One variant of the malicious RubyGems actively scans compromised developer workstations for SSH credentials and known host configurations. This capability creates a dangerous pathway for the infection to spread laterally to other servers and endpoints within an organization’s infrastructure.
Security researchers at Unit 42 said in a report that they have identified two distinct yet related clusters of malicious RubyGems uploads. Both groups employed similar naming conventions, specifically targeting developers in search of widely used programming libraries. This tactic underscores how adversaries can exploit the inherent trust developers place in public package repositories.
Collectively, the initial operation deployed 113 trojanized gems, resulting in 14,253 downloads. A subsequent group uploaded an additional 23 malicious packages. Furthermore, a related account was found to have uploaded 309 more gems, accumulating over 139,000 downloads, although no malicious code was detected in these specific packages at the time of the analysis.
Unit 42’s report, shared with Cyber Security News (CSN), revealed that the malicious packages were crafted by copying legitimate Ruby libraries and then modifying their entry-point files to inject and launch cryptocurrency mining code. This method is particularly concerning because a standard dependency installation can inadvertently become the initial breach point for a much broader infrastructure compromise.
Malicious RubyGems Turn Developer Machines Into Monero Miners
The first threat actor utilized automated-looking package names, often combining simple words such as “ultra,” “smart,” “tool,” and “kit.” This strategy is effective in making a malicious package appear legitimate during a hurried search for a small utility or a replacement library, a common scenario for developers.
Each package in this group contained an identical mining payload, programmed with a five-hour delay before execution. This delay is a deliberate evasion technique, designed to bypass rapid analysis within automated sandboxing environments, where suspicious software is typically observed for only a brief period post-installation.
The malware also incorporates checks to determine if it is operating within common virtual machines, containerized environments, or debugging setups. Should it detect such an analysis environment, it refrains from executing its malicious payload, thereby complicating detection efforts during initial investigations.
Once activated, the cryptocurrency miner intelligently throttles its resource consumption during periods of high system activity. This adaptive behavior minimizes noticeable performance degradation, allowing the miner to persist undetected on a developer’s machine for longer durations while still exploiting available processing power for Monero mining.
A second group of attackers employed a less complex strategy. Their malicious gems embedded a hidden Ruby file that, upon package loading, directly downloaded and launched the mining program. This approach lacked the sophisticated persistence and anti-analysis features observed in the first group.
Some packages from this second group were identified as typosquats, featuring names deliberately altered with minor spelling variations to mimic popular and trusted libraries. This tactic highlights a persistent risk that developers must remain vigilant against, as previous malicious RubyGems attacks have similarly leveraged deceptive dependency names to trick users.
SSH Worm Raises Stakes
The more advanced payload detected in this campaign went beyond mere cryptocurrency mining. It actively sought out SSH private keys and known-host records on the compromised machine. Subsequently, it attempted to establish connections to systems already trusted by the infected endpoint. This capability could transform a single compromised development machine into a critical pivot point for attackers, allowing them to infiltrate build servers, cloud workloads, or other internal systems.
Furthermore, this sophisticated malware demonstrated the ability to spread through local development assets. It could modify Node.js package files, Python setup scripts, Ruby gem specifications, Dockerfiles, Git hooks, and Visual Studio Code extensions. This cross-language and cross-tool propagation significantly broadens its reach within a development environment.
Such multi-language persistence makes remediation substantially more challenging. Security teams might successfully remove the initial malicious Ruby dependency but could easily overlook a modified project file, a compromised container build, or a malicious Git hook, leading to potential reinfection of systems at a later stage.
This campaign underscores the critical importance of rigorous package review processes. These reviews must encompass publisher history, download statistics, thorough source code examination, and precise verification of dependency names. Organizations should conduct immediate audits of recent RubyGems installations, investigate any unusual processor utilization, meticulously review SSH access logs, rotate all potentially exposed keys, and actively monitor for unexpected connections to cryptocurrency mining infrastructure.
Security teams are advised to block the provided Indicators of Compromise (IoCs) where applicable and to scan all endpoints for the listed artifacts. Continuous monitoring of outbound network traffic is essential, as cryptojacking activities can often blend into normal developer workloads, only becoming apparent when system performance noticeably degrades.
Indicators of Compromise (IoCs):
| Type | Indicator | Description |
|---|---|---|
| Monero wallet | 47vT2mcSzKPP2fEnZJ5QaVaF2fEEmvhxZHi26Hn9XixhY6tqNTtpXE8XXhG7Uoj6eta9a9HWmhssuS712s271jFf5vPngnn |
Wallet used by Prvaz12mars packages |
| Monero wallet | 8Aao1ANqXNeAfreezPgN3HYm5o96Jo8qEACDBZ1aZjjp5sRoP8HGcJwF97GEfP5GXofm9Y5vRMsWrWpxNNmKcQWh9qnqXZ2 |
Wallet used by monib110 packages |
| Mining pool | pool[.]moneroocean[.]stream:443 |
Prvaz12mars mining endpoint |
| Mining pool | p2pool[.]io:443 |
Prvaz12mars mining endpoint |
| Mining pool | pool[.]supportxmr[.]com:443 |
Mining endpoint used by both operations |
| Mining pool | de[.]monero[.]herominers[.]com:443 |
Prvaz12mars mining endpoint |
| Mining pool | pool[.]supportxmr[.]com:3333 |
monib110 mining endpoint |
| Download URL | raw[.]githubusercontent[.]com/xmrig/xmrig/v6.22.2/xmrig-6.22.2-linux-static-x64.tar.gz |
Miner archive download location |
| Download URL | raw[.]githubusercontent[.]com/xmrig/xmrig/v6.22.2/scripts/setup.sh |
Miner setup script location |
| Download URL | github[.]com/xmrig/xmrig/releases/download/v6.22.2/xmrig-6.22.2-linux-static-x64.tar.gz |
Miner release archive |
| API URL | api[.]github[.]com/repos/xmrig/xmrig/releases/latest |
Dynamic miner download lookup |
| Email address | [email protected] |
Prvaz12mars-associated email |
| Email address | [email protected] |
monib110-associated email |
| Email address | [email protected] |
Andrey78-associated email |
| RubyGems profile | rubygems[.]org/profiles/Prvaz12mars |
Prvaz12mars publisher profile |
| RubyGems profile | rubygems[.]org/profiles/monib110 |
monib110 publisher profile |
| RubyGems profile | rubygems[.]org/profiles/Andrey78 |
Related publisher profile |
| File name | lib.threadpool.rb |
Hidden Ruby payload used by monib110 packages |
| File name | .bashrc |
Persistence target used by Prvaz12mars payload |
| File name | .ssh/id_rsa |
SSH private-key target |
| File name | .ssh/known_hosts |
SSH known-host target |
What You Should Do
- Audit RubyGems Installations: Immediately review all recently installed RubyGems, especially those downloaded around the time of the campaign’s activity.
- Monitor System Performance: Investigate any unusual or sustained spikes in CPU usage on developer machines, as this could indicate hidden cryptocurrency mining.
- Review SSH Access: Scrutinize SSH access logs for unauthorized connections or unusual activity.
- Rotate SSH Keys: Assume any SSH private keys on compromised or potentially compromised developer machines are exposed and rotate them immediately.
- Network Monitoring: Implement robust outbound traffic monitoring to detect connections to known cryptocurrency mining pools and suspicious external IPs.
- Block IoCs: Configure firewalls, intrusion detection/prevention systems (IDS/IPS), and endpoint detection and response (EDR) solutions to block the provided Indicators of Compromise (IoCs).
- Scan for Artifacts: Use endpoint security tools to scan for the specific file names and other artifacts listed in the IoCs.
- Developer Education: Educate developers on the risks of supply chain attacks, emphasizing the importance of verifying package authenticity, publisher reputation, and avoiding typosquatted package names.
- Dependency Verification: Implement automated tools for dependency scanning and integrity checks to validate the authenticity and safety of third-party libraries before integration.
Disclaimer: HackersRadar reports on cybersecurity threats and incidents for informational and awareness purposes only. We do not engage in hacking activities, data exfiltration, or the hosting or distribution of stolen or leaked information. All content is based on publicly available sources.



No Comment! Be the first one.