From fe7798bba32d8d5425398acbe7ed05ed14f84470 Mon Sep 17 00:00:00 2001 From: sxt1001 Date: Thu, 5 Jan 2023 14:40:39 +0800 Subject: [PATCH] fix CVE-2021-33621 (cherry picked from commit 8b60ed7949baf898cbf1e9b616ce5f89608605e7) --- backport-0001-CVE-2021-33621.patch | 169 ++++++++++++++++++ backport-0002-CVE-2021-33621.patch | 135 ++++++++++++++ ...kie_new_with_domain-to-pass-on-older.patch | 39 ++++ ...osen-the-domain-regex-to-accept-.-29.patch | 44 +++++ ...port-Relax-domain-label-restrictions.patch | 55 ++++++ ruby.spec | 10 +- 6 files changed, 451 insertions(+), 1 deletion(-) create mode 100644 backport-0001-CVE-2021-33621.patch create mode 100644 backport-0002-CVE-2021-33621.patch create mode 100644 backport-Fix-test_cgi_cookie_new_with_domain-to-pass-on-older.patch create mode 100644 backport-Loosen-the-domain-regex-to-accept-.-29.patch create mode 100644 backport-Relax-domain-label-restrictions.patch diff --git a/backport-0001-CVE-2021-33621.patch b/backport-0001-CVE-2021-33621.patch new file mode 100644 index 0000000..1c29e06 --- /dev/null +++ b/backport-0001-CVE-2021-33621.patch @@ -0,0 +1,169 @@ +From 30107a4797f14227568913499a9a0bb4285de63b Mon Sep 17 00:00:00 2001 +From: Nobuyoshi Nakada +Date: Tue, 16 Aug 2022 18:36:12 +0900 +Subject: [PATCH] Check cookie name/path/domain characters + +https://hackerone.com/reports/1204977 +--- + lib/cgi/cookie.rb | 44 ++++++++++++++++++++----- + test/cgi/test_cgi_cookie.rb | 64 +++++++++++++++++++++++++++++++++++++ + 2 files changed, 100 insertions(+), 8 deletions(-) + +diff --git a/lib/cgi/cookie.rb b/lib/cgi/cookie.rb +index 6b0d89c..4b11a6a 100644 +--- a/lib/cgi/cookie.rb ++++ b/lib/cgi/cookie.rb +@@ -40,6 +40,10 @@ class CGI + class Cookie < Array + @@accept_charset="UTF-8" unless defined?(@@accept_charset) + ++ TOKEN_RE = %r"\A[[!-~]&&[^()<>@,;:\\\"/?=\[\]{}]]+\z" ++ PATH_VALUE_RE = %r"\A[[ -~]&&[^;]]*\z" ++ DOMAIN_VALUE_RE = %r"\A(?