CVE-2022-31033: Mechanize Mechanize Before V2.8.5 Vulnerable To Vulnerability

MODERATE
Advisory Identifier: GHSA-64qm-hrgp-pgr9
CVSS 5.9
CWE-522 CWE-200
Published
Advisory Summary

CVE-2022-31033 is a MODERATE (CVSS 5.9) mechanize before v2.8.5 vulnerable to vulnerability (CWE-522: Insufficiently Protected Credentials) affecting Mechanize libraries in the RubyGems ecosystem. The issue involves mechanize before v2.8.5 vulnerable to authorization header leak on port redirect. Remediation is available by upgrading affected packages to version 2.8.5.

CVE-2022-31033 at a Glance

CVE Identifier CVE-2022-31033
GHSA Identifier GHSA-64qm-hrgp-pgr9
Severity MODERATE
CVSS v3.1 Base Score 5.9
CWE Classification CWE-522: Insufficiently Protected Credentials
Affected Product Mechanize
Package Ecosystem RubyGems
Published Date
Last Updated

Security Impact

CVSS: 5.9

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2022-31033

To remediate this vulnerability, upgrade all affected Mechanize dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

mechanize fixed: 2.8.5
Upgrade mechanize to 2.8.5
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for mechanize

How to Check if You Are Affected

To determine whether your application is affected by CVE-2022-31033, inspect your project dependencies for Mechanize:

inspect dependencies for mechanize

Analyze the terminal output to locate any version of Mechanize in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.8.5), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-522: Insufficiently Protected Credentials, where the product transmits or stores authentication credentials, but it uses an insecure method that is susceptible to unauthorized interception and/or retrieval. In Mechanize, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

**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](CVE-2022-27776) 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.

CVE-2022-31033 Affected Mechanize Versions

1 component(s)
Fixed Versions:
2.8.5
Product / Package Ecosystem Affected Versions Fixed Version
mechanize
RubyGems
< 2.8.5
2.8.5

References

Frequently Asked Questions

What is CVE-2022-31033?
CVE-2022-31033 is a security vulnerability in Mechanize involving Mechanize before v2.8.5 vulnerable to authorization header leak on port redirect under CWE-522: Insufficiently Protected Credentials.
Which Mechanize versions are affected?
Affected versions include releases prior to 2.8.5 across affected packages: mechanize.
What version fixes CVE-2022-31033?
Upgrading to 2.8.5 (or the latest patched release for your respective branch) resolves the vulnerability.
Is mechanize affected?
Yes, mechanize is affected in releases prior to 2.8.5. Upgrade your dependency to 2.8.5 or later.
What is the CVSS score of CVE-2022-31033?
CVE-2022-31033 has a CVSS v3.1 base score of 5.9 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N.
What CWE is associated with CVE-2022-31033?
CVE-2022-31033 is classified under CWE-522: Insufficiently Protected Credentials (The product transmits or stores authentication credentials, but it uses an insecure method that is susceptible to unauthorized interception and/or retrieval.).
How can I check RubyGems dependencies for CVE-2022-31033?
Run the dependency tree command: 'inspect dependencies for mechanize'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-64qm-hrgp-pgr9",
  "modified" : "2022-07-21T14:53:46Z",
  "published" : "2022-06-09T23:47:57Z",
  "aliases" : [ "CVE-2022-31033" ],
  "summary" : "Mechanize before v2.8.5 vulnerable to authorization header leak on port redirect",
  "details" : "**Summary**\n\nMechanize (rubygem) `< v2.8.5` leaks the `Authorization` header after a redirect to a different port on the same site.\n\n**Mitigation**\n\nUpgrade to Mechanize v2.8.5 or later.\n\n**Notes**\n\nSee [https://curl.se/docs/CVE-2022-27776.html](CVE-2022-27776) for a similar vulnerability in curl.\n\nCookies 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:\n\n> Cookies do not provide isolation by port.  If a cookie is readable\n> by a service running on one port, the cookie is also readable by a\n> service running on another port of the same server.  If a cookie is\n> writable by a service on one port, the cookie is also writable by a\n> service running on another port of the same server.  For this\n> reason, servers SHOULD NOT both run mutually distrusting services on\n> different ports of the same host and use cookies to store security-\n> sensitive information.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "mechanize"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.8.5"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/sparklemotion/mechanize/security/advisories/GHSA-64qm-hrgp-pgr9"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-31033"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sparklemotion/mechanize/commit/c7fe6996a5b95f9880653ba3bc548a8d4ef72317"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/mechanize/CVE-2022-31033.yml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/sparklemotion/mechanize"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-200", "CWE-522" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-06-09T23:47:57Z",
    "nvd_published_at" : "2022-06-09T20:15:00Z"
  }
}