Skip to content
This repository was archived by the owner on Dec 26, 2020. It is now read-only.

Commit 4031d7c

Browse files
authored
Merge pull request #179 from dev-sec/remove_weak
update config of kex, macs, ciphers
2 parents 8e6ff59 + 638949f commit 4031d7c

File tree

4 files changed

+16
-72
lines changed

4 files changed

+16
-72
lines changed

README.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ Warning: This role disables root-login on the target server! Please make sure yo
1818
| Name | Default Value | Description |
1919
| -------------- | ------------- | -----------------------------------|
2020
|`network_ipv6_enable` | false |true if IPv6 is needed|
21-
|`ssh_client_cbc_required` | false |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.|
22-
|`ssh_server_cbc_required` | false |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.|
23-
|`ssh_client_weak_hmac` | false |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.|
24-
|`ssh_server_weak_hmac` | false |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.|
25-
|`ssh_client_weak_kex` | false |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.|
26-
|`ssh_server_weak_kex` | false |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.|
2721
|`ssh_server_ports` | ['22'] |ports on which ssh-server should listen|
2822
|`ssh_client_port` | '22' |port to which ssh-client should connect|
2923
|`ssh_listen_to` | ['0.0.0.0'] |one or more ip addresses, to which ssh-server should listen to. Default is all adresseses, but should be configured to specific addresses for security reasons!|
@@ -76,6 +70,9 @@ Warning: This role disables root-login on the target server! Please make sure yo
7670
|`ssh_use_dns` | `false` | Specifies whether sshd should look up the remote host name, and to check that the resolved host name for the remote IP address maps back to the very same IP address. |
7771
|`ssh_server_revoked_keys` | [] | a list of revoked public keys that the ssh server will always reject, useful to revoke known weak or compromised keys.|
7872
|`ssh_max_startups` | '10:30:100' | Specifies the maximum number of concurrent unauthenticated connections to the SSH daemon.|
73+
|`ssh_macs` | [] | Change this list to overwrite macs. Defaults found in `defaults/main.yml` |
74+
|`ssh_kex` | [] | Change this list to overwrite kexs. Defaults found in `defaults/main.yml` |
75+
|`ssh_ciphers` | [] | Change this list to overwrite ciphers. Defaults found in `defaults/main.yml` |
7976

8077
## Example Playbook
8178

@@ -149,8 +146,6 @@ Always look into log files first and if possible look at the negotation between
149146

150147
We have seen some issues in applications (based on python and ruby) that are due to their use of an outdated crypto set. This collides with this hardening module, which reduced the list of ciphers, message authentication codes (MACs) and key exchange (KEX) algorithms to a more secure selection.
151148

152-
If you find this isn't enough, feel free to activate the attributes `cbc_requires` for ciphers, `weak_hmac` for MACs and `weak_kex`for KEX in the variables `ssh_client` or `ssh_server` based on where you want to support them.
153-
154149
**After using the role Ansibles template/copy/file module does not work anymore!**
155150

156151
This role by default deactivates SFTP. Ansible uses by default SFTP to transfer files to the remote hosts. You have to set `scp_if_ssh = True` in your ansible.cfg. This way Ansible uses SCP to copy files. Alternatively you can enable SFTP again by setting `sftp_enabled` to `true`.

defaults/main.yml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,6 @@ ssh_compression: false # sshd
1414
ssh_client_hardening: true # ssh
1515
ssh_server_hardening: true # sshd
1616

17-
# 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.
18-
ssh_client_cbc_required: false # ssh
19-
ssh_server_cbc_required: false # sshd
20-
21-
# 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.
22-
ssh_client_weak_hmac: false # ssh
23-
ssh_server_weak_hmac: false # sshd
24-
25-
# 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.
26-
ssh_client_weak_kex: false # ssh
27-
ssh_server_weak_kex: false # sshd
28-
2917
# If true, password login is allowed
3018
ssh_client_password_login: false # ssh
3119
ssh_server_password_login: false # sshd
@@ -184,8 +172,6 @@ ssh_macs_59_default:
184172
- hmac-sha2-256
185173
- hmac-ripemd160
186174

187-
ssh_macs_59_weak: "{{ ssh_macs_59_default + ['hmac-sha1'] }}"
188-
189175
ssh_macs_66_default:
190176
191177
@@ -200,15 +186,11 @@ ssh_macs_76_default:
200186
- hmac-sha2-512
201187
- hmac-sha2-256
202188

203-
ssh_macs_66_weak: "{{ ssh_macs_66_default + ['hmac-sha1'] }}"
204-
205189
ssh_ciphers_53_default:
206190
- aes256-ctr
207191
- aes192-ctr
208192
- aes128-ctr
209193

210-
ssh_ciphers_53_weak: "{{ ssh_ciphers_53_default + ['aes256-cbc', 'aes192-cbc', 'aes128-cbc'] }}"
211-
212194
ssh_ciphers_66_default:
213195
214196
@@ -217,19 +199,13 @@ ssh_ciphers_66_default:
217199
- aes192-ctr
218200
- aes128-ctr
219201

220-
ssh_ciphers_66_weak: "{{ ssh_ciphers_66_default + ['aes256-cbc', 'aes192-cbc', 'aes128-cbc'] }}"
221-
222202
ssh_kex_59_default:
223203
- diffie-hellman-group-exchange-sha256
224204

225-
ssh_kex_59_weak: "{{ ssh_kex_59_default + ['diffie-hellman-group14-sha1', 'diffie-hellman-group-exchange-sha1', 'diffie-hellman-group1-sha1'] }}"
226-
227205
ssh_kex_66_default:
228206
229207
- diffie-hellman-group-exchange-sha256
230208

231-
ssh_kex_66_weak: "{{ ssh_kex_66_default + ['diffie-hellman-group14-sha1', 'diffie-hellman-group-exchange-sha1', 'diffie-hellman-group1-sha1'] }}"
232-
233209
# directory where to store ssh_password policy
234210
ssh_custom_selinux_dir: '/etc/selinux/local-policies'
235211

tasks/crypto.yml

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,16 @@
1717

1818
###
1919

20-
- name: set weak macs according to openssh-version if openssh >= 7.6
20+
- name: set macs according to openssh-version if openssh >= 7.6
2121
set_fact:
2222
ssh_macs: '{{ ssh_macs_76_default }}'
2323
when: sshd_version.stdout >= '7.6' and not ssh_macs
2424

25-
- name: set weak macs according to openssh-version if openssh >= 6.6
26-
set_fact:
27-
ssh_macs: '{{ ssh_macs_66_weak }}'
28-
when: sshd_version.stdout >= '6.6' and ssh_server_weak_hmac and not ssh_macs
29-
3025
- name: set macs according to openssh-version if openssh >= 6.6
3126
set_fact:
3227
ssh_macs: '{{ ssh_macs_66_default }}'
3328
when: sshd_version.stdout >= '6.6' and not ssh_macs
3429

35-
- name: set weak macs according to openssh-version
36-
set_fact:
37-
ssh_macs: '{{ ssh_macs_59_weak }}'
38-
when: sshd_version.stdout >= '5.9' and ssh_server_weak_hmac and not ssh_macs
39-
4030
- name: set macs according to openssh-version
4131
set_fact:
4232
ssh_macs: '{{ ssh_macs_59_default }}'
@@ -47,50 +37,25 @@
4737
ssh_macs: '{{ ssh_macs_53_default }}'
4838
when: sshd_version.stdout >= '5.3' and not ssh_macs
4939

50-
- name: set macs according to openssh-version
51-
set_fact:
52-
ssh_macs: '{{ ssh_macs_53_default }}'
53-
when: sshd_version.stdout >= '5.3' and not ssh_macs
54-
5540
###
5641

57-
- name: set weak ciphers according to openssh-version if openssh >= 6.6
58-
set_fact:
59-
ssh_ciphers: '{{ ssh_ciphers_66_weak }}'
60-
when: sshd_version.stdout >= '6.6' and ssh_server_cbc_required and not ssh_ciphers
61-
6242
- name: set ciphers according to openssh-version if openssh >= 6.6
6343
set_fact:
6444
ssh_ciphers: '{{ ssh_ciphers_66_default }}'
6545
when: sshd_version.stdout >= '6.6' and not ssh_ciphers
6646

67-
- name: set weak ciphers according to openssh-version
68-
set_fact:
69-
ssh_ciphers: '{{ ssh_ciphers_53_weak }}'
70-
when: sshd_version.stdout >= '5.3' and ssh_server_cbc_required and not ssh_ciphers
71-
7247
- name: set ciphers according to openssh-version
7348
set_fact:
7449
ssh_ciphers: '{{ ssh_ciphers_53_default }}'
7550
when: sshd_version.stdout >= '5.3' and not ssh_ciphers
7651

7752
###
7853

79-
- name: set weak kex according to openssh-version if openssh >= 6.6
80-
set_fact:
81-
ssh_kex: '{{ ssh_kex_66_weak }}'
82-
when: sshd_version.stdout >= '6.6' and ssh_server_weak_hmac and not ssh_kex
83-
8454
- name: set kex according to openssh-version if openssh >= 6.6
8555
set_fact:
8656
ssh_kex: '{{ ssh_kex_66_default }}'
8757
when: sshd_version.stdout >= '6.6' and not ssh_kex
8858

89-
- name: set weak kex according to openssh-version
90-
set_fact:
91-
ssh_kex: '{{ ssh_kex_59_weak }}'
92-
when: sshd_version.stdout >= '5.9' and ssh_server_weak_hmac and not ssh_kex
93-
9459
- name: set kex according to openssh-version
9560
set_fact:
9661
ssh_kex: '{{ ssh_kex_59_default }}'

tests/default_custom.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
ssh_client_alive_interval: 100
3030
ssh_client_alive_count: 10
3131
ssh_client_password_login: true
32-
ssh_client_cbc_required: true
33-
ssh_client_weak_kex: true
3432
ssh_challengeresponseauthentication: true
3533
ssh_compression: true
3634
ssh_allow_users: 'root kitchen vagrant'
@@ -44,10 +42,9 @@
4442
ssh_print_last_log: true
4543
ssh_banner: true
4644
ssh_server_password_login: true
47-
ssh_server_weak_hmac: true
4845
sftp_enabled: true
4946
sftp_chroot: true
50-
ssh_server_enabled: false
47+
#ssh_server_enabled: false
5148
ssh_server_match_group:
5249
- group: 'root'
5350
rules: 'AllowTcpForwarding yes'
@@ -68,3 +65,14 @@
6865
ssh_authorized_principals_file: '/etc/ssh/auth_principals/%u'
6966
ssh_authorized_principals :
7067
- { path: '/etc/ssh/auth_principals/root', principals: [ 'root' ], owner: "{{ ssh_owner }}", group: "{{ ssh_group }}", directoryowner: "{{ ssh_owner }}", directorygroup: "{{ ssh_group}}" }
68+
ssh_macs:
69+
- hmac-sha2-512
70+
- hmac-sha2-256
71+
ssh_ciphers:
72+
- aes256-ctr
73+
- aes192-ctr
74+
- aes128-ctr
75+
- aes256-cbc
76+
ssh_kex:
77+
- diffie-hellman-group-exchange-sha256
78+
- diffie-hellman-group-exchange-sha1

0 commit comments

Comments
 (0)