Skip to main content
Scrapers in RubyGems Targeted UK Government ServersIncident
4 min readFor Security Engineers

Scrapers in RubyGems Targeted UK Government Servers

What Happened

Threat actors published malicious packages to RubyGems containing scrapers designed to target public-facing UK government servers. These packages appeared legitimate but included code that attempted to extract data from government infrastructure. The attackers' end goal remains unknown -- they may have been conducting reconnaissance, establishing persistence, or testing exfiltration channels.

RubyGems, the package manager for the Ruby programming language, hosts over 175,000 packages. Like npm, PyPI, and other public repositories, it operates on a trust model: anyone can publish, and most organizations download dependencies without deep inspection.

Timeline

The exact timeline isn't fully public, but the pattern follows what we've seen in other package manager attacks:

  • Initial publication: Attackers create packages with names similar to popular gems or with generic utility-sounding names that blend into dependency lists.
  • Installation phase: Developers or automated build systems pull the malicious packages during routine dependency updates or new project setups.
  • Execution: The scraper code runs either during installation (via post-install hooks) or when the package is first required in application code.
  • Discovery: Security researchers or automated scanning tools flag suspicious network behavior or code patterns.
  • Disclosure: The malicious packages are reported to RubyGems maintainers and removed from the repository.

This incident is notable because the scrapers specifically targeted government infrastructure rather than attempting broad credential theft or cryptomining, which are more common objectives in supply chain attacks.

Which Controls Failed or Were Missing

  • Dependency vetting: Organizations likely installed these packages without code review. Most teams treat package managers as trusted sources and don't inspect what they're pulling into their build environments.
  • Network egress monitoring: The scrapers contacted UK government servers. If these packages were installed in controlled environments, outbound connections to unexpected government domains should have triggered alerts.
  • Build isolation: If the malicious code executed during installation, it suggests builds ran with network access to production or internet-facing systems. Proper isolation would have contained the scraper's reach.
  • Software Bill of Materials (SBOM): Without an SBOM, teams couldn't quickly identify which applications or environments included the compromised packages after disclosure.
  • Automated scanning: Static analysis tools should catch suspicious patterns like HTTP requests to hardcoded government domains in a utility package. The fact these packages reached production suggests scanning gaps.

What the Standards Require

  • PCI DSS v4.0.1 Requirement 6.3.2 requires organizations to maintain an inventory of bespoke and custom software and third-party components. This includes dependencies pulled from package managers.
  • Requirement 6.4.3 mandates that scripts and custom code are reviewed before deployment to production. This applies to your application code and the dependencies it includes.
  • ISO 27001 Control 8.31 (Security of information in use) requires protecting information during processing. Installing unvetted packages that make network requests to external servers violates this control.
  • NIST 800-53 Rev 5 Control SA-12 (Supply Chain Protection) requires organizations to employ anti-counterfeit, malicious code detection, and vulnerability scanning for acquired components.
  • SOC 2 Type II Common Criteria CC6.8 requires logical access controls that prevent unauthorized access to data.

The gap isn't that standards don't cover this -- they do. The gap is treating package managers as exempt from the same controls you apply to other software sources.

Lessons and Action Items for Your Team

  • Implement dependency scanning in CI/CD: Tools like Dependabot, Snyk, or OWASP Dependency-Check flag known vulnerabilities. You also need behavioral analysis -- solutions that execute packages in sandboxes and monitor for suspicious network activity or file system access. Socket.dev and Phylum specialize in detecting malicious behavior in packages.
  • Lock your dependencies: Use Gemfile.lock (for Ruby), package-lock.json (for Node), or equivalent lock files for every language. Pin exact versions. When you run bundle install, you should get the same packages you tested, not whatever was published yesterday.
  • Review new dependencies before adding them: Before adding a gem to your Gemfile, check: When was it first published? Who maintains it? Does it have recent commits? How many downloads? A package published two weeks ago with 47 downloads that claims to be a "common utility" is suspicious.
  • Isolate build environments: Your CI/CD runners shouldn't have network access to production systems or sensitive infrastructure. If a malicious package executes during bundle install, it should hit a network boundary before reaching anything valuable.
  • Monitor egress traffic: Log and alert on unexpected outbound connections from build and development environments. A Ruby application that suddenly contacts government servers during installation should trigger an investigation.
  • Generate and maintain SBOMs: Use tools like CycloneDX or SPDX to create software bills of materials for every application. When a malicious package is disclosed, you need to know within minutes which systems are affected.
  • Establish a private package mirror: For high-security environments, mirror RubyGems (or other package repositories) internally. Scan packages before they enter the mirror. This adds friction but gives you a chokepoint for inspection.
  • Enable community reporting channels: If your team discovers suspicious packages, report them. RubyGems, npm, and PyPI all have abuse reporting processes. Community vigilance caught this attack -- it works when people participate.

The attackers in this incident didn't exploit a zero-day or breach a perimeter. They published code to a public repository and waited for your build system to install it. The controls that would have stopped them aren't exotic -- they're the same dependency management practices that standards already require. The question is whether you're applying them to package managers with the same rigor you apply to other third-party software.

Topics:Incident

You Might Also Like