Skip to main content
Three Dormant RubyGems Accounts Hijacked to Spread MalwareIncident
4 min readFor Security Engineers

Three Dormant RubyGems Accounts Hijacked to Spread Malware

What Happened

Three RubyGems packages, impersonating legitimate Ruby tools, were hijacked and republished with malicious code to steal credentials from developer workstations. These packages scanned for CI environment variables and exited silently if detected, specifically targeting developer machines where secrets are more likely to be exposed. The rogue gems were published without any matching commit or tag in the source projects, making the attack invisible to teams that monitor repositories but not package registries directly.

This wasn't a typosquatting campaign. The attackers compromised dormant RubyGems accounts and republished existing, legitimate package names with malicious versions.

Timeline

The exact timeline of account compromise remains unclear, but the attack pattern is consistent: dormant accounts were accessed, malicious versions were published to RubyGems, and the packages began spreading through dependency chains. StepSecurity and Aikido Security researchers identified the malicious packages after they'd already been published and potentially installed on developer machines.

If your team installed any of these packages during the compromise window, treat those machines as compromised and rotate all credentials accessible from those environments.

Which Controls Failed or Were Missing

Package Registry Monitoring
Most teams monitor their source code repositories for unauthorized commits, but few monitor package registries for unauthorized publishes. The malicious packages scanned for environment variables related to CI systems and exited if detected, knowing your CI pipeline might catch them, but your developer workstations wouldn't.

Dormant Account Management
The attackers targeted accounts that hadn't published in months or years. These accounts retained publish permissions but lacked active maintainers who would notice unauthorized activity. No alerts fired when these accounts suddenly published new versions after extended dormancy.

Dependency Pinning and Lock File Review
Teams using unpinned dependencies (like gem 'package-name' without version constraints) automatically pulled malicious versions. Even teams with lock files may not have reviewed the lock file diffs closely enough to notice that a previously stable dependency had a new version from an unexpected source.

Developer Workstation Hardening
The malware specifically avoided CI environments because it knew those systems are more likely to be ephemeral and monitored. Developer machines, where secrets are stored in shell configurations, credential managers, and environment variables, were the actual targets.

What the Standards Require

OWASP ASVS v4.0.3 Requirement 14.2.1 calls for verification that all components are free from known vulnerabilities. This includes verifying that packages come from expected sources and haven't been tampered with. Publishing a gem without a corresponding source commit is a red flag that this requirement would catch if you're checking for it.

PCI DSS v4.0.1 Requirement 6.3.2 requires that changes to system components are approved by authorized personnel. In a supply chain context, this means verifying that package updates come from legitimate maintainers. Dormant accounts publishing after months of inactivity should trigger approval workflows.

NIST 800-53 Rev 5 Control SA-12 addresses supply chain protection, requiring organizations to employ anti-counterfeit measures and protect against the insertion of counterfeits into the supply chain. Package registry monitoring and maintainer verification are direct implementations of this control.

ISO/IEC 27001:2022 Control 8.30 covers outsourcing and supplier relationships, which includes your dependency supply chain. You need processes to verify that third-party components remain trustworthy throughout their lifecycle, not just at initial adoption.

Lessons and Action Items for Your Team

Implement Registry-Level Monitoring
Don't just watch your Git repositories. Monitor your package registries for unexpected publishes, especially from packages you depend on. Set up alerts when:

  • A package publishes a new version without a corresponding Git tag
  • A dormant package (no updates in 90+ days) suddenly publishes
  • The publisher account differs from historical patterns

Audit Dormant Accounts You Maintain
If your team maintains open-source packages, review all accounts with publish permissions. Rotate credentials for any account that hasn't published in the last six months. Enable multi-factor authentication on all package registry accounts, most registries support this now.

Pin Your Dependencies and Review Lock Files
Use exact version pinning in production (gem 'package', '1.2.3' not gem 'package', '~> 1.2'). Treat lock file changes as security-relevant code changes. In pull request reviews, ask: "Why did this dependency version change? Where's the changelog?"

Harden Developer Workstations
The malicious packages scan for environment variables related to CI systems and exit if detected. This tells you something important: attackers assume your CI is harder to compromise than your developers' laptops. Treat developer machines as high-value targets:

  • Don't store production credentials in shell configurations
  • Use credential managers that require authentication per use
  • Run dependency installs in containers or VMs when possible
  • Monitor outbound network connections from development environments

Establish Package Provenance Verification
Before adding a new dependency, verify that:

  • The package registry entry links to a legitimate source repository
  • Recent versions have corresponding Git tags
  • The maintainer account has a history of legitimate activity
  • The package doesn't request excessive permissions for its stated purpose

Create an Incident Response Plan for Compromised Dependencies
Users are advised to treat machines with the installed gems as compromised and to rotate all credentials. Do you have a runbook for this scenario? Document the steps: which credentials need rotation, how to identify affected machines, who needs to be notified, and how to verify remediation.

The SleeperGem attack succeeded because it exploited the gap between how you monitor code and how you monitor packages. Your repository might be locked down, but your package registry is a separate attack surface. Close that gap.

RubyGems

Topics:Incident

You Might Also Like