Skip to content

Commit 91f4a1f

Browse files
authored
cni: address CVE-2022-32149 (#10371)
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
1 parent 0d3bfba commit 91f4a1f

2 files changed

Lines changed: 70 additions & 1 deletion

File tree

SPECS/cni/CVE-2022-32149.patch

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
From a47ab91255e04dda4ca0d734afef58216c7479a2 Mon Sep 17 00:00:00 2001
2+
From: Roland Shoemaker <bracewell@google.com>
3+
Date: Fri, 2 Sep 2022 09:35:37 -0700
4+
Subject: [PATCH] language: reject excessively large Accept-Language strings
5+
6+
Backported to apply on vendor direcotry by @mfrw
7+
8+
The BCP 47 tag parser has quadratic time complexity due to inherent
9+
aspects of its design. Since the parser is, by design, exposed to
10+
untrusted user input, this can be leveraged to force a program to
11+
consume significant time parsing Accept-Language headers.
12+
13+
The parser cannot be easily rewritten to fix this behavior for
14+
various reasons. Instead the solution implemented in this CL is to
15+
limit the total complexity of tags passed into ParseAcceptLanguage
16+
by limiting the number of dashes in the string to 1000. This should
17+
be more than enough for the majority of real world use cases, where
18+
the number of tags being sent is likely to be in the single digits.
19+
20+
Thanks to the OSS-Fuzz project for discovering this issue and to Adam
21+
Korczynski (ADA Logics) for writing the fuzz case and for reporting the
22+
issue.
23+
24+
Fixes CVE-2022-32149
25+
Fixes golang/go#56152
26+
27+
Change-Id: I7bda1d84cee2b945039c203f26869d58ee9374ae
28+
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1565112
29+
Reviewed-by: Damien Neil <dneil@google.com>
30+
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
31+
Reviewed-on: https://go-review.googlesource.com/c/text/+/442235
32+
TryBot-Result: Gopher Robot <gobot@golang.org>
33+
Auto-Submit: Roland Shoemaker <roland@golang.org>
34+
Run-TryBot: Roland Shoemaker <roland@golang.org>
35+
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
36+
---
37+
vendor/golang.org/x/text/language/parse.go | 5 +++++
38+
1 file changed, 5 insertions(+)
39+
40+
diff --git a/vendor/golang.org/x/text/language/parse.go b/vendor/golang.org/x/text/language/parse.go
41+
index 59b0410..b982d9e 100644
42+
--- a/vendor/golang.org/x/text/language/parse.go
43+
+++ b/vendor/golang.org/x/text/language/parse.go
44+
@@ -147,6 +147,7 @@ func update(b *language.Builder, part ...interface{}) (err error) {
45+
}
46+
47+
var errInvalidWeight = errors.New("ParseAcceptLanguage: invalid weight")
48+
+var errTagListTooLarge = errors.New("tag list exceeds max length")
49+
50+
// ParseAcceptLanguage parses the contents of an Accept-Language header as
51+
// defined in http://www.ietf.org/rfc/rfc2616.txt and returns a list of Tags and
52+
@@ -164,6 +165,10 @@ func ParseAcceptLanguage(s string) (tag []Tag, q []float32, err error) {
53+
}
54+
}()
55+
56+
+ if strings.Count(s, "-") > 1000 {
57+
+ return nil, nil, errTagListTooLarge
58+
+ }
59+
+
60+
var entry string
61+
for s != "" {
62+
if entry, s = split(s, ','); entry == "" {
63+
--
64+
2.40.1
65+

SPECS/cni/cni.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
Summary: Container Network Interface - networking for Linux containers
2525
Name: cni
2626
Version: 1.1.2
27-
Release: 2%{?dist}
27+
Release: 3%{?dist}
2828
License: Apache-2.0
2929
Vendor: Microsoft Corporation
3030
Distribution: Azure Linux
@@ -49,6 +49,7 @@ Source2: build.sh
4949
#
5050
Source3: %{name}-%{version}-vendor.tar.gz
5151
Patch0: CVE-2021-38561.patch
52+
Patch1: CVE-2022-32149.patch
5253
BuildRequires: golang
5354
BuildRequires: systemd-rpm-macros
5455
BuildRequires: xz
@@ -114,6 +115,9 @@ install -m 755 -d "%{buildroot}%{cni_doc_dir}"
114115
%{_sbindir}/cnitool
115116

116117
%changelog
118+
* Fri Sep 06 2024 Muhammad Falak R Wani <mwani@microsoft.com> - 1.1.2-3
119+
- Patch CVE-2022-32149
120+
117121
* Tue Jul 02 2024 Osama Esmail <osamaesmail@microsoft.com> - 1.1.2-2
118122
- Patching CVE-2021-38561
119123

0 commit comments

Comments
 (0)