Skip to content

Commit dc4b0b3

Browse files
[AUTO-CHERRYPICK] libcontainers-common: patch CVE-2021-43565 - branch main (#9975)
Co-authored-by: Archana Choudhary <36061892+arc9693@users.noreply.github.com>
1 parent 58612db commit dc4b0b3

2 files changed

Lines changed: 63 additions & 1 deletion

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
From 5770296d904e90f15f38f77dfc2e43fdf5efc083 Mon Sep 17 00:00:00 2001
2+
From: Roland Shoemaker <roland@golang.org>
3+
Date: Tue, 9 Nov 2021 11:45:57 -0800
4+
Subject: [PATCH] ssh: don't assume packet plaintext size
5+
6+
When reading GCM and ChaChaPoly1305 packets, don't make assumptions
7+
about the size of the enciphered plaintext. This fixes two panics
8+
caused by standards non-compliant malformed packets.
9+
10+
Thanks to Rod Hynes, Psiphon Inc. for reporting this issue.
11+
12+
Fixes golang/go#49932
13+
Fixes CVE-2021-43565
14+
15+
Change-Id: I660cff39d197e0d04ec44d11d792b22d954df2ef
16+
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1262659
17+
Reviewed-by: Katie Hockman <katiehockman@google.com>
18+
Reviewed-by: Julie Qiu <julieqiu@google.com>
19+
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/368814
20+
Trust: Roland Shoemaker <roland@golang.org>
21+
Trust: Katie Hockman <katie@golang.org>
22+
Run-TryBot: Roland Shoemaker <roland@golang.org>
23+
TryBot-Result: Gopher Robot <gobot@golang.org>
24+
Reviewed-by: Julie Qiu <julie@golang.org>
25+
Reviewed-by: Katie Hockman <katie@golang.org>
26+
---
27+
ssh/cipher.go | 8 ++++
28+
ssh/cipher_test.go | 100 +++++++++++++++++++++++++++++++++++++++++++++
29+
2 files changed, 108 insertions(+)
30+
31+
diff --git a/vendor/golang.org/x/crypto/ssh/cipher.go b/vendor/golang.org/x/crypto/ssh/cipher.go
32+
index bddbde5dbd..f8bdf4984c 100644
33+
--- a/vendor/golang.org/x/crypto/ssh/cipher.go
34+
+++ b/vendor/golang.org/x/crypto/ssh/cipher.go
35+
@@ -394,6 +394,10 @@ func (c *gcmCipher) readCipherPacket(seqNum uint32, r io.Reader) ([]byte, error)
36+
}
37+
c.incIV()
38+
39+
+ if len(plain) == 0 {
40+
+ return nil, errors.New("ssh: empty packet")
41+
+ }
42+
+
43+
padding := plain[0]
44+
if padding < 4 {
45+
// padding is a byte, so it automatically satisfies
46+
@@ -710,6 +714,10 @@ func (c *chacha20Poly1305Cipher) readCipherPacket(seqNum uint32, r io.Reader) ([
47+
plain := c.buf[4:contentEnd]
48+
s.XORKeyStream(plain, plain)
49+
50+
+ if len(plain) == 0 {
51+
+ return nil, errors.New("ssh: empty packet")
52+
+ }
53+
+
54+
padding := plain[0]
55+
if padding < 4 {
56+
// padding is a byte, so it automatically satisfies

SPECS/libcontainers-common/libcontainers-common.spec

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
Summary: Configuration files common to github.com/containers
2727
Name: libcontainers-common
2828
Version: 20210626
29-
Release: 4%{?dist}
29+
Release: 5%{?dist}
3030
License: ASL 2.0 AND GPLv3
3131
Vendor: Microsoft Corporation
3232
Distribution: Mariner
@@ -50,6 +50,7 @@ Source10: containers.conf
5050
Patch0: CVE-2021-44716.patch
5151
#Note (mfrw): The patch for CVE-2024-37298 only applies to podman.
5252
Patch1: CVE-2024-37298.patch
53+
Patch2: CVE-2021-43565.patch
5354
BuildRequires: go-go-md2man
5455
Requires(post): grep
5556
Requires(post): util-linux
@@ -70,7 +71,9 @@ github.com/containers libraries, such as Buildah, CRI-O, Podman and Skopeo.
7071

7172
%setup -q -T -D -b 9 -n common-%{commonver}
7273
%patch 0 -p1
74+
7375
# copy the LICENSE file in the build root
76+
%patch 2 -p1 -d ../podman-%{podmanver}
7477
cd ..
7578
cp %{SOURCE2} .
7679

@@ -165,6 +168,9 @@ fi
165168
%license LICENSE
166169
167170
%changelog
171+
* Mon Jul 29 2024 Archana Choudhary <archana1@microsoft.com> - 20210626-5
172+
- Patch CVE-2021-43565
173+
168174
* Wed Jul 24 2024 Muhammad Falak <mwani@microsoft.com> - 20210526-4
169175
- Address CVE-2024-37298 by patching vendored github.com/gorilla/schema
170176

0 commit comments

Comments
 (0)