{"id":"MAL-2026-17594","summary":"Malicious code in crypto-key-utils (RubyGems)","details":"RubyGems runs this gem's native extension script `ext/crypto-key-utils/extconf.rb` during `gem install`. The script exits without action on CI runners and sandboxes, based on CI environment variables, the hostname, the username and the working directory. It continues if the system uptime is over 30 minutes and the home directory holds `.ssh`, `.gitconfig`, `.npmrc`, `.gem/credentials` or `.bundle`. It then decodes a Base64 Ruby payload and forks twice into a detached process. After 20 to 40 minutes the payload downloads `http://45.138.12.177:8092/wgkit.tar.gz` to `/tmp/.w1.tgz` with `curl`, extracts it to `/tmp/.w1/`, runs `wg_install.sh` with `bash` and deletes both. The payload stores the URL XOR-encoded with the key `usv\\x9a`. The Ruby code in `lib/` is a decoy. The RubyGems account `reqthrottle_3474` published this gem and 41 others with the same loader on 2026-10-05.\n\n---\n_-= Per source details. Do not edit below this line.=-_\n\n## Source: amazon-inspector (559eb6e590366fcb8968de4964d8eb9d61ad6149a1ce1d4696ff4f64bff1a214)\nThe gem declares a native extension whose extconf.rb is the attack vehicle: the C source (ext/crypto-key-utils/crypto-key-utils.c) is a two-line empty Init stub, and create_makefile is only reached after a block of install-time logic. On `gem install`, extconf.rb runs sandbox/analysis evasion gates — skipping execution under CI, under analysis path prefixes (/tmp, /opt/rubygems, /workspace, /private/var/tmp), under generated usernames (uA\\d+, sandbox/tester/analys/scanner), on ephemeral hostnames (uvm, firecracker, sandbox, vagrant), and when /proc/uptime is below 1800 seconds — and requires developer-host signals (presence of ~/.ssh, ~/.gem/credentials, ~/.npmrc, ~/.bundle). When the gates pass, it base64-decodes an embedded Ruby payload and double-forks it. The payload XOR-decodes a hardcoded URL (hex blob XORed with key \"usv\\x9a\") resolving to http://45.138.127.77:8092/wgkit.tar.gz, sleeps a randomized 20–40 minutes, curls the tarball to /tmp/.w1.tgz over plain HTTP with no verification, extracts it, and executes bash /tmp/.w1/wg_install.sh. The lib/crypto-key-utils.rb entry is an unrelated BIP-39-style word list and does not implement the DER/PEM functionality the gem advertises.\n","modified":"2026-10-05T23:45:04.688315042Z","published":"2026-10-05T09:30:00Z","database_specific":{"iocs":{"files":[{"paths":["ext/crypto-key-utils/extconf.rb"],"source":"PACKAGE_ARCHIVE","digests":{"sha256":"dc851aecce1c2ea9652daafb151e5821c8d75e6263b934a4dc98ea82869d3343"},"note":"Native extension script that RubyGems runs at install time. It gates on the environment and starts the payload."},{"note":"Second-stage archive and install script downloaded and run by the payload.","paths":["/tmp/.w1.tgz","/tmp/.w1/wg_install.sh"],"source":"DROPPED"}],"ips":["45.138.12.177"],"urls":["http://45.138.12.177:8092/wgkit.tar.gz"]},"malicious-packages-origins":[{"sha256":"559eb6e590366fcb8968de4964d8eb9d61ad6149a1ce1d4696ff4f64bff1a214","source":"amazon-inspector","versions":["1.0.0"],"id":"IN-MAL-2026-021064","import_time":"2026-10-05T16:22:55.916180118Z","modified_time":"2026-10-05T15:58:56Z"}]},"references":[{"type":"PACKAGE","url":"https://rubygems.org/gems/crypto-key-utils/versions/1.0.0"},{"type":"REPORT","url":"https://safedep.io/rubygems-crypto-gems-install-time-reverse-shell/"}],"affected":[{"package":{"name":"crypto-key-utils","ecosystem":"RubyGems","purl":"pkg:gem/crypto-key-utils"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"}]}],"versions":["1.0.0"],"database_specific":{"indicators":{"evidence_files":[{"tlsh":"ca51cb56cb8395f54db1d0d044359412fb66bb0d6068ad64f3de0868bb5af2ac4f02fd","path":"ext/crypto-key-utils/extconf.rb","sha256":"dc851aecce1c2ea9652daafb151e5821c8d75e6263b934a4dc98ea82869d3343"},{"sha256":"7920c1543b84f5a68921718e7593becfeb6112bbdd306c55d87aabe0351ffbf7","tlsh":"e99002e5857864414044a2e2533582494191f8144d187e557b172555a5e02847d6a170","path":"ext/crypto-key-utils/crypto-key-utils.c"}]},"cwes":[{"name":"Embedded Malicious Code","cweId":"CWE-506","description":"The product contains code that appears to be malicious in nature."},{"cweId":"CWE-506","description":"The product contains code that appears to be malicious in nature.","name":"Embedded Malicious Code"}],"source":"https://github.com/ossf/malicious-packages/blob/main/osv/malicious/rubygems/crypto-key-utils/MAL-2026-17594.json"}}],"schema_version":"1.9.0","credits":[{"name":"Amazon Inspector","contact":["inspector-research@amazon.com"],"type":"FINDER"},{"name":"SafeDep","contact":["https://safedep.io"],"type":"FINDER"}]}