<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Oauth2 (&gt;= 0.4.0, &lt;= 2.0.21) - CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/products/oauth2--0.4.0--2.0.21/</link><description>Trending threats, MITRE ATT&amp;CK coverage, and detection metadata. Fed continuously.</description><generator>Hugo</generator><language>en</language><managingEditor>hello@craftedsignal.io</managingEditor><webMaster>hello@craftedsignal.io</webMaster><lastBuildDate>Tue, 28 Jul 2026 16:33:59 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/products/oauth2--0.4.0--2.0.21/feed.xml" rel="self" type="application/rss+xml"/><item><title>OAuth2::Client Redirection Vulnerability Leaks Bearer Tokens</title><link>https://feed.craftedsignal.io/briefs/2026-07-oauth2-client-redirect-leak/</link><pubDate>Tue, 28 Jul 2026 16:33:59 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2026-07-oauth2-client-redirect-leak/</guid><description>The `OAuth2::Client` in the `oauth2` Ruby gem is vulnerable to credential disclosure and Server-Side Request Forgery (SSRF) due to improper handling of protocol-relative redirect URLs, allowing an attacker to steal bearer tokens and access internal network resources.</description><content:encoded><![CDATA[<p>A critical vulnerability (CVE-2026-54603) exists in the <code>OAuth2::Client</code> component of the <code>oauth2</code> Ruby gem, affecting versions from 0.4.0 up to and including 2.0.21. This flaw stems from improper resolution of protocol-relative redirect URIs within the <code>OAuth2::Client#request</code> method. When an OAuth2 application makes a request and its configured Identity Provider (IdP) or an open-redirect vulnerability can be influenced to return a 30x redirect with a <code>Location</code> header such as <code>//attacker.example/leak</code>, the <code>OAuth2::Client</code> incorrectly merges this URI. As a result, the subsequent request, including the <code>Authorization: Bearer &lt;access-token&gt;</code> header, is redirected to the attacker-controlled host instead of remaining with the trusted IdP. This vulnerability leads to both cross-origin credential disclosure and potential Server-Side Request Forgery (SSRF) from the application server, allowing attackers to steal sensitive tokens and probe internal networks.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>An application, using <code>OAuth2::AccessToken</code> via <code>OAuth2::Client</code>, initiates a request to a trusted Identity Provider (IdP) or resource server, including an <code>Authorization: Bearer &lt;access-token&gt;</code> header.</li>
<li>An attacker, by exploiting an open redirect vulnerability on the IdP, configuring a malicious tenant in a multi-tenant setup, or through a network compromise, causes the IdP to issue an HTTP 30x redirect response.</li>
<li>The crafted redirect response's <code>Location</code> header contains a protocol-relative URI pointing to an attacker-controlled host (e.g., <code>//attacker.example/leak</code>).</li>
<li>The <code>OAuth2::Client#request</code> method attempts to resolve this redirect by calling <code>response.response.env.url.merge(location)</code>. Per RFC 3986 §5.2, <code>URI#merge</code> interprets the protocol-relative URI as a network-path reference, which overrides the authority (scheme and host) of the base URL.</li>
<li>The library then recursively re-invokes <code>request(verb, full_location, req_opts)</code> using the newly resolved attacker-controlled URL. Crucially, the <code>req_opts</code> dictionary, containing the original request headers, is passed verbatim.</li>
<li>The <code>Authorization: Bearer &lt;access-token&gt;</code> header, initially set by <code>OAuth2::AccessToken#configure_authentication!</code>, is preserved and transmitted in the request to the attacker's host.</li>
<li>The attacker-controlled server receives the application's bearer token, achieving immediate cross-origin credential disclosure without further user interaction.</li>
<li>Alternatively, if the <code>Location</code> URI specifies an internal network address (e.g., <code>//169.254.169.254/</code>), the application server acts as a Server-Side Request Forgery (SSRF) proxy, allowing the attacker to interact with internal resources.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation of this vulnerability results in two primary impacts:</p>
<ol>
<li><strong>Cross-origin credential disclosure:</strong> The immediate consequence is the theft of <code>Authorization: Bearer</code> tokens. Any application utilizing the vulnerable <code>oauth2</code> gem to communicate with an IdP susceptible to such redirection risks having its access tokens exfiltrated to an attacker-controlled server. This can lead to unauthorized access to user data or resources that the stolen token grants access to.</li>
<li><strong>Server-Side Request Forgery (SSRF):</strong> The ability to redirect the application's requests to an arbitrary host also enables SSRF. Attackers can leverage this to force the application server to make requests to internal network services, cloud metadata endpoints (e.g., <code>169.254.169.254</code>), or other restricted resources that are typically inaccessible from the internet. This could facilitate reconnaissance, lateral movement, or further exploitation within an organization's internal infrastructure. Given the widespread use of OAuth2 in modern applications, the potential number of affected services and organizations is substantial across all sectors.</li>
</ol>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Upgrade the <code>oauth2</code> gem to version <code>2.0.22</code> or later immediately to address CVE-2026-54603.</li>
<li>Apply the suggested patch logic to <code>OAuth2::Client#request</code> as an interim measure if immediate gem upgrade is not possible. This involves forcing protocol-relative <code>Location</code> values to be interpreted as relative paths by prepending <code>./</code> before <code>URI#merge</code>.</li>
<li>Developers should review their Identity Provider (IdP) and resource server configurations to ensure they do not expose open redirect vulnerabilities that could be abused to supply malicious <code>Location</code> headers.</li>
<li>Implement defense-in-depth measures to strip credential-bearing headers (like <code>Authorization</code>) from requests when a redirect crosses origin boundaries, similar to how robust HTTP clients handle such scenarios.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>oauth2</category><category>ruby</category><category>vulnerability</category><category>credential-disclosure</category><category>ssrf</category><category>redirect</category><category>ghsa</category></item></channel></rss>