CVE-2026-54603: OAuth2 Package Vulnerability Leading to Bearer Token Leakage
Summary
CVE-2026-54603: When an application uses OAuth2::Client (typically via an OAuth2::AccessToken) and the configured authorization server returns a redirect whose Location header is a protocol-relative URI of the form //attacker.example/le... Affects oauth2 versions >= 0.4.0, < 2.0.22. Fixed in 2.0.22. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
The OAuth2 package is a Ruby library that facilitates the implementation of OAuth 2.0 authentication flows in applications. It allows developers to easily manage access tokens and make authenticated requests to resource servers. However, a critical vulnerability has been identified in versions up to 2.0.21, where protocol-relative redirects can lead to unauthorized disclosure of bearer tokens.
Vulnerability Detail
The vulnerability arises from the handling of protocol-relative redirect URIs in the OAuth2::Client#request method. When an authorization server returns a redirect with a Location header formatted as a protocol-relative URI (e.g., //attacker.example/leak), the OAuth2 client incorrectly resolves this URI, replacing the authority of the base URL with that of the attacker. This results in the bearer token being sent to the attacker-controlled host without any additional user interaction, leading to potential credential leakage and server-side request forgery (SSRF). The vulnerability affects all versions of the OAuth2 package from 0.4.0 to 2.0.21.
How To Fix
Latest published version: 2.0.25 as of 23 Oct 2026
gem install oauth2 -v 2.0.25
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
2.0.22
This is the first release that contains the fix.
gem install oauth2 -v 2.0.22
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
As a temporary workaround, you can modify the OAuth2::Client#request method to handle protocol-relative locations safely. Here’s a code snippet to implement this patch:
module OAuth2 class Client
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]
verb = :get and req_opts.delete(:body) if status == 303
location = response.headers["location"]
if location
safe_location = location.start_with?("//") ? "./#{location}" : location
full_location = response.response.env.url.merge(safe_location)
request(verb, full_location, req_opts)
else
raise(Error.new(response), "Got #{status} status code, but no Location header was present")
end
end
end
end end
Conclusion
The CVE-2026-54603 vulnerability in the OAuth2 package poses a significant risk of bearer token leakage through improper handling of protocol-relative redirects. It is crucial to update to version 2.0.22 or later to safeguard your application. Additionally, utilizing the Vulert platform can help monitor and alert for such vulnerabilities in real-time.
See every vulnerability recorded for oauth2 →
FAQ
CVE-2026-54603 is a vulnerability in the OAuth2 package that allows an attacker to leak bearer tokens through protocol-relative redirects.
All versions from 0.4.0 to 2.0.21 are affected by this vulnerability.
You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.
The CVSS score of this vulnerability is 8.6, indicating a high severity level.
If you cannot update the package immediately, consider implementing the provided workaround to mitigate the risk until you can apply the official patch.
References
Related vulnerabilities
Recent vulnerabilities recorded for oauth2.