Fix/CVE 2025 61594 uri credential leakage#99
Open
224599437 wants to merge 2 commits intothoth-tech:10.0.xfrom
Open
Fix/CVE 2025 61594 uri credential leakage#99224599437 wants to merge 2 commits intothoth-tech:10.0.xfrom
224599437 wants to merge 2 commits intothoth-tech:10.0.xfrom
Conversation
Replace wildcard CORS behavior with whitelist validation and restrict allowed headers/methods so only trusted frontend origins can make cross-origin API requests. Made-with: Cursor
Upgrade the uri gem and add a runtime guard that strips URI credentials when combining a credential-bearing base with relative paths to prevent CVE-2025-61594 style leakage in API runtime flows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR remediates URI credential leakage behavior associated with CVE-2025-61594 in doubtfire-api.
Summary of changes
Updated dependency constraint in Gemfile to gem 'uri', '>= 1.1.1'.
Updated Gemfile.lock to resolve uri to 1.1.1.
Added runtime hardening initializer at config/initializers/uri_credential_leak_mitigation.rb:
Intercepts URI#+ merges.
When a credential-bearing base URI is combined with a relative URI, strips user and password from the resulting URI.
Prevents credential propagation into constructed URLs.
Motivation / context
Pentest PoC confirmed credential-bearing userinfo could persist in merged URIs and be exposed in downstream flows (logs, redirects, API/service requests).
Although user login credentials are not directly impacted, leakage of internal integration credentials is a high-severity operational risk.
The dependency bump alone did not eliminate observed behavior in runtime testing, so this PR includes an application-layer mitigation (defense in depth) to enforce safe URI merge output.
Dependencies required
uri >= 1.1.1 (recorded in Gemfile and Gemfile.lock).
Fixes # (issue)
Type of change
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to not work as expected)
This change requires a documentation update
How Has This Been Tested?
Validation was performed in the containerized API runtime using reproducible commands.
Ensure containers are running:
docker compose up -d doubtfire-api
Verify runtime versions:
docker compose run --rm doubtfire-api bash -lc '
cd /doubtfire && bundle exec rails runner "
require "uri/version"
puts "Ruby: #{RUBY_VERSION}"
puts "URI gem: #{URI::VERSION}"
"
'
Reproduce CVE PoC behavior check:
docker compose run --rm doubtfire-api bash -lc '
cd /doubtfire && bundle exec rails runner "
require "uri"
base = URI.parse("https://fakeuser:fakepass@internal.example/service\")
target = URI.parse("/steal")
combined = base + target
puts "Base: #{base}"
puts "Target: #{target}"
puts "Combined: #{combined}"
if combined.to_s.include?("fakeuser:fakepass@")
puts "RESULT: VULNERABLE (CVE-2025-61594)"
else
puts "RESULT: SAFE"
end
"
'
Observed result after fix:
Ruby: 3.4.9
URI gem: 1.1.1
Combined: https://internal.example/steal
RESULT: SAFE
Before the fix:

After the fix:

Checklist:
My code follows the style guidelines of this project
I have performed a self-review of my own code
I have commented my code, particularly in hard-to-understand areas
My changes generate no new warnings
I have added tests that prove my fix is effective
New and existing unit tests pass locally with my changes