MediumGHSA-64qm-hrgp-pgr9CVE-2022-31033

Mechanize before v2.8.5 vulnerable to authorization header leak on port redirect

Published 9 Jun 2022 · Updated 8 Nov 2023

Is your project on an affected mechanize?

Private repo? Upload its lockfile instead, or connect GitHub to check every repo.

Look after several Rails or Ruby apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie

Affected package

mechanizeRubyGems
Affected
<2.8.5
Fixed in
2.8.5
Update to the fixed version for your release line, for example:bundle update --conservative mechanize # Gemfile: '>= 2.8.5'

Details

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.

Is GHSA-64qm-hrgp-pgr9 in any of your client repos?

Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected mechanize, and gives you the command that fixes it.

More advisories for mechanize

  • MediumCVE-2026-107399Mechanize sends credential headers to another origin after a meta refresh · 8 Oct 2026
  • MediumCVE-2026-107715Mechanize sends credential headers to another host after an HTTP redirect · 8 Oct 2026
  • HighCVE-2021-21289Command Injection Vulnerability in Mechanize · 2 Feb 2021
mechanize security overview

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.