# CVE-2021-21289: Command Injection Vulnerability in Mechanize

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** HIGH 7.4
- **CVSS:** 7.4 (v3.1, CNA) `CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:N/I:H/A:N`
- **CVSS metrics:** Attack vector: Network; Attack complexity: Low; Privileges required: None; User interaction: Required; Scope: Changed (impact reaches other components); Confidentiality impact: None; Integrity impact: High; Availability impact: None
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Remote, no login needed
- **EPSS:** 3.55% (percentile 90, 2026-11-26)
- **CWE:** CWE-78
- **Aliases:** GHSA-qrqm-fpv6-6r8g
- **Published:** 2021-02-02T18:50:13.000Z
- **Modified:** 2026-09-10T03:48:25.998Z

## Who should check

- Projects that depend on RubyGems package mechanize (\>= 2.0.0, \< 2.7.7)
- Anyone running sparklemotion mechanize \>= 2.0, \< 2.7.7

## 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 and fixed versions

- RubyGems `mechanize`: affected \>= 2.0.0, \< 2.7.7; fixed 2.7.7 (osv)
- sparklemotion mechanize: \>= 2.0, \< 2.7.7 (cvelist)

## Mitigation

- Upgrade mechanize to 2.7.7 or later.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2021-21289. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2021-21289.md
Affected: mechanize >= 2.0.0, < 2.7.7
Fixed in: 2.7.7

Steps:
1. Search this machine and project for mechanize (RubyGems), sparklemotion mechanize: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2021-21289 being exploited?

There is no confirmed exploitation: CVE-2021-21289 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 3.55% chance of exploitation in the next 30 days (as of 2026-11-26).

### How serious is CVE-2021-21289?

High: CVSS 7.4 (v3.1, scored by CNA). Remote, no login needed. A user has to take an action, such as opening a link, for the attack to work.

### Which versions are affected by CVE-2021-21289?

mechanize \>= 2.0.0, \< 2.7.7.

### Is there a fix for CVE-2021-21289?

Yes. Fixed in 2.7.7. Upgrade mechanize to 2.7.7 or later.

### How do I check if I'm affected by CVE-2021-21289?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- vendor: <https://github.com/sparklemotion/mechanize/security/advisories/GHSA-qrqm-fpv6-6r8g>
- vendor: <https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/LBVVJUL4P4KCJH4IQTHFZ4ATXY7XXZPV/>
- vendor: <https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/YNFZ7ROYS6V4J5L5PRAJUG2AWC7VXR2V/>
- vendor: <https://security.gentoo.org/glsa/202107-17>
- vendor: <https://nvd.nist.gov/vuln/detail/CVE-2021-21289>
- patch: <https://github.com/sparklemotion/mechanize/commit/66a6a1bfa653a5f13274a396a5e5441238656aa0>
- other: <https://rubygems.org/gems/mechanize/>
- other: <https://github.com/sparklemotion/mechanize/releases/tag/v2.7.7>
- other: <https://lists.debian.org/debian-lts-announce/2021/02/msg00021.html>
- other: <https://github.com/rubysec/ruby-advisory-db/blob/master/gems/mechanize/CVE-2021-21289.yml>
- other: <https://github.com/sparklemotion/mechanize>
- other: <https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/LBVVJUL4P4KCJH4IQTHFZ4ATXY7XXZPV>
- other: <https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/YNFZ7ROYS6V4J5L5PRAJUG2AWC7VXR2V>
- other: <https://rubygems.org/gems/mechanize>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2021-21289>
- OSV: CC-BY 4.0 <https://osv.dev/vulnerability/GHSA-qrqm-fpv6-6r8g> (license: <https://creativecommons.org/licenses/by/4.0/>)

HTML: <https://flawdb.com/CVE-2021-21289> · JSON: <https://flawdb.com/api/v1/entries/CVE-2021-21289>
