Skip to content

Commit 9948c24

Browse files
committed
Add node attributes to override KEX, MAC and cipher values
There's advice available on preferred choices of key exchange, message authentication and ciphers from a number of sources [1][2][3], all of which don't _entirely_ agree with each other, and then there's the hardcoded selection of Kex, MAC and ciphers encoded in this cookbook. At the time of committing, there is a refactor going on to simplify kex and cipher handling: #134 Even in that refactor, hmac-ripemd160 MACs, which have been removed in OpenSSH 6.7 (and hence flagged by ssh-audit[1] and are absent from Mozilla's recommendations[2] for modern sshd, yet are still recommended by secure secure shell[3]) are included in the default MAC list. Likewise hmac-sha2-256 and hmac-sha2-512 are flagged by ssh-audit[1] as they are encrypt-and-MAC, which has a number of issues, discussed in secure secure shell[3]. There is likely to be more complexity and balancing of features/security to consider plus the future changes of refactors in this cookbook, so initially, I'd just like a way of overriding the generated defaults. [1] https://github.com/arthepsy/ssh-audit [2] https://wiki.mozilla.org/Security/Guidelines/OpenSSH [3] https://stribika.github.io/2015/01/04/secure-secure-shell.html
1 parent 10953dc commit 9948c24

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ This cookbook provides secure ssh-client and ssh-server configurations.
2828
## Attributes
2929

3030
* `['network']['ipv6']['enable']` - true if IPv6 is needed
31+
* `['ssh'][{'client', 'server'}]['kex']` - nil to calculate best key-exchange (KEX) based on server version, otherwise specify a string of Kex values
32+
* `['ssh'][{'client', 'server'}]['mac']` - nil to calculate best Message Authentication Codes (MACs) based on server version, otherwise specify a string of Mac values
33+
* `['ssh'][{'client', 'server'}]['cipher']` - nil to calculate best ciphers based on server version, otherwise specify a string of Cipher values
3134
* `['ssh'][{'client', 'server'}]['cbc_required']` - true if CBC for ciphers is required. This is usually only necessary, if older M2M mechanism need to communicate with SSH, that don't have any of the configured secure ciphers enabled. CBC is a weak alternative. Anything weaker should be avoided and is thus not available.
3235
* `['ssh'][{'client', 'server'}]['weak_hmac']` - true if weaker HMAC mechanisms are required. This is usually only necessary, if older M2M mechanism need to communicate with SSH, that don't have any of the configured secure HMACs enabled.
3336
* `['ssh'][{'client', 'server'}]['weak_kex']` - true if weaker Key-Exchange (KEX) mechanisms are required. This is usually only necessary, if older M2M mechanism need to communicate with SSH, that don't have any of the configured secure KEXs enabled.

attributes/default.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@
4848

4949
default['config_disclaimer'] = '**Note:** This file was automatically created by Hardening Framework (dev-sec.io) configuration. If you use its automated setup, do not edit this file directly, but adjust the automation instead.'
5050
default['network']['ipv6']['enable'] = false # sshd + ssh
51+
default['ssh']['server']['kex'] = nil # nil = calculate best combination for server version
52+
default['ssh']['client']['mac'] = nil # nil = calculate best combination for client
53+
default['ssh']['server']['cipher'] = nil # nil = calculate best combination for server version
54+
default['ssh']['client']['kex'] = nil # nil = calculate best combination for client
55+
default['ssh']['server']['mac'] = nil # nil = calculate best combination for server version
56+
default['ssh']['client']['cipher'] = nil # nil = calculate best combination for client
5157
default['ssh']['client']['cbc_required'] = false # ssh
5258
default['ssh']['server']['cbc_required'] = false # sshd
5359
default['ssh']['client']['weak_hmac'] = false # ssh

recipes/client.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@
6262
owner 'root'
6363
group 'root'
6464
variables(
65-
mac: SshMac.get_macs(node, node['ssh']['client']['weak_hmac']),
66-
kex: SshKex.get_kexs(node, node['ssh']['client']['weak_kex']),
67-
cipher: SshCipher.get_ciphers(node, node['ssh']['client']['cbc_required']),
65+
mac: node['ssh']['client']['mac'] || SshMac.get_macs(node, node['ssh']['client']['weak_hmac']),
66+
kex: node['ssh']['client']['kex'] || SshKex.get_kexs(node, node['ssh']['client']['weak_kex']),
67+
cipher: node['ssh']['client']['cipher'] || SshCipher.get_ciphers(node, node['ssh']['client']['cbc_required']),
6868
roaming: node['ssh']['client']['roaming']
6969
)
7070
end

recipes/server.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@
9292
owner 'root'
9393
group 'root'
9494
variables(
95-
mac: SshMac.get_macs(node, node['ssh']['server']['weak_hmac']),
96-
kex: SshKex.get_kexs(node, node['ssh']['server']['weak_kex']),
97-
cipher: SshCipher.get_ciphers(node, node['ssh']['server']['cbc_required']),
95+
mac: node['ssh']['server']['mac'] || SshMac.get_macs(node, node['ssh']['server']['weak_hmac']),
96+
kex: node['ssh']['server']['kex'] || SshKex.get_kexs(node, node['ssh']['server']['weak_kex']),
97+
cipher: node['ssh']['server']['cipher'] || SshCipher.get_ciphers(node, node['ssh']['server']['cbc_required']),
9898
use_priv_sep: node['ssh']['use_privilege_separation'] || UsePrivilegeSeparation.get(node),
9999
deny_users: node['ssh']['deny_users'],
100100
allow_users: node['ssh']['allow_users'],

0 commit comments

Comments
 (0)