CVE-2021-21289: Command Injection Vulnerability in Mechanize

Published Feb 2, 2021
·
Updated

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#saveas, Mechanize#download, Mechanize::Download#save, Mechanize::File#save, and Mechanize::FileResponse#readbody. This is fixed in version 2.7.7.

Other sources

This security advisory has been created for public disclosure of a Command Injection vulnerability that was responsibly reported by @kyoshidajp (Katsuhiko YOSHIDA).

Impact

Mechanize >= 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:

- Mechanize::CookieJar#load: since v2.0 (see 208e3ed) - Mechanize::CookieJar#saveas: since v2.0 (see 5b776a4) - Mechanize#download: since v2.2 (see dc91667) - Mechanize::Download#save and #save! since v2.1 (see 98b2f51, bd62ff0) - Mechanize::File#save and #saveas: since v2.1 (see 2bf7519) - Mechanize::FileResponse#readbody: since v2.0 (see 01039f5)

Patches

These vulnerabilities are patched in Mechanize v2.7.7.

Workarounds

No workarounds are available. We recommend upgrading to v2.7.7 or later.

References

See https://docs.rubocop.org/rubocop/copssecurity.html#securityopen for background on why Kernel.open should not be used with untrusted input.

For more information

If you have any questions or comments about this advisory, please open an issue in sparklemotion/mechanize.

Affected Software

5 affected componentsFixes available
rubygems/mechanize>=2.0.0<2.7.7
2.7.7
Mechanize Project Mechanize Ruby>=2.0<2.7.7
Fedoraproject Fedora=32
Fedoraproject Fedora=33
Debian Debian Linux=9.0

Event History

Feb 2, 2021
CVE Published
via MITRE·06:50 PM
Data Sourced
via MITRE·06:50 PM
DescriptionSeverityWeakness
Advisory Published
06:50 PM

Frequently Asked Questions

1

What is CVE-2021-21289?

CVE-2021-21289 is a Command Injection vulnerability in the Mechanize Ruby library.

2

How does CVE-2021-21289 impact Mechanize?

CVE-2021-21289 allows for OS commands to be injected using certain methods in Mechanize.

3

What is the severity of CVE-2021-21289?

CVE-2021-21289 has a severity score of 8.3 out of 10.

4

Which versions of Mechanize are affected by CVE-2021-21289?

Mechanize versions >= 2.0 and < 2.7.7 are affected by CVE-2021-21289.

5

How can I fix CVE-2021-21289?

To fix CVE-2021-21289, update Mechanize to version 2.7.7 or later.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203