Authentication Credential Leakage in URI Gem for Ruby

ruby2.7 Updated 02 Oct 2025

Summary

04/03/2025
N/A
Yes i
Medium
5.3

CVE-2025-27221: In the URI gem before 1.0.3 for Ruby, the URI handling methods (URI.join, URI#merge, URI#+) have an inadvertent leakage of authentication credentials because userinfo is retained even after changing the host. Affects ruby2.7 across 2 version ranges.

< 2.7.4-1+deb11u5 < c13dfc2164bc4af31085e709ab348fdbd527013f

Fixed in 2.7.4-1+deb11u5. 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 URI gem is a crucial component of Ruby, providing methods for handling Uniform Resource Identifiers (URIs). It allows developers to construct, parse, and manipulate URIs effectively. However, prior to version 1.0.3, the gem exhibited a significant vulnerability that could lead to the unintended exposure of authentication credentials, particularly when changing hosts.

Vulnerability Detail

In the URI gem versions before 1.0.3, methods such as URI.join, URI#merge, and URI#+ inadvertently retained user authentication information even after the host was modified. This flaw could allow malicious actors to exploit the retained credentials, leading to unauthorized access and potential data breaches. The vulnerability stems from improper handling of userinfo in the URI processing methods, which fails to clear sensitive information when the host changes.

How To Fix

Minimum fixed version

2.7.4-1+deb11u5

This is the first release that contains the fix.

sudo apt-get install --only-upgrade ruby2.7

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, avoid using the affected methods (URI.join, URI#merge, URI#+) until you can update to the patched version. Instead, manually handle URI construction and merging without relying on these methods to prevent accidental leakage of authentication credentials.

Conclusion

The URI gem vulnerability (CVE-2025-27221) poses a significant risk by leaking authentication credentials due to improper handling of userinfo. It is crucial to update to version 1.0.3 or later to safeguard your application. Implementing workarounds and utilizing tools like Vulert can further enhance your security posture.

See every vulnerability recorded for ruby2.7 →

Share this vulnerability

FAQ

The URI gem is a Ruby library that provides functionality for parsing and manipulating Uniform Resource Identifiers (URIs).

If your application uses the affected methods in the URI gem, it may unintentionally expose authentication credentials, leading to security risks.

If an immediate update is not possible, avoid using the vulnerable methods and implement manual URI handling as a temporary measure.

You can find detailed information about this vulnerability on the official CVE database or security advisories related to the URI gem.

Vulert allows you to monitor and alert for open-source vulnerabilities in your software using just a manifest file like package-lock.json, providing real-time insights without requiring code access.

Related vulnerabilities

Recent vulnerabilities recorded for ruby2.7.

How To Fix

Minimum fixed version

2.7.4-1+deb11u5

This is the first release that contains the fix.

sudo apt-get install --only-upgrade ruby2.7

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