Incident Overview
Between late 2024 and early 2025, attackers published over 150 malicious gems to the RubyGems repository. These gems were not meant to compromise developers who downloaded them. Instead, the attackers used RubyGems as a platform to store scraped data from U.K. local government portals running ModernGov software.
Socket's security research team identified this campaign, dubbed GemStuffer. The gems fetched pages from council websites, packaged the HTML into .gem archives, and uploaded them back to RubyGems. This turned the repository into a data staging ground, rather than a malware distribution channel.
Timeline of Events
The exact start date of the campaign is unknown, but Socket detected it in late 2024. The operation continued into early 2025, with attackers publishing gems in batches. Each gem targeted specific council portals, scraped their public-facing pages, and repackaged the content.
RubyGems removed the malicious packages after Socket's disclosure. The timeline indicates the attackers operated undetected for weeks or months, publishing dozens of gems without triggering automated security controls.
Failed or Missing Controls
Repository Vetting Controls: RubyGems lacked automated detection for gems performing network requests to government domains upon installation. The gems made HTTP requests to ModernGov portals, fetched HTML content, and wrote files to disk—behaviors that should trigger review.
API Key Security: The gems contained hardcoded API keys for the RubyGems API, allowing attackers to automate gem publication. These keys should have been rotated or revoked after the first suspicious upload pattern.
Anomaly Detection: A single maintainer publishing over 150 gems rapidly, all following identical code patterns and targeting government websites, is a clear anomaly. RubyGems had no rate limiting or behavioral analysis to flag this activity.
Package Naming Controls: The gem names followed predictable patterns referencing their targets. Better namespace monitoring could have identified coordinated campaigns earlier.
Relevant Standards and Requirements
NIST Cybersecurity Framework v2.0 addresses supply chain risk in the Identify (ID) and Protect (PR) functions. Specifically, ID.SC-01 requires organizations to identify and document supply chain risk management processes. Repository operators like RubyGems must assess risks from hosted packages.
ISO/IEC 27001:2022 Annex A.5.19 covers information security in supplier relationships. For package repositories, this means implementing controls to verify package integrity and monitor for malicious behavior.
PCI DSS v4.0.1 Requirement 6.3.2 mandates that custom code is reviewed before release to production. Repository operators should implement similar controls, such as pre-publication scanning for hardcoded credentials and suspicious network activity.
SOC 2 Type II Common Criteria CC6.6 requires logical and physical access controls to restrict access to sensitive information. Hardcoded API keys in public packages violate this control. Repository operators must implement key rotation policies and automated credential scanning.
The gap here: none of these standards specifically address package repository operators' responsibilities. The security community needs clearer guidance on what "reasonable security controls" means for platforms hosting millions of packages.
Lessons and Action Items for Your Team
For Package Repository Operators:
- Deploy automated scanning for gems that make network requests during installation. Block publication if a package attempts DNS resolution or HTTP requests before any developer-initiated code runs.
- Implement rate limiting per maintainer account. Flag any account publishing more than 10 packages per day for manual review. Require additional verification for accounts publishing more than 50 packages total.
- Scan all packages for hardcoded credentials before publication. Use tools like TruffleHog or GitGuardian integrated into your CI/CD pipeline. Reject packages containing API keys, tokens, or private keys.
- Build behavioral profiles for maintainers. Track publication frequency, package naming patterns, code similarity across packages, and external domains referenced. Alert on statistical outliers.
For Teams Consuming Packages from Public Repositories:
- Add repository monitoring to your security program. Tools like Socket, Snyk, or Phylum can alert you when dependencies exhibit suspicious behavior.
- Implement Software Bill of Materials (SBOM) generation for every build. Document which packages you're using and track their provenance.
- Review your dependency update process. Add a manual review gate for new dependencies or major version bumps.
- Configure network egress controls for build environments. Your CI/CD runners shouldn't make HTTP requests to arbitrary domains during package installation.
For API Key Management:
- Rotate all API keys quarterly, at minimum. If a key is used in automation, implement programmatic rotation. Never commit keys to code, even in private repositories.
- Use short-lived tokens instead of long-lived API keys wherever possible. Services like GitHub Actions support OIDC token exchange—no stored credentials required.
- Implement secret scanning in your CI/CD pipeline and pre-commit hooks. Catch credentials before they reach your repository.
Conclusion
GemStuffer demonstrates that attackers are innovating beyond traditional supply chain attacks. They're exploiting repository infrastructure as free, reliable hosting for exfiltrated data. Your threat model needs to account for this.
Repository abuse is a control failure, not just a malware problem. The security community needs to pressure repository operators to implement the same rigor we demand from cloud providers and SaaS platforms. Until then, assume repositories are minimally vetted and implement defense in depth.



