CVE-2026-107715: Mechanize Mechanize Sends Credential Headers To Vulnerability

MODERATE
Advisory Identifier: GHSA-2mwr-xjcg-37j7
CVSS 6.8
CWE-522 CWE-200
Published
Advisory Summary

CVE-2026-107715 is a MODERATE (CVSS 6.8) mechanize sends credential headers to vulnerability (CWE-522: Insufficiently Protected Credentials) affecting Mechanize libraries in the RubyGems ecosystem. The issue involves mechanize sends credential headers to another host after an http redirect. Remediation is available by upgrading affected packages to version 2.14.1.

CVE-2026-107715 at a Glance

CVE Identifier CVE-2026-107715
GHSA Identifier GHSA-2mwr-xjcg-37j7
Severity MODERATE
CVSS v3.1 Base Score 6.8
CWE Classification CWE-522: Insufficiently Protected Credentials
Affected Product Mechanize
Package Ecosystem RubyGems
Published Date
Last Updated

Security Impact

CVSS: 6.8

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:C/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 Changed (S:C)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2026-107715

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.14.1
Upgrade mechanize to 2.14.1
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-2026-107715, 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.14.1), 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` leaked credentials to the redirect target when an HTTP redirect crossed to another host. Credentials set through `Mechanize#request_headers=` leaked even when they were `Authorization`. ## Details Two defects, both in `lib/mechanize/http/agent.rb`. **1. `Mechanize#request_headers=` bypassed the redirect strip entirely.** `#request_add_headers` copied `@request_headers` onto every request unconditionally, with no host check, including the request issued after a redirect. The strip in `#response_redirect` mutated only the per-request headers hash and never touched agent state. Because `request_headers=` is the documented way to set a default credential for every request, the header the code explicitly protected — `Authorization` — was the one most likely to leak. **2. The strip list omitted `Proxy-Authorization` and `Cookie2`.** Only `CREDENTIAL_HEADERS = ['Authorization']` and `COOKIE_HEADERS = ['Cookie']` were removed from the per-request headers hash on a cross-host redirect. Cookies held in `Mechanize#cookie_jar` and credentials held in `Mechanize::HTTP::AuthStore` are **not** affected. Both are looked up per-URI, so they never follow a redirect to a foreign host. The exposure was limited to headers the caller set by hand. ## PoC ```ruby agent = Mechanize.new agent.request_headers = { 'Authorization' => 'Bearer secret' } agent.get('https://example.test/redirects-to-attacker') # the request to the attacker's host carries "Authorization: Bearer secret" ``` ## Impact An attacker who controls a redirect target — through an open redirect on the site being fetched, an attacker-supplied fetch URL, DNS rebinding, or MITM — captures bearer tokens and session cookies from any `mechanize` agent that sets credentials through `request_headers=` or the per-request `headers` argument. Disclosure only; no integrity or availability impact. ## Patches Fixed in `mechanize` v2.14.1. - Credentials and cookies are withheld from a request that follows a redirect across an origin, from **both** header sources: the per-request `headers` argument and `Mechanize#request_headers=`. - `CREDENTIAL_HEADERS` gains `Proxy-Authorization`; `COOKIE_HEADERS` gains `Cookie2`. `Proxy-Authorization` is withheld here although curl does not withhold it, because `Net::HTTP` tunnels `https:` requests with `CONNECT`, so a caller-supplied `Proxy-Authorization` travels inside the tunnel to the origin server rather than to the proxy. Headers set through `Mechanize#request_headers=` no longer reach a redirect target on another origin when they are credentials. Callers that relied on the previous behavior will see those headers withheld. ### What this fix does not cover Only the headers in `CREDENTIAL_HEADERS` and `COOKIE_HEADERS` are withheld. A caller-supplied header that carries a credential under some other name — `X-API-Key`, `X-Vault-Token`, or any bespoke token header — still follows a redirect to another origin, matching the behavior of curl's `CURLOPT_HTTPHEADER`. If you set such a header, do not enable redirect following for requests that carry it, or scope it to a single request whose destination you control. ## Workarounds Set `Mechanize#redirect_ok = false` and handle redirects explicitly, or avoid `request_headers=` for credentials and pass them per-request only to hosts you intend to authenticate to. ## Credit Reported by @SnailSploit.

CVE-2026-107715 Affected Mechanize Versions

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

References

Frequently Asked Questions

What is CVE-2026-107715?
CVE-2026-107715 is a security vulnerability in Mechanize involving Mechanize sends credential headers to another host after an HTTP redirect under CWE-522: Insufficiently Protected Credentials.
Which Mechanize versions are affected?
Affected versions include releases prior to 2.14.1 across affected packages: mechanize.
What version fixes CVE-2026-107715?
Upgrading to 2.14.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is mechanize affected?
Yes, mechanize is affected in releases prior to 2.14.1. Upgrade your dependency to 2.14.1 or later.
What is the CVSS score of CVE-2026-107715?
CVE-2026-107715 has a CVSS v3.1 base score of 6.8 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:N/A:N.
What CWE is associated with CVE-2026-107715?
CVE-2026-107715 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-2026-107715?
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-2mwr-xjcg-37j7",
  "modified" : "2026-10-08T22:09:00Z",
  "published" : "2026-10-08T22:09:00Z",
  "aliases" : [ "CVE-2026-107715" ],
  "summary" : "Mechanize sends credential headers to another host after an HTTP redirect",
  "details" : "## Summary\n\n`mechanize` leaked credentials to the redirect target when an HTTP redirect crossed to another host. Credentials set through `Mechanize#request_headers=` leaked even when they were `Authorization`.\n\n## Details\n\nTwo defects, both in `lib/mechanize/http/agent.rb`.\n\n**1. `Mechanize#request_headers=` bypassed the redirect strip entirely.** `#request_add_headers` copied `@request_headers` onto every request unconditionally, with no host check, including the request issued after a redirect. The strip in `#response_redirect` mutated only the per-request headers hash and never touched agent state. Because `request_headers=` is the documented way to set a default credential for every request, the header the code explicitly protected — `Authorization` — was the one most likely to leak.\n\n**2. The strip list omitted `Proxy-Authorization` and `Cookie2`.** Only `CREDENTIAL_HEADERS = ['Authorization']` and `COOKIE_HEADERS = ['Cookie']` were removed from the per-request headers hash on a cross-host redirect.\n\nCookies held in `Mechanize#cookie_jar` and credentials held in `Mechanize::HTTP::AuthStore` are **not** affected. Both are looked up per-URI, so they never follow a redirect to a foreign host. The exposure was limited to headers the caller set by hand.\n\n## PoC\n\n```ruby\nagent = Mechanize.new\nagent.request_headers = { 'Authorization' => 'Bearer secret' }\nagent.get('https://example.test/redirects-to-attacker')\n# the request to the attacker's host carries \"Authorization: Bearer secret\"\n```\n\n## Impact\n\nAn attacker who controls a redirect target — through an open redirect on the site being fetched, an attacker-supplied fetch URL, DNS rebinding, or MITM — captures bearer tokens and session cookies from any `mechanize` agent that sets credentials through `request_headers=` or the per-request `headers` argument. Disclosure only; no integrity or availability impact.\n\n## Patches\n\nFixed in `mechanize` v2.14.1.\n\n- Credentials and cookies are withheld from a request that follows a redirect across an origin, from **both** header sources: the per-request `headers` argument and `Mechanize#request_headers=`.\n- `CREDENTIAL_HEADERS` gains `Proxy-Authorization`; `COOKIE_HEADERS` gains `Cookie2`.\n\n`Proxy-Authorization` is withheld here although curl does not withhold it, because `Net::HTTP` tunnels `https:` requests with `CONNECT`, so a caller-supplied `Proxy-Authorization` travels inside the tunnel to the origin server rather than to the proxy.\n\nHeaders set through `Mechanize#request_headers=` no longer reach a redirect target on another origin when they are credentials. Callers that relied on the previous behavior will see those headers withheld.\n\n### What this fix does not cover\n\nOnly the headers in `CREDENTIAL_HEADERS` and `COOKIE_HEADERS` are withheld. A caller-supplied header that carries a credential under some other name — `X-API-Key`, `X-Vault-Token`, or any bespoke token header — still follows a redirect to another origin, matching the behavior of curl's `CURLOPT_HTTPHEADER`. If you set such a header, do not enable redirect following for requests that carry it, or scope it to a single request whose destination you control.\n\n## Workarounds\n\nSet `Mechanize#redirect_ok = false` and handle redirects explicitly, or avoid `request_headers=` for credentials and pass them per-request only to hosts you intend to authenticate to.\n\n## Credit\n\nReported by @SnailSploit.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "mechanize"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.14.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/sparklemotion/mechanize/security/advisories/GHSA-2mwr-xjcg-37j7"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sparklemotion/mechanize/pull/676"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sparklemotion/mechanize/commit/02a1235842d6eda8d4a5a3d8f13aba2cecf52e4f"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sparklemotion/mechanize/commit/94e0902867296be804f36eccbb47acf7d5018745"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sparklemotion/mechanize/commit/ac49abf2869297d83c3b11bbfb8b18e63b588c95"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/sparklemotion/mechanize"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sparklemotion/mechanize/releases/tag/v2.14.1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-200", "CWE-522" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-10-08T22:09:00Z",
    "nvd_published_at" : null
  }
}