Skip to content

Commit 35c2be2

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. After initial discussions around this change with @chris-rock and @artem-sideorenko, there may be follow-on changes to the hardcoded selections this cookbook generates, however that's a topic for future discussion and PRs. 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. Note that `node['ssh'][{'client', 'server'}][{'weak_hmac', 'weak_kex', 'cbc_required'}}` are all ignored if these overrides are used, as the user is supplying their preferred choices, rather than relying on the cookbook's generated strings. [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 0fa0082 commit 35c2be2

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: DevSec::Ssh.get_client_macs(node['ssh']['client']['weak_hmac']),
66-
kex: DevSec::Ssh.get_client_kexs(node['ssh']['client']['weak_kex']),
67-
cipher: DevSec::Ssh.get_client_ciphers(node['ssh']['client']['cbc_required']),
65+
mac: node['ssh']['client']['mac'] || DevSec::Ssh.get_client_macs(node['ssh']['client']['weak_hmac']),
66+
kex: node['ssh']['client']['kex'] || DevSec::Ssh.get_client_kexs(node['ssh']['client']['weak_kex']),
67+
cipher: node['ssh']['client']['cipher'] || DevSec::Ssh.get_client_ciphers(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: DevSec::Ssh.get_server_macs(node['ssh']['server']['weak_hmac']),
96-
kex: DevSec::Ssh.get_server_kexs(node['ssh']['server']['weak_kex']),
97-
cipher: DevSec::Ssh.get_server_ciphers(node['ssh']['server']['cbc_required']),
95+
mac: node['ssh']['server']['mac'] || DevSec::Ssh.get_server_macs(node['ssh']['server']['weak_hmac']),
96+
kex: node['ssh']['server']['kex'] || DevSec::Ssh.get_server_kexs(node['ssh']['server']['weak_kex']),
97+
cipher: node['ssh']['server']['cipher'] || DevSec::Ssh.get_server_ciphers(node['ssh']['server']['cbc_required']),
9898
use_priv_sep: node['ssh']['use_privilege_separation'] || DevSec::Ssh.get_server_privilege_separarion,
9999
deny_users: node['ssh']['deny_users'],
100100
allow_users: node['ssh']['allow_users'],

0 commit comments

Comments
 (0)