CVE-2026-54603: OAuth2 Package Vulnerability Leading to Bearer Token Leakage

oauth2 Updated 28 Jul 2026

Summary

28/07/2026
Yes i
High
8.6

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 ↓

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

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 →

Share this vulnerability

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.

Related vulnerabilities

Recent vulnerabilities recorded for oauth2.

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 →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback