{"id":"GHSA-qrqm-fpv6-6r8g","summary":"Command Injection Vulnerability in Mechanize","details":"This security advisory has been created for public disclosure of a Command Injection vulnerability that was responsibly reported by @kyoshidajp (Katsuhiko YOSHIDA).\n\n### Impact\n\nMechanize `\u003e= v2.0`, `\u003c v2.7.7` allows for OS commands to be injected using several classes' methods which implicitly use Ruby's `Kernel.open` method. Exploitation is possible only if untrusted input is used as a local filename and passed to any of these calls:\n\n- `Mechanize::CookieJar#load`: since v2.0 (see 208e3ed)\n- `Mechanize::CookieJar#save_as`: since v2.0 (see 5b776a4)\n- `Mechanize#download`: since v2.2 (see dc91667)\n- `Mechanize::Download#save` and `#save!` since v2.1 (see 98b2f51, bd62ff0)\n- `Mechanize::File#save` and `#save_as`: since v2.1 (see 2bf7519)\n- `Mechanize::FileResponse#read_body`: since v2.0 (see 01039f5)\n\n\n### Patches\n\nThese vulnerabilities are patched in Mechanize v2.7.7.\n\n\n### Workarounds\n\nNo workarounds are available. We recommend upgrading to v2.7.7 or later.\n\n\n### References\n\nSee https://docs.rubocop.org/rubocop/cops_security.html#securityopen for background on why `Kernel.open` should not be used with untrusted input.\n\n\n### For more information\n\nIf you have any questions or comments about this advisory, please open an issue in [sparklemotion/mechanize](https://github.com/sparklemotion/mechanize/issues/new).","aliases":["CVE-2021-21289"],"modified":"2026-05-07T05:00:38.727529737Z","published":"2021-02-02T18:50:27Z","database_specific":{"github_reviewed":true,"github_reviewed_at":"2021-02-02T18:50:15Z","nvd_published_at":"2021-02-02T19:15:00Z","cwe_ids":["CWE-78"],"severity":"HIGH"},"references":[{"type":"WEB","url":"https://github.com/sparklemotion/mechanize/security/advisories/GHSA-qrqm-fpv6-6r8g"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2021-21289"},{"type":"WEB","url":"https://github.com/sparklemotion/mechanize/commit/66a6a1bfa653a5f13274a396a5e5441238656aa0"},{"type":"WEB","url":"https://github.com/rubysec/ruby-advisory-db/blob/master/gems/mechanize/CVE-2021-21289.yml"},{"type":"PACKAGE","url":"https://github.com/sparklemotion/mechanize"},{"type":"WEB","url":"https://github.com/sparklemotion/mechanize/releases/tag/v2.7.7"},{"type":"WEB","url":"https://lists.debian.org/debian-lts-announce/2021/02/msg00021.html"},{"type":"WEB","url":"https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/LBVVJUL4P4KCJH4IQTHFZ4ATXY7XXZPV"},{"type":"WEB","url":"https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/YNFZ7ROYS6V4J5L5PRAJUG2AWC7VXR2V"},{"type":"WEB","url":"https://rubygems.org/gems/mechanize"},{"type":"WEB","url":"https://security.gentoo.org/glsa/202107-17"}],"affected":[{"package":{"name":"mechanize","ecosystem":"RubyGems","purl":"pkg:gem/mechanize"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2.0.0"},{"fixed":"2.7.7"}]}],"versions":["2.0","2.0.1","2.1","2.1.1","2.1.pre.1","2.2","2.2.1","2.3","2.4","2.5","2.5.1","2.6.0","2.7.0","2.7.1","2.7.2","2.7.3","2.7.4","2.7.5","2.7.6"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2021/02/GHSA-qrqm-fpv6-6r8g/GHSA-qrqm-fpv6-6r8g.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:N/I:H/A:N"}]}