{"id":"CVE-2021-21289","aliases":["DEBIAN-CVE-2021-21289","DLA-2561-1","EUVD-2021-0569","GHSA-qrqm-fpv6-6r8g","MGASA-2021-0124","UBUNTU-CVE-2021-21289"],"status":"published","title":"Command Injection Vulnerability in Mechanize","description":"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.","severity":{"version":"3.1","score":7.4,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:N/I:H/A:N","level":"high","assessor":"cna","from":"cve"},"epss":{"day":"2026-11-12","score":0.03549,"percentile":0.89468,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true},"cwes":["CWE-78"],"published":"2021-02-02T18:50:13Z","modified":"2026-10-24T10:48:38Z","fixes":[{"ecosystem":"RubyGems","package":"mechanize","fixed_in":["2.7.7"],"sources":["ghsa","osv"]},{"ecosystem":"Debian:12","package":"ruby-mechanize","fixed_in":["2.7.7-1"],"sources":["osv"]},{"ecosystem":"Debian:13","package":"ruby-mechanize","fixed_in":["2.7.7-1"],"sources":["osv"]},{"ecosystem":"Debian:14","package":"ruby-mechanize","fixed_in":["2.7.7-1"],"sources":["osv"]},{"ecosystem":"Debian:9","package":"ruby-mechanize","fixed_in":["2.7.5-1+deb9u1"],"sources":["osv"]},{"ecosystem":"Mageia:7","package":"ruby-mechanize","fixed_in":["2.7.6-2.1.mga7"],"sources":["osv"]},{"ecosystem":"Mageia:8","package":"ruby-mechanize","fixed_in":["2.7.6-3.1.mga8"],"sources":["osv"]}],"affected":[{"source":"ghsa","ecosystem":"RubyGems","package":"mechanize","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2.0.0"},{"fixed":"2.7.7"}]}]},{"source":"osv","ecosystem":"Debian:12","package":"ruby-mechanize","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"2.7.7-1"}]}]},{"source":"osv","ecosystem":"Debian:13","package":"ruby-mechanize","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"2.7.7-1"}]}]},{"source":"osv","ecosystem":"Debian:14","package":"ruby-mechanize","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"2.7.7-1"}]}]},{"source":"osv","ecosystem":"Debian:9","package":"ruby-mechanize","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"2.7.5-1+deb9u1"}]}],"versions":["2.7.5-1"]},{"source":"osv","ecosystem":"RubyGems","package":"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"]},{"source":"osv","ecosystem":"Mageia:7","package":"ruby-mechanize","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"2.7.6-2.1.mga7"}]}]},{"source":"osv","ecosystem":"Mageia:8","package":"ruby-mechanize","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"2.7.6-3.1.mga8"}]}]},{"source":"osv","ecosystem":"Ubuntu:16.04:LTS","package":"ruby-mechanize","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"}]}],"versions":["2.7.3-1"]},{"source":"osv","ecosystem":"Ubuntu:18.04:LTS","package":"ruby-mechanize","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"}]}],"versions":["2.7.5-1","2.7.5-2"]},{"source":"osv","ecosystem":"Ubuntu:20.04:LTS","package":"ruby-mechanize","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"}]}],"versions":["2.7.6-1"]},{"source":"osv","ecosystem":"Ubuntu:22.04:LTS","package":"ruby-mechanize","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"}]}],"versions":["2.7.7-1","2.7.7-3"]}],"products":[{"vendor":"debian","product":"debian_linux"},{"vendor":"fedoraproject","product":"fedora"},{"vendor":"mechanize_project","product":"mechanize"},{"vendor":"python-mechanize","product":"mechanize"},{"vendor":"sparklemotion","product":"mechanize"}],"references":[{"url":"https://github.com/sparklemotion/mechanize/security/advisories/GHSA-qrqm-fpv6-6r8g","tags":["x_refsource_CONFIRM","x_transferred","Third Party Advisory","advisory","web","report"]},{"url":"https://rubygems.org/gems/mechanize/","tags":["x_refsource_MISC","x_transferred","Product","Third Party Advisory","advisory","report"]},{"url":"https://github.com/sparklemotion/mechanize/releases/tag/v2.7.7","tags":["x_refsource_MISC","x_transferred","Release Notes","Third Party Advisory","advisory","web","report"]},{"url":"https://github.com/sparklemotion/mechanize/commit/66a6a1bfa653a5f13274a396a5e5441238656aa0","tags":["x_refsource_MISC","x_transferred","Patch","Third Party Advisory","fix","web","report"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/LBVVJUL4P4KCJH4IQTHFZ4ATXY7XXZPV/","tags":["vendor-advisory","x_refsource_FEDORA","x_transferred","web"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/YNFZ7ROYS6V4J5L5PRAJUG2AWC7VXR2V/","tags":["vendor-advisory","x_refsource_FEDORA","x_transferred","web"]},{"url":"https://lists.debian.org/debian-lts-announce/2021/02/msg00021.html","tags":["mailing-list","x_refsource_MLIST","x_transferred","Mailing List","Third Party Advisory","advisory","web"]},{"url":"https://security.gentoo.org/glsa/202107-17","tags":["vendor-advisory","x_refsource_GENTOO","x_transferred","Third Party Advisory","advisory","web"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-21289","tags":["advisory"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/LBVVJUL4P4KCJH4IQTHFZ4ATXY7XXZPV/"},{"url":"https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/YNFZ7ROYS6V4J5L5PRAJUG2AWC7VXR2V/"},{"url":"https://github.com/rubysec/ruby-advisory-db/blob/master/gems/mechanize/CVE-2021-21289.yml","tags":["web"]},{"url":"https://github.com/advisories/GHSA-qrqm-fpv6-6r8g"},{"url":"https://security-tracker.debian.org/tracker/CVE-2021-21289","tags":["advisory"]},{"url":"https://github.com/sparklemotion/mechanize","tags":["package"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/LBVVJUL4P4KCJH4IQTHFZ4ATXY7XXZPV","tags":["web"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/YNFZ7ROYS6V4J5L5PRAJUG2AWC7VXR2V","tags":["web"]},{"url":"https://rubygems.org/gems/mechanize","tags":["web"]},{"url":"https://advisories.mageia.org/MGASA-2021-0124.html","tags":["advisory"]},{"url":"https://bugs.mageia.org/show_bug.cgi?id=28448","tags":["report"]},{"url":"https://www.debian.org/lts/security/2021/dla-2561","tags":["web"]},{"url":"https://ubuntu.com/security/CVE-2021-21289","tags":["report"]},{"url":"https://github.com/sparklemotion/mechanize/commit/aae0b13514a1a0caf93b1cf233733c50e679069a","tags":["report"]},{"url":"https://github.com/sparklemotion/mechanize/commit/2ac906b26f4a565a0af92df5fb9c8a36c2b75375","tags":["report"]},{"url":"https://github.com/sparklemotion/mechanize/commit/f43a3952ab39341136656b0a8b2c8597ba1b4adc","tags":["report"]},{"url":"https://github.com/sparklemotion/mechanize/commit/b48b12f5db33c5a94a14dfcab8adf3e73cfa0388","tags":["report"]},{"url":"https://github.com/sparklemotion/mechanize/commit/63f8779e49664d5e95fae8d42d04c8e373162b3c","tags":["report"]},{"url":"https://www.cve.org/CVERecord?id=CVE-2021-21289","tags":["report"]}],"sources":{"cve":[{"id":"CVE-2021-21289","title":"Command Injection Vulnerability in Mechanize","description":"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.","status":"published","published":"2021-02-02T18:50:13Z","modified":"2024-08-03T18:09:15.157Z","cvss":[{"version":"3.1","score":7.4,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:N/I:H/A:N","level":"high","assessor":"cna"}],"cwes":["CWE-78"],"updated_at":"2026-11-02T14:33:00.137099Z"}],"euvd":[{"id":"EUVD-2021-0569","description":"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.","status":"published","published":"2021-02-02T18:50:13Z","modified":"2024-08-03T18:09:15Z","cvss":[{"version":"3.1","score":7.4,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:N/I:H/A:N","level":"high"}],"updated_at":"2026-11-03T03:25:06.913643Z"}],"ghsa":[{"id":"GHSA-qrqm-fpv6-6r8g","title":"Command Injection Vulnerability in Mechanize","description":"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).","status":"published","published":"2021-02-02T18:50:27Z","modified":"2023-05-04T19:54:26Z","cvss":[{"version":"3.1","score":7.4,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:N/I:H/A:N","level":"high"}],"cwes":["CWE-78"],"updated_at":"2026-11-02T14:36:52.310293Z"}],"nvd":[{"id":"CVE-2021-21289","description":"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.","status":"published","published":"2021-02-02T19:15:14.22Z","modified":"2026-06-17T03:35:12.263Z","cvss":[{"version":"3.1","score":7.4,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:N/I:H/A:N","level":"high","assessor":"secondary"},{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H","level":"high","assessor":"primary"},{"version":"2.0","score":7.6,"vector":"AV:N/AC:H/Au:N/C:C/I:C/A:C","level":"high","assessor":"primary"}],"cwes":["CWE-78"],"updated_at":"2026-11-02T14:06:49.660551Z"}],"osv":[{"id":"CVE-2021-21289","description":"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.","status":"published","published":"2021-02-02T19:15:14.22Z","modified":"2026-10-24T10:48:38.213398164Z","cvss":[{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H","level":"high"}],"updated_at":"2026-11-02T15:44:18.004149Z"},{"id":"DEBIAN-CVE-2021-21289","description":"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.","status":"published","published":"2021-02-02T19:15:14.22Z","modified":"2026-10-23T18:03:11.433667345Z","cvss":[{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H","level":"high"}],"updated_at":"2026-11-02T15:45:34.637046Z"},{"id":"GHSA-qrqm-fpv6-6r8g","title":"Command Injection Vulnerability in Mechanize","description":"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).","status":"published","published":"2021-02-02T18:50:27Z","modified":"2026-09-10T03:48:25.99839505Z","cvss":[{"version":"3.1","score":7.4,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:N/I:H/A:N","level":"high"}],"cwes":["CWE-78"],"updated_at":"2026-11-02T15:46:54.760124Z"},{"id":"UBUNTU-CVE-2021-21289","description":"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.","status":"published","published":"2021-02-02T19:15:00Z","modified":"2025-10-24T04:50:06Z","cvss":[{"version":"3.1","score":7.4,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:N/I:H/A:N","level":"high"},{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H","level":"high"}],"updated_at":"2026-11-02T15:54:26.29421Z"},{"id":"DLA-2561-1","title":"ruby-mechanize - security update","status":"published","published":"2021-02-17T00:00:00Z","modified":"2026-03-09T01:21:07.982371Z","updated_at":"2026-11-02T15:46:10.712745Z"},{"id":"MGASA-2021-0124","title":"Updated ruby-mechanize packages fix a security vulnerability","description":"In Mechanize, from v2.0.0 until v2.7.7, there is a command injection\nvulnerability. Affected versions of Mechanize allow for OS commands to be\ninjected using several classes' methods which implicitly use Ruby's Kernel#open\nmethod (CVE-2021-21289).\n","status":"published","published":"2021-03-12T01:25:47Z","modified":"2026-04-16T04:41:10.558859986Z","updated_at":"2026-11-02T15:49:41.509337Z"}]}}
