What’s Vulnerable › Vulnerabilities
CVE-2021-21289: Command Injection Vulnerability in Mechanize
- Severity: high (CVSS 8.3 v3.1)
- Exploited in the wild: not listed in CISA KEV
- EPSS: 3.5% probability of exploitation in the next 30 days
- Public exploit or detection template: none known
- Published: 2021-02-02 · updated 2026-06-17
- Weakness: CWE-78
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.
Affected products
- Debian Linux: 9.0
- Fedoraproject Fedora: 32, 33
- python-mechanize mechanize: from 2.0 before 2.7.7 — fixed in 2.7.7
How to fix
Upgrade to a fixed version: python-mechanize mechanize 2.7.7. Check the vendor advisory for mitigations.
References
- https://github.com/sparklemotion/mechanize/commit/66a6a1bfa653a5f13274a396a5e5441238656aa0
- https://github.com/sparklemotion/mechanize/releases/tag/v2.7.7
- https://github.com/sparklemotion/mechanize/security/advisories/GHSA-qrqm-fpv6-6r8g
- https://lists.debian.org/debian-lts-announce/2021/02/msg00021.html
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/LBVVJUL4P4KCJH4IQTHFZ4ATXY7XXZPV/
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/YNFZ7ROYS6V4J5L5PRAJUG2AWC7VXR2V/
- https://rubygems.org/gems/mechanize/
- https://security.gentoo.org/glsa/202107-17
- https://github.com/sparklemotion/mechanize/commit/66a6a1bfa653a5f13274a396a5e5441238656aa0
- https://github.com/sparklemotion/mechanize/releases/tag/v2.7.7
- https://github.com/sparklemotion/mechanize/security/advisories/GHSA-qrqm-fpv6-6r8g
- https://lists.debian.org/debian-lts-announce/2021/02/msg00021.html
Get alerted when CVE-2021-21289 or the next vulnerability affects your stack