{"schema":"threatline.record/2","record":{"id":"CVE-2026-107715","aliases":["GHSA-2mwr-xjcg-37j7"],"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.","categories":["Libraries & packages"],"product":"mechanize","vendor":"sparklemotion","ecosystem":"rubygems","affected_ranges":[{"source":"GitHub Advisory Database","source_url":"https://github.com/advisories/GHSA-2mwr-xjcg-37j7","source_modified_at":"2026-10-08T22:09:01Z","fetched_at":"2026-10-23T18:42:43.628194Z","package":{"ecosystem":"rubygems","name":"mechanize"},"range":"< 2.14.1"},{"source":"CVE List","source_url":"https://www.cve.org/CVERecord?id=CVE-2026-107715","source_modified_at":"2026-10-09T13:22:27.174Z","fetched_at":"2026-10-23T18:45:31.882637Z","product":"mechanize","vendor":"sparklemotion","versions":[{"version":"< 2.15.0","status":"affected"}],"defaultStatus":null},{"source":"OSV","source_url":"https://osv.dev/vulnerability/GHSA-2mwr-xjcg-37j7","source_modified_at":"2026-10-08T22:15:07.251994937Z","fetched_at":"2026-10-23T18:42:43.628194Z","package":{"ecosystem":"RubyGems","name":"mechanize","purl":"pkg:gem/mechanize"},"ranges":[{"events":[{"introduced":"0"},{"fixed":"2.14.1"}],"type":"ECOSYSTEM"}],"versions":["0.1.0","0.1.1","0.1.2","0.1.3","0.2.0","0.2.1","0.2.2","0.2.3","0.3.0","0.3.1","0.4.0","0.4.1","0.4.2","0.4.3","0.4.4","0.4.5","0.4.6","0.4.7","0.5.0","0.5.1","0.5.2","0.5.3","0.5.4","0.6.0","0.6.1","0.6.10","0.6.11","0.6.2","0.6.3","0.6.4","0.6.5","0.6.6","0.6.7","0.6.8","0.6.9","0.7.0","0.7.1","0.7.2","0.7.3","0.7.4","0.7.5","0.7.6","0.7.7","0.7.8","0.8.0","0.8.1","0.8.2","0.8.3","0.8.4","0.8.5"]}],"fixed_versions":[{"source":"GitHub Advisory Database","source_url":"https://github.com/advisories/GHSA-2mwr-xjcg-37j7","source_modified_at":"2026-10-08T22:09:01Z","fetched_at":"2026-10-23T18:42:43.628194Z","package":{"ecosystem":"rubygems","name":"mechanize"},"version":"2.14.1"},{"source":"OSV","source_url":"https://osv.dev/vulnerability/GHSA-2mwr-xjcg-37j7","source_modified_at":"2026-10-08T22:15:07.251994937Z","fetched_at":"2026-10-23T18:42:43.628194Z","package":{"ecosystem":"RubyGems","name":"mechanize","purl":"pkg:gem/mechanize"},"version":"2.14.1"}],"cvss":6.8,"severity":"Medium","kev":{"listed":false},"epss":{"probability":0.00395,"percentile":0.32509,"score_date":"2026-10-23"},"published_at":"2026-10-08T21:27:24.651Z","modified_at":"2026-10-09T13:22:27.174Z","provenance":[{"source":"GitHub Advisory Database","url":"https://github.com/advisories/GHSA-2mwr-xjcg-37j7","fetched_at":"2026-10-23T18:42:43.628194Z","source_modified_at":"2026-10-08T22:09:01Z"},{"source":"CVE List","url":"https://www.cve.org/CVERecord?id=CVE-2026-107715","fetched_at":"2026-10-23T18:45:31.882637Z","source_modified_at":"2026-10-09T13:22:27.174Z"},{"source":"OSV","url":"https://osv.dev/vulnerability/GHSA-2mwr-xjcg-37j7","fetched_at":"2026-10-23T18:42:43.628194Z","source_modified_at":"2026-10-08T22:15:07.251994937Z"},{"source":"EPSS","url":"https://api.first.org/data/v1/epss?cve=CVE-2026-107715","fetched_at":"2026-10-23T18:42:43.628194Z","source_modified_at":"2026-10-23"}],"sources":["GitHub Advisory Database","CVE List","OSV","EPSS"],"references":[{"source":"CVE List","url":"https://github.com/sparklemotion/mechanize/security/advisories/GHSA-2mwr-xjcg-37j7","tags":["exploit"]},{"source":"CVE List","url":"https://github.com/sparklemotion/mechanize/pull/676","tags":["x_refsource_MISC"]},{"source":"CVE List","url":"https://github.com/sparklemotion/mechanize/commit/02a1235842d6eda8d4a5a3d8f13aba2cecf52e4f","tags":["x_refsource_MISC"]},{"source":"CVE List","url":"https://github.com/sparklemotion/mechanize/commit/94e0902867296be804f36eccbb47acf7d5018745","tags":["x_refsource_MISC"]},{"source":"CVE List","url":"https://github.com/sparklemotion/mechanize/commit/ac49abf2869297d83c3b11bbfb8b18e63b588c95","tags":["x_refsource_MISC"]},{"source":"CVE List","url":"https://github.com/sparklemotion/mechanize/releases/tag/v2.14.1","tags":["x_refsource_MISC"]},{"url":"https://github.com/advisories/GHSA-2mwr-xjcg-37j7","source":"GitHub Advisory Database"}],"locations":[],"motoko_assessment":{"status":"requires_architecture_review","automatic_remediation":false},"cve_state":"PUBLISHED","ssvc":{"exploitation":"poc","automatable":"no","technical_impact":"partial","assessed_at":"2026-10-09T13:22:03.491703Z"},"classification":{"method":"product-first software-layer rules","rules_version":"2.1","matched_on":"ecosystem","confidence":"heuristic","reviewed":false},"change_timestamp":"2026-10-09T13:22:27.174Z","content_hash":"491825527780813f5c51914ba7d0109227f391dda72217a29764cb461dd7bca0"}}
