CVE-2022-31033 — Vulnerability in mechanize — CVE Details
Mechanize before v2.8.5 vulnerable to authorization header leak on port redirect
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (1.48%). Schedule for your next planned update.
Does your project use an affected mechanize version?
Paste your Gemfile.lock to check it for CVE-2022-31033 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
Summary
Mechanize (rubygem) < v2.8.5 leaks the Authorization header after a redirect to a different port on the same site.
Mitigation
Upgrade to Mechanize v2.8.5 or later.
Notes
See https://curl.se/docs/CVE-2022-27776.html for a similar vulnerability in curl.
Cookies are shared with a server at a different port on the same site, per https://datatracker.ietf.org/doc/html/rfc6265#section-8.5 which states in part:
Cookies do not provide isolation by port. If a cookie is readable by a service running on one port, the cookie is also readable by a service running on another port of the same server. If a cookie is writable by a service on one port, the cookie is also writable by a service running on another port of the same server. For this reason, servers SHOULD NOT both run mutually distrusting services on different ports of the same host and use cookies to store security- sensitive information.
Advisory Timeline
- First published June 9, 2022 (1630 days ago).
- Last revised November 8, 2023 — 516 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
gem install mechanize -v 2.8.5
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (1)
Affects 1 ecosystem: RubyGems (1).
| Package | Fixed In |
|---|---|
| mechanize RubyGems · Affected: 0.1.0, 0.1.1, 0.1.2, 0.1.3 (+79 more) | 2.8.5 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-200Information ExposureMITRE
- CWE-522
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 5.9 score means for each attack dimension.
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N
References
- https://github.com/sparklemotion/mechanize/security/advisories/GHSA-64qm-hrgp-pgr9WEB
- https://nvd.nist.gov/vuln/detail/CVE-2022-31033ADVISORY
- https://github.com/sparklemotion/mechanize/commit/c7fe6996a5b95f9880653ba3bc548a8d4ef72317WEB
- https://github.com/rubysec/ruby-advisory-db/blob/master/gems/mechanize/CVE-2022-31033.ymlWEB
- https://github.com/sparklemotion/mechanizePACKAGE
Frequently Asked Questions
- What is CVE-2022-31033?
- Mechanize before v2.8.5 vulnerable to authorization header leak on port redirect. This vulnerability has been assigned a severity rating of MEDIUM (CVSS score: 5.9/10).
- How do I check if my project is affected by CVE-2022-31033?
- CVE-2022-31033 affects mechanize. It has a 1.5% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2022-31033 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Exploitation requires specific conditions, or the impact is limited.
This is an above-median EPSS score — 74.2% of tracked vulnerabilities score at or below it, putting its exploitation likelihood in the upper half of the tracked corpus.
Also Known As
Related CVEs
- CVE-2021-21289HIGH
Command Injection Vulnerability in Mechanize
- CVE-2026-107715MEDIUM
Mechanize sends credential headers to another host after an HTTP redirect
- CVE-2026-128084MEDIUM
sqlite3-ruby: Possible SQL query truncation when a string is 4 GiB or larger
- CVE-2026-107399MEDIUM
Mechanize sends credential headers to another origin after a meta refresh
- CVE-2026-115472MEDIUM
Doorkeeper: When using public clients, any client can revoke any access token