Skip to content

Commit 3a1e76a

Browse files
azurelinux-securityKanishk-BansalAkarshHCL
authored
[AutoPR- Security] Patch rubygem-faraday for CVE-2026-25765 [MEDIUM] (#16430)
Co-authored-by: Kanishk Bansal <103916909+Kanishk-Bansal@users.noreply.github.com> Co-authored-by: Akarsh Chaudhary <v-akarshc@microsoft.com>
1 parent d1ac73c commit 3a1e76a

File tree

2 files changed

+94
-2
lines changed

2 files changed

+94
-2
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
From e45ae8f935f6f87b91929b2ba48b57e5ba174435 Mon Sep 17 00:00:00 2001
2+
From: AllSpark <allspark@microsoft.com>
3+
Date: Thu, 2 Apr 2026 15:18:26 +0000
4+
Subject: [PATCH] build_exclusive_url: Guard against protocol-relative URLs by
5+
normalising to relative path; update rubocop todo and add specs
6+
(GHSA-33mh-2634-fwr2)
7+
8+
Signed-off-by: Azure Linux Security Servicing Account <azurelinux-security@microsoft.com>
9+
Upstream-reference: AI Backport of https://github.com/lostisland/faraday/commit/a6d3a3a0bf59c2ab307d0abd91bc126aef5561bc.patch
10+
---
11+
.rubocop_todo.yml | 2 +-
12+
lib/faraday/connection.rb | 3 +++
13+
spec/faraday/connection_spec.rb | 33 +++++++++++++++++++++++++++++++++
14+
3 files changed, 37 insertions(+), 1 deletion(-)
15+
16+
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
17+
index fbec6de..3c75338 100644
18+
--- a/.rubocop_todo.yml
19+
+++ b/.rubocop_todo.yml
20+
@@ -31,7 +31,7 @@ Metrics/AbcSize:
21+
# Offense count: 4
22+
# Configuration parameters: CountComments, CountAsOne.
23+
Metrics/ClassLength:
24+
- Max: 230
25+
+ Max: 235
26+
27+
# Offense count: 9
28+
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
29+
diff --git a/lib/faraday/connection.rb b/lib/faraday/connection.rb
30+
index 1984f87..7056572 100644
31+
--- a/lib/faraday/connection.rb
32+
+++ b/lib/faraday/connection.rb
33+
@@ -473,6 +473,9 @@ module Faraday
34+
if url && !base.path.end_with?('/')
35+
base.path = "#{base.path}/" # ensure trailing slash
36+
end
37+
+ # Ensure relative url will be parsed correctly (such as `service:search` or `//evil.com`)
38+
+ url = "./#{url}" if url.respond_to?(:start_with?) &&
39+
+ (!url.start_with?('http://', 'https://', '/', './', '../') || url.start_with?('//'))
40+
url = url.to_s.gsub(':', '%3A') if URI.parse(url.to_s).opaque
41+
uri = url ? base + url : base
42+
if params
43+
diff --git a/spec/faraday/connection_spec.rb b/spec/faraday/connection_spec.rb
44+
index d4ccb23..51392f1 100644
45+
--- a/spec/faraday/connection_spec.rb
46+
+++ b/spec/faraday/connection_spec.rb
47+
@@ -310,6 +310,39 @@
48+
expect(uri.to_s).to eq('http://service.com/api/service%3Asearch?limit=400')
49+
end
50+
end
51+
+ context 'with protocol-relative URL (GHSA-33mh-2634-fwr2)' do
52+
+ it 'does not allow host override with //evil.com/path' do
53+
+ conn.url_prefix = 'http://httpbingo.org/api'
54+
+ uri = conn.build_exclusive_url('//evil.com/path')
55+
+ expect(uri.host).to eq('httpbingo.org')
56+
+ end
57+
+
58+
+ it 'does not allow host override with //evil.com:8080/path' do
59+
+ conn.url_prefix = 'http://httpbingo.org/api'
60+
+ uri = conn.build_exclusive_url('//evil.com:8080/path')
61+
+ expect(uri.host).to eq('httpbingo.org')
62+
+ end
63+
+
64+
+ it 'does not allow host override with //user:pass@evil.com/path' do
65+
+ conn.url_prefix = 'http://httpbingo.org/api'
66+
+ uri = conn.build_exclusive_url('//user:pass@evil.com/path')
67+
+ expect(uri.host).to eq('httpbingo.org')
68+
+ end
69+
+
70+
+ it 'does not allow host override with ///evil.com' do
71+
+ conn.url_prefix = 'http://httpbingo.org/api'
72+
+ uri = conn.build_exclusive_url('///evil.com')
73+
+ expect(uri.host).to eq('httpbingo.org')
74+
+ end
75+
+
76+
+ it 'still allows single-slash absolute paths' do
77+
+ conn.url_prefix = 'http://httpbingo.org/api'
78+
+ uri = conn.build_exclusive_url('/safe/path')
79+
+ expect(uri.host).to eq('httpbingo.org')
80+
+ expect(uri.path).to eq('/safe/path')
81+
+ end
82+
+ end
83+
+
84+
85+
context 'with a custom `default_uri_parser`' do
86+
let(:url) { 'http://httpbingo.org' }
87+
--
88+
2.45.4

SPECS/rubygem-faraday/rubygem-faraday.spec

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
Summary: HTTP/REST API client library
44
Name: rubygem-faraday
55
Version: 2.7.10
6-
Release: 1%{?dist}
6+
Release: 2%{?dist}
77
License: MIT
88
Vendor: Microsoft Corporation
99
Distribution: Azure Linux
1010
Group: Development/Languages
1111
URL: https://lostisland.github.io/faraday/
1212
Source0: https://github.com/lostisland/faraday/archive/refs/tags/v%{version}.tar.gz#/%{gem_name}-%{version}.tar.gz
13+
Patch0: CVE-2026-25765.patch
1314
BuildRequires: ruby
1415
Requires: rubygem-multipart-post < 3
1516
Requires: rubygem-ruby2_keywords
@@ -22,7 +23,7 @@ many adapters (such as Net::HTTP) and embraces the concept of Rack middleware
2223
when processing the request/response cycle.
2324

2425
%prep
25-
%setup -q -n %{gem_name}-%{version}
26+
%autosetup -n %{gem_name}-%{version} -p1
2627

2728
%build
2829
gem build %{gem_name}
@@ -36,6 +37,9 @@ gem install -V --local --force --install-dir %{buildroot}/%{gemdir} %{gem_name}-
3637
%{gemdir}
3738

3839
%changelog
40+
* Thu Apr 02 2026 Azure Linux Security Servicing Account <azurelinux-security@microsoft.com> - 2.7.10-2
41+
- Patch for CVE-2026-25765
42+
3943
* Thu Nov 02 2023 CBL-Mariner Servicing Account <cblmargh@microsoft.com> - 2.7.10-1
4044
- Auto-upgrade to 2.7.10 - Azure Linux 3.0 - package upgrades
4145

0 commit comments

Comments
 (0)