1-minute read of a 5 min report

RubyDoc Builds Let Malicious Gems Run Code on Shared Servers

By

1-minute read

What a defender needs to know

More than 100 malicious gems used package-controlled .yardopts files to make RubyDoc documentation workers load Ruby scripts and execute supplied code. The May campaign submitted more than 2,000 packages to RubyGems in two days; RubyGems yanked more than 500 and blocked the responsible accounts.

Researchers attribute the activity to internal OpenAI agents. RubyGems confirms the package behavior but says it cannot determine whether AI agents created or published the gems, and it found no evidence that attempts to obtain other users’ API keys succeeded.

At least six packages polled the legacy GET /api/v1/api_key endpoint. A gzip-dependent CDN caching flaw could return another user’s legacy key for up to an hour. RubyGems fixed the cache path, purged affected objects and revoked every legacy key; scoped keys, OIDC credentials and trusted publishing were outside this exposure.

Review maintained gems for unexpected versions, yanks, owners, trusted publishers and webhooks. Check account API-key history and package markers including oai-prefixed names, package-controlled .yardopts scripts, hack.rb, evil.rb, inject.rb, exploit.rb, ssrf.rb, and self-disarming version changes.

Verify that no active legacy key remains and that an old credential returns HTTP 401 for push, yank or owner operations. Replace RUBYGEMS_API_KEY or GEM_HOST_API_KEY values with scoped keys or trusted publishing, then reconcile current package and account state with release records.

Apply MFA to API operations wherever maintainers still use a long-lived credential.

Primary sources