From 1835319e08b3912563a14bbe05e639d7470a30a8 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Wed, 10 Jan 2018 11:56:48 +0100 Subject: [PATCH] ssh: remove arcfour ciphers from the default preference list OpenSSH removed these ciphers from sshd's default configuration with release 6.7 in 2014. Change-Id: Ia8b6d671dc8fa5d0493bf933d3b541f8ae5707a3 Reviewed-on: https://go-review.googlesource.com/86955 Run-TryBot: Han-Wen Nienhuys TryBot-Result: Gobot Gobot Reviewed-by: Adam Langley Reviewed-by: Brad Fitzpatrick --- ssh/cipher_test.go | 7 ++++++- ssh/common.go | 15 ++++++++++++--- ssh/test/session_test.go | 10 ++++++---- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/ssh/cipher_test.go b/ssh/cipher_test.go index 6a35d87..6da5815 100644 --- a/ssh/cipher_test.go +++ b/ssh/cipher_test.go @@ -15,7 +15,12 @@ import ( func TestDefaultCiphersExist(t *testing.T) { for _, cipherAlgo := range supportedCiphers { if _, ok := cipherModes[cipherAlgo]; !ok { - t.Errorf("default cipher %q is unknown", cipherAlgo) + t.Errorf("supported cipher %q is unknown", cipherAlgo) + } + } + for _, cipherAlgo := range preferredCiphers { + if _, ok := cipherModes[cipherAlgo]; !ok { + t.Errorf("preferred cipher %q is unknown", cipherAlgo) } } } diff --git a/ssh/common.go b/ssh/common.go index 77f9c5b..ffdc01f 100644 --- a/ssh/common.go +++ b/ssh/common.go @@ -24,12 +24,21 @@ const ( serviceSSH = "ssh-connection" ) -// supportedCiphers specifies the supported ciphers in preference order. +// supportedCiphers lists ciphers we support but might not recommend. var supportedCiphers = []string{ "aes128-ctr", "aes192-ctr", "aes256-ctr", "aes128-gcm@openssh.com", chacha20Poly1305ID, - "arcfour256", "arcfour128", + "arcfour256", "arcfour128", "arcfour", + aes128cbcID, + tripledescbcID, +} + +// preferredCiphers specifies the default preference for ciphers. +var preferredCiphers = []string{ + "aes128-ctr", "aes192-ctr", "aes256-ctr", + "aes128-gcm@openssh.com", + chacha20Poly1305ID, } // supportedKexAlgos specifies the supported key-exchange algorithms in @@ -212,7 +221,7 @@ func (c *Config) SetDefaults() { c.Rand = rand.Reader } if c.Ciphers == nil { - c.Ciphers = supportedCiphers + c.Ciphers = preferredCiphers } var ciphers []string for _, c := range c.Ciphers { diff --git a/ssh/test/session_test.go b/ssh/test/session_test.go index 9e702ef..7588b0c 100644 --- a/ssh/test/session_test.go +++ b/ssh/test/session_test.go @@ -324,13 +324,15 @@ func TestWindowChange(t *testing.T) { } } +var deprecatedCiphers = []string{ + "aes128-cbc", "3des-cbc", + "arcfour128", "arcfour256", +} + func TestCiphers(t *testing.T) { var config ssh.Config config.SetDefaults() - cipherOrder := config.Ciphers - // These ciphers will not be tested when commented out in cipher.go it will - // fallback to the next available as per line 292. - cipherOrder = append(cipherOrder, "aes128-cbc", "3des-cbc") + cipherOrder := append(config.Ciphers, deprecatedCiphers...) for _, ciph := range cipherOrder { t.Run(ciph, func(t *testing.T) {