Skip to content

Commit acf2b37

Browse files
CBL-Mariner-Botarc9693rikenm1
authored
[AUTO-CHERRYPICK] cf-cli: patch CVE-2021-43565 - branch main (#9902)
Co-authored-by: Archana Choudhary <36061892+arc9693@users.noreply.github.com> Co-authored-by: Riken Maharjan <106988478+rikenm1@users.noreply.github.com>
1 parent f684f32 commit acf2b37

2 files changed

Lines changed: 62 additions & 1 deletion

File tree

SPECS/cf-cli/CVE-2021-43565.patch

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/cf-cli/cf-cli.spec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Summary: The official command line client for Cloud Foundry.
22
Name: cf-cli
33
Version: 8.4.0
4-
Release: 18%{?dist}
4+
Release: 19%{?dist}
55
License: Apache-2.0
66
Vendor: Microsoft Corporation
77
Distribution: Mariner
@@ -29,6 +29,7 @@ Source0: https://github.com/cloudfoundry/cli/archive/refs/tags/v%{version
2929
Source1: cli-%{version}-vendor.tar.gz
3030
Patch0: CVE-2023-44487.patch
3131
Patch1: CVE-2021-44716.patch
32+
Patch2: CVE-2021-43565.patch
3233

3334
BuildRequires: golang
3435
%global debug_package %{nil}
@@ -63,9 +64,13 @@ install -p -m 755 -t %{buildroot}%{_bindir} ./out/cf
6364
%{_bindir}/cf
6465

6566
%changelog
67+
* Mon Jul 22 2024 Archana Choudhary <archana1@microsoft.com> - 8.4.0-19.cm2
68+
- Patch CVE-2021-43565
69+
6670
* Wed Jul 17 2024 Muhammad Falak R Wani <mwani@microsoft.com> - 8.4.0-18
6771
- Drop requirement on a specific version of golang
6872

73+
6974
* Thu Jun 06 2024 CBL-Mariner Servicing Account <cblmargh@microsoft.com> - 8.4.0-17
7075
- Bump release to rebuild with go 1.21.11
7176

0 commit comments

Comments
 (0)