{"id":"MAL-2026-17617","summary":"Malicious code in web3-sign-helper (RubyGems)","details":"RubyGems runs this gem's native extension script `ext/web3-sign-helper/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 (adeb83bd6e9fada6d55dfe140c32a5ae29d4b3331fb888643ebe064e6d57fc23)\nThe gem declares a C native extension at ext/web3-sign-helper/extconf.rb, but the shipped C source is a 53-byte empty Init_Web3SignHelper stub and the Ruby library only exposes a static word list — the native-extension declaration exists solely to get extconf.rb executed by RubyGems at install time. Before create_makefile, extconf.rb evaluates a base64-decoded Ruby payload that reconstructs a download URL by XORing a hardcoded hex blob against the key \"usv\\x9a\" (overridable via the WG_KIT_URL environment variable), sleeps for a randomized 20-40 minute delay, curl-downloads a tarball to /tmp/.w1.tgz, extracts it, and runs bash /tmp/.w1/wg_install.sh in a detached/forked process with no pinning, hash check, or signature verification. Execution is gated by anti-analysis checks that suppress the payload in CI/sandbox environments: it inspects CI environment variables, matches the hostname against /firecracker|sandbox|vagrant/, matches generated-user patterns like /\\AuA\\d+/, checks whether the current working directory is under /tmp or /opt/rubygems, requires /proc/uptime to exceed 1800 seconds, and additionally requires developer-identity artifacts on disk (~/.ssh, ~/.gitconfig, ~/.gem/credentials, ~/.bundle) before firing. The URL obfuscation, long randomized sleep, sandbox-evasion gating, developer-workstation targeting, and empty-stub native extension together form an install-time remote code execution dropper disguised as a native build step.\n","modified":"2026-10-05T23:45:06.787491952Z","published":"2026-10-05T09:30:00Z","database_specific":{"iocs":{"files":[{"source":"PACKAGE_ARCHIVE","digests":{"sha256":"4699cb4f40e8f9ab766544bb32d11af63a52e553d7b57c0e39e6200e910411f4"},"note":"Native extension script that RubyGems runs at install time. It gates on the environment and starts the payload.","paths":["ext/web3-sign-helper/extconf.rb"]},{"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":[{"import_time":"2026-10-05T16:22:55.681056048Z","modified_time":"2026-10-05T15:58:32Z","sha256":"adeb83bd6e9fada6d55dfe140c32a5ae29d4b3331fb888643ebe064e6d57fc23","source":"amazon-inspector","versions":["1.0.0"],"id":"IN-MAL-2026-021061"}]},"references":[{"type":"PACKAGE","url":"https://rubygems.org/gems/web3-sign-helper/versions/1.0.0"},{"type":"REPORT","url":"https://safedep.io/rubygems-crypto-gems-install-time-reverse-shell/"}],"affected":[{"package":{"name":"web3-sign-helper","ecosystem":"RubyGems","purl":"pkg:gem/web3-sign-helper"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"}]}],"versions":["1.0.0"],"database_specific":{"indicators":{"evidence_files":[{"sha256":"4699cb4f40e8f9ab766544bb32d11af63a52e553d7b57c0e39e6200e910411f4","tlsh":"5c51cb568b8395f54db1d0d044795413fb667b0d6068ac64f3de0868bb5af2ac4f02fd","path":"ext/web3-sign-helper/extconf.rb"},{"path":"ext/web3-sign-helper/web3-sign-helper.c","sha256":"7906af16f00c5ff6b3c9816071dbcb5dd181c65c933e8f3159078ae88dd82c78","tlsh":"709002c2c53870024000efe1932d51498090b5544f59754669032156a750294396b5b4"}]},"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/web3-sign-helper/MAL-2026-17617.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"}]}