Skip to content

Commit c3ac246

Browse files
[Medium] Patch ruby for CVE-2025-24294 (microsoft#14296)
1 parent ed2830f commit c3ac246

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

SPECS/ruby/CVE-2025-24294.patch

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
From 0402b9455a79af510e18bbd60f83427fe30fea86 Mon Sep 17 00:00:00 2001
2+
From: BinduSri-6522866 <[email protected]>
3+
Date: Tue, 15 Jul 2025 07:41:43 +0000
4+
Subject: [PATCH] Address CVE-2025-24294
5+
6+
Upstream Patch reference: https://github.com/ruby/resolv/commit/4c2f71b5e80826506f78417d85b38481c058fb25
7+
---
8+
lib/resolv.rb | 6 +++++-
9+
test/resolv/test_dns.rb | 7 +++++++
10+
2 files changed, 12 insertions(+), 1 deletion(-)
11+
12+
diff --git a/lib/resolv.rb b/lib/resolv.rb
13+
index 57fd173..778891c 100644
14+
--- a/lib/resolv.rb
15+
+++ b/lib/resolv.rb
16+
@@ -1655,6 +1655,7 @@ class Resolv
17+
prev_index = @index
18+
save_index = nil
19+
d = []
20+
+ size = -1
21+
while true
22+
raise DecodeError.new("limit exceeded") if @limit <= @index
23+
case @data.getbyte(@index)
24+
@@ -1675,7 +1676,10 @@ class Resolv
25+
end
26+
@index = idx
27+
else
28+
- d << self.get_label
29+
+ l = self.get_label
30+
+ d << l
31+
+ size += 1 + l.string.bytesize
32+
+ raise DecodeError.new("name label data exceed 255 octets") if size > 255
33+
end
34+
end
35+
end
36+
diff --git a/test/resolv/test_dns.rb b/test/resolv/test_dns.rb
37+
index 20c3408..c25026e 100644
38+
--- a/test/resolv/test_dns.rb
39+
+++ b/test/resolv/test_dns.rb
40+
@@ -589,6 +589,13 @@ class TestResolvDNS < Test::Unit::TestCase
41+
assert_operator(2**14, :<, m.to_s.length)
42+
end
43+
44+
+ def test_too_long_address
45+
+ too_long_address_message = [0, 0, 1, 0, 0, 0].pack("n*") + "\x01x" * 129 + [0, 0, 0].pack("cnn")
46+
+ assert_raise_with_message(Resolv::DNS::DecodeError, /name label data exceed 255 octets/) do
47+
+ Resolv::DNS::Message.decode too_long_address_message
48+
+ end
49+
+ end
50+
+
51+
def assert_no_fd_leak
52+
socket = assert_throw(self) do |tag|
53+
Resolv::DNS.stub(:bind_random_port, ->(s, *) {throw(tag, s)}) do
54+
--
55+
2.45.3
56+

SPECS/ruby/ruby.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Name: ruby
8383
# provides should be versioned according to the ruby version.
8484
# More info: https://stdgems.org/
8585
Version: 3.1.7
86-
Release: 2%{?dist}
86+
Release: 3%{?dist}
8787
License: (Ruby OR BSD) AND Public Domain AND MIT AND CC0 AND zlib AND UCD
8888
Vendor: Microsoft Corporation
8989
Distribution: Mariner
@@ -100,6 +100,7 @@ Source7: macros.rubygems
100100
# Updates default ruby-uri to 0.12.2 and vendored one to 0.10.3. Remove once ruby gets updated to a version that comes with both lib/uri/version.rb and lib/bundler/vendor/uri/lib/uri/version.rb versions >= 0.12.2 or == 0.10.3
101101
Patch0: CVE-2023-36617.patch
102102
Patch1: CVE-2025-6442.patch
103+
Patch2: CVE-2025-24294.patch
103104
BuildRequires: openssl-devel
104105
BuildRequires: readline
105106
BuildRequires: readline-devel
@@ -402,6 +403,9 @@ sudo -u test make test TESTS="-v"
402403
%{_rpmconfigdir}/rubygems.con
403404

404405
%changelog
406+
* Tue Jul 15 2025 BinduSri Adabala <[email protected]> - 3.1.7-3
407+
- Patch CVE-2025-24294
408+
405409
* Mon Jun 30 2025 Kevin Lockwood <[email protected]> - 3.1.7-2
406410
- Patch CVE-2025-6442
407411

0 commit comments

Comments
 (0)