Skip to content

Commit 51f4f12

Browse files
authored
Merge pull request #119 from atomic111/master
Use new ciphers, kex, macs and priv separation sandbox for redhat family 7
2 parents 2e7a893 + a3f7e40 commit 51f4f12

File tree

7 files changed

+31
-12
lines changed

7 files changed

+31
-12
lines changed

attributes/default.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
default['sshserver']['service_name'] = 'ssh'
4242
end
4343

44-
default['config_disclaimer'] = '**Note:** This file was automatically created by Hardening Framework (hardening.io) configuration. If you use its automated setup, do not edit this file directly, but adjust the automation instead.'
44+
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.'
4545
default['network']['ipv6']['enable'] = false # sshd + ssh
4646
default['ssh']['client']['cbc_required'] = false # ssh
4747
default['ssh']['server']['cbc_required'] = false # sshd

libraries/get_ssh_ciphers.rb

+4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ def self.get_ciphers(node, cbc_required)
4747
elsif node['platform'] == 'debian' && node['platform_version'].to_f >= 8
4848
Chef::Log.info('Detected Debian 8 or newer, use new ciphers')
4949
cipher = ciphers_66
50+
51+
elsif node['platform_family'] == 'rhel' && node['platform_version'].to_f >= 7
52+
Chef::Log.info('Detected RedHat Family with version 7 or newer, use new ciphers')
53+
cipher = ciphers_66
5054
end
5155

5256
Chef::Log.info("Choose cipher: #{cipher[weak_ciphers]}")

libraries/get_ssh_kex.rb

+9-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Chef
2424
class Recipe
2525
class SshKex
2626
# rubocop:disable AbcSize
27-
def self.get_kexs(node, weak_kex)
27+
def self.get_kexs(node, weak_kex) # rubocop:disable CyclomaticComplexity, PerceivedComplexity
2828
weak_kex = weak_kex ? 'weak' : 'default'
2929

3030
kex_59 = {}
@@ -47,8 +47,14 @@ def self.get_kexs(node, weak_kex)
4747
Chef::Log.info('Detected Debian 8 or newer, use new key exchange algorithms')
4848
kex = kex_66
4949

50-
# deactivate kex on redhat
51-
elsif node['platform_family'] == 'rhel'
50+
# use newer kex for redhat version 7 or newer
51+
elsif node['platform_family'] == 'rhel' && node['platform_version'].to_f >= 7
52+
Chef::Log.info('Detected Redhat 7 or newer, use new key exchange algorithms')
53+
kex = kex_66
54+
55+
# deactivate kex on redhat version 6
56+
elsif node['platform_family'] == 'rhel' && node['platform_version'].to_f < 7
57+
Chef::Log.info('Detected Redhat 6 or earlier, disable KEX')
5258
kex = {}
5359
kex.default = nil
5460

libraries/get_ssh_macs.rb

+9-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Chef
2424
class Recipe
2525
class SshMac
2626
# rubocop:disable AbcSize
27-
def self.get_macs(node, weak_hmac)
27+
def self.get_macs(node, weak_hmac) # rubocop:disable CyclomaticComplexity, PerceivedComplexity
2828
weak_macs = weak_hmac ? 'weak' : 'default'
2929

3030
macs_53 = {}
@@ -41,7 +41,7 @@ def self.get_macs(node, weak_hmac)
4141
# determine the mac for the operating system
4242
macs = macs_59
4343

44-
# use newer ciphers on ubuntu 14.04
44+
# use newer macs on ubuntu 14.04
4545
if node['platform'] == 'ubuntu' && node['platform_version'].to_f >= 14.04
4646
Chef::Log.info('Detected Ubuntu 14.04 or newer, use new macs')
4747
macs = macs_66
@@ -50,8 +50,13 @@ def self.get_macs(node, weak_hmac)
5050
Chef::Log.info('Detected Debian 8 or newer, use new macs')
5151
macs = macs_66
5252

53-
# stick to 53 for rhel <= 6, verify for rhel >= 7
54-
elsif node['platform_family'] == 'rhel'
53+
# use newer macs for rhel >= 7
54+
elsif node['platform_family'] == 'rhel' && node['platform_version'].to_f >= 7
55+
Chef::Log.info('Detected RedHat Family with version 7 or newer, use new macs')
56+
macs = macs_66
57+
58+
# stick to 53 for rhel <= 6
59+
elsif node['platform_family'] == 'rhel' && node['platform_version'].to_f < 7
5560
Chef::Log.info('Detected RedHat Family, use old macs')
5661
macs = macs_53
5762

libraries/use_privilege_separation.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ def self.get(node)
3030
# ubuntu 12.04 and newer has ssh 5.9+
3131

3232
# redhat/centos/oracle 6.x has ssh 5.3
33-
if node['platform_family'] == 'rhel'
33+
if node['platform_family'] == 'rhel' && node['platform_version'].to_f >= 7
34+
ps = ps59
35+
36+
# redhat/centos/oracle 6.x has ssh 5.3
37+
elsif node['platform_family'] == 'rhel' && node['platform_version'].to_f < 7
3438
ps = ps53
3539

3640
# debian 7.x and newer has ssh 5.9+

templates/default/openssh.conf.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# This is the ssh client system-wide configuration file.
77
# See ssh_config(5) for more information on any settings used. Comments will be added only to clarify why a configuration was chosen.
88
#
9-
# Created for OpenSSH v5.9
9+
# Created for OpenSSH v5.9 up to 6.8
1010

1111
# Basic configuration
1212
# ===================

templates/default/opensshd.conf.erb

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# This is the ssh client system-wide configuration file.
77
# See sshd_config(5) for more information on any settings used. Comments will be added only to clarify why a configuration was chosen.
88
#
9-
# Created for OpenSSH v5.9
9+
# Created for OpenSSH v5.9 up to 6.8
1010

1111
# Basic configuration
1212
# ===================
@@ -219,4 +219,4 @@ X11Forwarding no
219219
#PasswordAuthentication no
220220
#PermitRootLogin no
221221
#X11Forwarding no
222-
<% end %>
222+
<% end %>

0 commit comments

Comments
 (0)