{"id":"CVE-2021-21289","aliases":["CVE-2021-21289","GHSA-qrqm-fpv6-6r8g"],"related":[],"kind":"vulnerability","state":"published","title":"Command Injection Vulnerability in Mechanize","summary":"Mechanize is an open-source ruby library that makes automated web interaction easy. In Mechanize from version 2.0.0 and before version 2.7.7 there is a command injection vulnerability. Affected versions of mechanize allow 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: Mechanize::CookieJar#load, Mechanize::CookieJar#save_as, Mechanize#download, Mechanize::Download#save, Mechanize::File#save, and Mechanize::FileResponse#read_body. This is fixed in version 2.7.7.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Mechanize is an open-source ruby library that makes automated web interaction easy. In Mechanize from version 2.0.0 and before version 2.7.7 there is a command injection vulnerability. Affected versions of mechanize allow 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: Mechanize::CookieJar#load, Mechanize::CookieJar#save_as, Mechanize#download, Mechanize::Download#save, Mechanize::File#save, and Mechanize::FileResponse#read_body. This is fixed in version 2.7.7.","source":"cvelist"},{"lang":"en","text":"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 `>= v2.0`, `< 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).","format":"markdown","source":"ghsa"},{"lang":"es","text":"Mechanize es una biblioteca de ruby ??de código abierto que facilita la interacción web automatizada.&#xa0;En Mechanize desde versión 2.0.0 y versiones anteriores a 2.7.7, se presenta una vulnerabilidad de inyección de comandos.&#xa0;Las versiones afectadas de mechanize permiten a unos comandos del Sistema Operativo ser inyectados usando métodos de varias clases que implícitamente usan el método Kernel.open de Ruby.&#xa0;Una explotación es posible solo si es usada una entrada que no sea confiable como nombre de archivo local y sea pasada a cualquiera de estas llamadas: Mechanize::CookieJar#load, Mechanize::CookieJar#save_as, Mechanize#download, Mechanize::Download#save, Mechanize::File#save y Mechanize::FileResponse#read_body.&#xa0;Esto es corregido en versión 2.7.7","source":"nvd"}],"published":"2021-02-02T18:50:13.000Z","modified":"2026-09-10T03:48:25.998Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:N/I:H/A:N","score":7.4,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:N/I:H/A:N","score":7.4,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:N/I:H/A:N","score":7.4,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H","score":8.3,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:2.0","vector":"AV:N/AC:H/Au:N/C:C/I:C/A:C","score":7.6,"rating":"HIGH"}],"cwes":["CWE-78"],"affected":[{"ranges":[{"version":">= 2.0, < 2.7.7","status":"affected"}],"vendor":"sparklemotion","product":"mechanize","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"2.0.0","status":"affected","fixed":"2.7.7"}],"ecosystem":"RubyGems","package":"mechanize","purl":"pkg:gem/mechanize","source":"ghsa"},{"ranges":[{"status":"affected","introduced":"2.0","fixed":"2.7.7"}],"vendor":"mechanize_project","product":"mechanize","cpe":"cpe:2.3:a:mechanize_project:mechanize:*:*:*:*:*:ruby:*:*","source":"nvd"},{"ranges":[{"status":"affected","version":"32"},{"status":"affected","version":"33"}],"vendor":"fedoraproject","product":"fedora","cpe":"cpe:2.3:o:fedoraproject:fedora:32:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"status":"affected","version":"9.0"}],"vendor":"debian","product":"debian_linux","cpe":"cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/sparklemotion/mechanize/security/advisories/GHSA-qrqm-fpv6-6r8g","tags":["third-party-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://rubygems.org/gems/mechanize/","tags":["product","third-party-advisory","x-refsource-misc","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://github.com/sparklemotion/mechanize/releases/tag/v2.7.7","tags":["release-notes","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/sparklemotion/mechanize/commit/66a6a1bfa653a5f13274a396a5e5441238656aa0","tags":["patch","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/LBVVJUL4P4KCJH4IQTHFZ4ATXY7XXZPV/","tags":["vendor-advisory","x-refsource-fedora","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/YNFZ7ROYS6V4J5L5PRAJUG2AWC7VXR2V/","tags":["vendor-advisory","x-refsource-fedora","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://lists.debian.org/debian-lts-announce/2021/02/msg00021.html","tags":["mailing-list","third-party-advisory","web","x-refsource-mlist","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://security.gentoo.org/glsa/202107-17","tags":["third-party-advisory","vendor-advisory","web","x-refsource-gentoo","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-21289","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/rubysec/ruby-advisory-db/blob/master/gems/mechanize/CVE-2021-21289.yml","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/sparklemotion/mechanize","tags":["package"],"sources":["ghsa"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/LBVVJUL4P4KCJH4IQTHFZ4ATXY7XXZPV","tags":["web"],"sources":["ghsa"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/YNFZ7ROYS6V4J5L5PRAJUG2AWC7VXR2V","tags":["web"],"sources":["ghsa"]},{"url":"https://rubygems.org/gems/mechanize","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2021-21289","url":"https://www.cve.org/CVERecord?id=CVE-2021-21289","licence":"CVE Terms of Use","modified":"2024-08-03T18:09:15.157Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-qrqm-fpv6-6r8g","url":"https://github.com/advisories/GHSA-qrqm-fpv6-6r8g","licence":"CC-BY-4.0","modified":"2026-09-10T03:48:25.998Z"},{"source":"nvd","name":"NVD","id":"CVE-2021-21289","url":"https://nvd.nist.gov/vuln/detail/CVE-2021-21289","licence":"Public domain","modified":"2026-06-17T03:35:12.263Z"}],"updatedAt":"2026-11-25T22:57:59.776Z","epss":{"score":0.03549,"percentile":0.89604,"date":"2026-12-01T12:00:22.000Z"}}