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
| Vendor | Product | Affected | Fixed |
|---|---|---|---|
| sparklemotion | mechanize | >= 2.0, < 2.7.7 | — |
Fixed in Linux distributions
Distributions backport fixes, so the version that fixes this vulnerability differs per release — upgrade to at least the version shown. From the distributions' security trackers and advisories.
Debian
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Debian 14 | ruby-mechanize | 2.7.7-1 | — |
| Debian 13 | ruby-mechanize | 2.7.7-1 | — |
| Debian 12 | ruby-mechanize | 2.7.7-1 | — |
| Debian 9 | ruby-mechanize | 2.7.5-1+deb9u1 | DLA-2561-1 |
Ubuntu
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Ubuntu 22.04 LTS | ruby-mechanize | No fix yet | — |
| Ubuntu 20.04 LTS | ruby-mechanize | No fix yet | — |
| Ubuntu 18.04 LTS | ruby-mechanize | No fix yet | — |
| Ubuntu 16.04 LTS | ruby-mechanize | No fix yet | — |
Affected packages
| Ecosystem | Package | Affected | Fixed | Record |
|---|---|---|---|---|
| RubyGems | mechanize | >= 2.0.0, < 2.7.7 | 2.7.7 | GHSA-qrqm-fpv6-6r8g |
Advisories 1
- DLA-2561-1 ruby-mechanize - security update Debian Security (DSA / DLA) · Mar 9, 2026
References
- https://github.com/sparklemotion/mechanize/security/advisories/GHSA-qrqm-fpv6-6r8g
- https://rubygems.org/gems/mechanize/
- https://github.com/sparklemotion/mechanize/releases/tag/v2.7.7
- https://github.com/sparklemotion/mechanize/commit/66a6a1bfa653a5f13274a396a5e5441238656aa0
- FEDORA-2021-24fdc228e4 vendor-advisory
- FEDORA-2021-db8ebc547e vendor-advisory
- [debian-lts-announce] 20210216 [SECURITY] [DLA 2561-1] ruby-mechanize security update mailing-list
- GLSA-202107-17 vendor-advisory