From 1687e99bf2a415553e11ebcc3aa1eaf2493ad1c5 Mon Sep 17 00:00:00 2001 From: starlet-dx <15929766099@163.com> Date: Fri, 14 Jan 2022 17:17:42 +0800 Subject: [PATCH] Fix CVE-2021-41819 (cherry picked from commit 68341c512bb0bbf62eac5ae360513bee2dafa2fe) --- CVE-2021-41819.patch | 38 ++++++++++++++++++++++++++++++++++++++ ruby.spec | 6 +++++- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 CVE-2021-41819.patch diff --git a/CVE-2021-41819.patch b/CVE-2021-41819.patch new file mode 100644 index 0000000..4ee4ace --- /dev/null +++ b/CVE-2021-41819.patch @@ -0,0 +1,38 @@ +From 052eb3a828b0f99bca39cfd800f6c2b91307dbd5 Mon Sep 17 00:00:00 2001 +From: Nobuyoshi Nakada +Date: Mon, 29 Jun 2020 10:29:25 +0900 +Subject: [PATCH] When parsing cookies, only decode the values + +--- + lib/cgi/cookie.rb | 1 - + test/cgi/test_cgi_cookie.rb | 5 +++++ + 2 files changed, 5 insertions(+), 1 deletion(-) + +diff --git a/lib/cgi/cookie.rb b/lib/cgi/cookie.rb +index ae9ab58..6b0d89c 100644 +--- a/lib/cgi/cookie.rb ++++ b/lib/cgi/cookie.rb +@@ -165,7 +165,6 @@ def self.parse(raw_cookie) + raw_cookie.split(/;\s?/).each do |pairs| + name, values = pairs.split('=',2) + next unless name and values +- name = CGI.unescape(name) + values ||= "" + values = values.split('&').collect{|v| CGI.unescape(v,@@accept_charset) } + if cookies.has_key?(name) +diff --git a/test/cgi/test_cgi_cookie.rb b/test/cgi/test_cgi_cookie.rb +index 115a57e..985cc0d 100644 +--- a/test/cgi/test_cgi_cookie.rb ++++ b/test/cgi/test_cgi_cookie.rb +@@ -101,6 +101,11 @@ def test_cgi_cookie_parse + end + end + ++ def test_cgi_cookie_parse_not_decode_name ++ cookie_str = "%66oo=baz;foo=bar" ++ cookies = CGI::Cookie.parse(cookie_str) ++ assert_equal({"%66oo" => ["baz"], "foo" => ["bar"]}, cookies) ++ end + + def test_cgi_cookie_arrayinterface + cookie = CGI::Cookie.new('name1', 'a', 'b', 'c') diff --git a/ruby.spec b/ruby.spec index c3567d6..0a57418 100644 --- a/ruby.spec +++ b/ruby.spec @@ -1,6 +1,6 @@ Name: ruby Version: 2.5.8 -Release: 114 +Release: 115 Summary: Object-oriented scripting language interpreter License: (Ruby or BSD) and Public Domain and MIT and CC0 and zlib and UCD URL: https://www.ruby-lang.org/ @@ -39,6 +39,7 @@ Patch0013: CVE-2019-19204.patch Patch0014: CVE-2019-19246.patch Patch0015: CVE-2019-16163.patch Patch0016: CVE-2020-25613.patch +Patch0017: CVE-2021-41819.patch Patch6000: backport-0001-CVE-2021-28965.patch Patch6001: backport-0002-CVE-2021-28965.patch Patch6002: backport-CVE-2021-31799.patch @@ -581,6 +582,9 @@ make runruby TESTRUN_SCRIPT=%{SOURCE13} %exclude %{gem_dir}/gems/xmlrpc-0.3.0/.* %changelog +* Fri Jan 14 2022 yaoxin - 2.5.8-115 +- Fix CVE-2021-41819 + * Sat Jul 31 2021 shixuantong - 2.5.8-114 - Type:cves - ID:CVE-2021-31799 CVE-2021-31810 CVE-2021-32066 -- Gitee