Jul 28, 2026·7 min read·60 visits
The oauth2 Ruby gem leaks active Authorization bearer tokens to untrusted external hosts when following protocol-relative redirects (starting with //) and enables server-side request forgery.
An issue in the ruby-oauth2 gem allows unauthenticated attackers to steal OAuth access tokens or perform Server-Side Request Forgery (SSRF) via a protocol-relative URI in HTTP Location redirect headers.
The oauth2 Ruby gem is an open-source library that implements a client wrapper for the OAuth 2.0 authorization framework. It is widely integrated into Ruby on Rails and other Rack-based web applications to handle identity verification, Single Sign-On (SSO), and API resource consumption. The library interacts with Identity Providers (IdPs) and authorization servers, managing access tokens on behalf of users.
Historically, standard compliance updates introduced support for relative URI redirects within the gem's network request cycle. However, this implementation introduced a critical security flaw: during the handling of standard 3xx redirect status codes (301, 302, 303, and 307), the client fails to securely handle protocol-relative URIs received in the HTTP Location response header.
When a protocol-relative URI (one starting with double slashes, such as //attacker.example) is processed, it completely overrides the original target host and port while keeping the original request options intact. Consequently, the client recursively transmits the active bearer credential to the newly parsed host. This flaw corresponds to CWE-200 (Exposure of Sensitive Information to an Unauthorized Actor) and CWE-601 (URL Redirection to Untrusted Site), yielding a high-severity risk.
The root cause of this vulnerability lies in the unsafe interaction between HTTP redirection logic and Ruby's standard library URI merging utility (URI#merge). In the vulnerable versions of the library, the redirection handler dynamically extracts the Location header from a 3xx HTTP response. It then resolves the redirection destination by calling response.response.env.url.merge(location), where env.url represents the absolute URI of the original request.
According to the URI standard specified in RFC 3986, a string starting with two forward slashes (//) represents a network-path reference. This format inherits the active URI scheme but indicates a complete replacement of the authority component (the domain and port). When URI#merge combines the base absolute URL https://trusted-idp.example/oauth/token with the protocol-relative input //attacker-controlled.example/steal, the resolved URL evaluates directly to https://attacker-controlled.example/steal.
Furthermore, the client library recursively calls OAuth2::Client#request using the newly computed redirect target URL. Crucially, the local variable req_opts—which contains the HTTP request configurations and headers—is passed directly into the recursive call without validation or modifications. Since the original request parameters contained an Authorization header containing the user's active bearer access token, the client sends this high-privilege token to the attacker-controlled server.
To understand the flaw at the source-code level, consider the original request loop within lib/oauth2/client.rb in version 2.0.21:
def request(verb, url, req_opts = {}, &block)
response = execute_request(verb, url, req_opts, &block)
status = response.status
case status
when 301, 302, 303, 307
req_opts[:redirect_count] ||= 0
req_opts[:redirect_count] += 1
return response if req_opts[:redirect_count] > options[:max_redirects]
if status == 303
verb = :get
req_opts.delete(:body)
end
location = response.headers["location"]
if location
# Vulnerability: protocol-relative URI replaces authority component
full_location = response.response.env.url.merge(location)
# Vulnerability: req_opts passed unmodified, including Authorization headers
request(verb, full_location, req_opts)
end
end
endTo remediate this, the patched version 2.0.22 intercepts protocol-relative URIs and sanitizes the outgoing headers before initiating recursion. The fix modifies the redirect flow to call resolve_redirect_location and sanitize_redirect_options:
# The patched request execution logic
if location
current_location = response.response.env.url
# Step 1: Prevent authority hijacking by prefixing relative URLs
full_location = resolve_redirect_location(current_location, location)
# Step 2: Strip sensitive headers during cross-origin shifts
request(verb, full_location, sanitize_redirect_options(req_opts, current_location, full_location))
endAdditionally, the patch implements three helper methods to enforce boundary limits. The resolve_redirect_location helper checks if the target location string starts with //. If so, it prepends ./ to neutralize the authority replacement, converting the string into a relative-path component on the same origin. The sanitize_redirect_options helper checks if a cross-origin redirect occurred using cross_origin_redirect? and purges any keys matching Authorization (case-insensitively) from the request options hash.
An attacker can exploit this vulnerability through multiple vectors, provided they can influence the destination of an HTTP request executed by the victim application's OAuth client. In a standard enterprise scenario, an attacker identifies an Open Redirect vulnerability on the target Identity Provider (IdP) server. During authentication, the OAuth client calls a token exchange or user-profile endpoint, and the compromised or open-redirecting IdP responds with an HTTP 302 containing Location: //attacker.example/log.
Alternatively, in multi-tenant SaaS environments, tenant administrators can configure custom OIDC metadata endpoints. An attacker can set up a rogue IdP and configure the application to use it as the trusted OAuth authority. When the application's backend queries the malicious metadata or token endpoint, the rogue server returns a protocol-relative redirect targeting the administrative API or internal network addresses.
Below is a sequence diagram illustrating the transaction and subsequent credential disclosure:
Because the browser is not involved in back-channel API calls, no user interaction is required to trigger the final request. Once the server-side application resolves the redirect, the bearer token is sent directly to the adversary-controlled web server. The attacker-controlled server parses the incoming Authorization header and logs the stolen token for persistent API access.
The impact of CVE-2026-54603 is significant, representing a high-probability vector for complete credential compromise. The exposure of active access tokens allows attackers to bypass multi-factor authentication (MFA) and access control lists, enabling unauthorized data access or session hijacking on downstream systems. This behavior results in a CVSS v3.1 score of 8.6, emphasizing the critical nature of the flaw.
In addition to credential theft, this vulnerability represents a Server-Side Request Forgery (SSRF) hazard. If an attacker controls the endpoint or redirects the outbound connection, they can force the application server to make arbitrary requests to local network interfaces, metadata endpoints, or database APIs. Because the target URI undergoes standard resolution, local system paths (e.g., //127.0.0.1 or //169.254.169.254) can be accessed blindly through the redirection loop.
The scope of the vulnerability is further broadened by its presence in all versions of the oauth2 library ranging from 0.4.0 to 2.0.21, representing years of production releases. Due to the gem's widespread use as a foundational dependency in OmniAuth strategies and enterprise single-sign-on systems, the potential attack surface spans thousands of internet-exposed applications.
The recommended remediation path is to upgrade the oauth2 dependency to version 2.0.22 or later. This release enforces validation rules that block relative-authority hijacking and strip authentication headers during cross-origin transitions. Teams should inspect their dependency trees via Gemfile.lock to ensure all transitive dependencies (e.g., specific OmniAuth provider plugins) inherit the patched version.
When direct upgrades are blocked by legacy environment dependencies, a monkey-patch must be loaded during the application bootstrap process. This patch overrides the request loop in OAuth2::Client to manually intercept // relative redirects and purge the Authorization header when a cross-origin boundary is traversed. Applying structural monkey-patches provides immediate defense-in-depth without modifying base infrastructure.
Additionally, network-level and application-level controls should be configured to restrict outbound HTTP requests originating from backend application servers. Restricting server egress connections to designated Identity Providers using firewall egress policies prevents connections to unknown domains. Developers should also verify that Identity Provider endpoint configurations are read-only and cannot be manipulated by untrusted administrative accounts.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N| Product | Affected Versions | Fixed Version |
|---|---|---|
oauth2 ruby-oauth | >= 0.4.0, <= 2.0.21 | 2.0.22 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-200, CWE-601 |
| Attack Vector | Network (AV:N) |
| CVSS v3.1 Score | 8.6 (High) |
| EPSS Score | Not Available |
| Impact | High (Credential Disclosure / SSRF) |
| Exploit Status | Proof-of-Concept |
| KEV Status | Not Listed |
The product exposes sensitive information to an actor who is not authorized to have access to that information.
CVE-2026-12411 is a broken access control vulnerability in the DevLXD interface of Canonical LXD versions 6.6 through 6.8. The flaw resides in the devLXDInstancePatchHandler component, which fails to verify storage volume ownership when an instance attaches a new disk device via the /dev/lxd guest socket. When the security.devlxd.management.volumes configuration option is enabled, an untrusted guest or DevLXD identity can issue a crafted HTTP PATCH request referencing another tenant's custom storage volume. The LXD host daemon subsequently mounts the target volume into the requesting guest, permitting unauthorized cross-tenant read and write operations.
CVE-2026-105769 (GHSA-5q7h-w9jf-cx97, GO-2026-6225) is an origin validation error and credential exfiltration vulnerability affecting Kaniko prior to version 1.25.20. The flaw stems from an unanchored regular expression in the integrated Azure Container Registry (ACR) credential helper (github.com/chrismellard/docker-credential-acr-env). When Kaniko processes a Dockerfile containing an image reference hosted on a lookalike domain containing an ACR suffix as a substring (e.g., x.azurecr.io.attacker.com), the credential helper acquires a Microsoft Entra ID access token for Azure Resource Manager and transmits it via HTTP POST to the attacker-controlled host.
CVE-2026-62300 is an uncontrolled resource consumption vulnerability (CWE-400) affecting the daemon mode of filecoin-pin in versions up to and including 1.1.0. The daemon implements the IPFS Pinning Service API to store content on Filecoin's Proof of Data Possession (PDP) service. Due to the absence of rate limits, concurrency caps, execution timeouts, and Directed Acyclic Graph (DAG) traversal limits, an authenticated user—or an unauthenticated user when authentication is disabled—can exhaust system resources via crafted POST /pins requests.
CVE-2026-61536 is a high-severity Remote Code Execution (RCE) vulnerability in the masci/banks Python library prior to version 2.4.3. The flaw exists within the CompletionExtension component, which parses JSON-serialized Tool definitions directly from rendered Jinja template bodies inside {% completion %} blocks. When handling tool calls returned by an LLM, the library dynamically resolves the target callable using importlib.import_module() and getattr() based on an unvalidated import_path string. An attacker who can supply or modify prompt templates can inject a malicious Tool JSON object pointing to arbitrary Python functions (such as os.system), bypassing the Jinja SandboxedEnvironment introduced in version 2.4.2 and achieving arbitrary code execution when the LLM invokes the tool.
Payload CMS contains a missing authorization vulnerability (CWE-862) in its client-side upload instructions endpoint and the `@payloadcms/storage-vercel-blob` storage adapter. Two distinct logic defects allow authenticated users lacking collection-level `create` or `update` permissions to generate signed upload tokens and upload arbitrary files directly to external cloud storage.
CVE-2026-55098 (GHSA-93cm-2v4m-c56c) is an authorization bypass and sensitive information disclosure vulnerability in Basekick-Labs Arc prior to version 26.06.2. The flaw stems from an incomplete remediation of CVE-2026-47735, which failed to restrict the full suite of DuckDB table-valued filesystem I/O functions and quoted-identifier invocations. Because Arc's query parser ignores function calls during table reference extraction, authenticated users with minimal or empty permissions can invoke functions like parquet_scan(), glob(), and read_blob() to read, enumerate, and extract telemetry data across all tenant databases residing within the shared local storage root.