|
1 | 1 | # encoding: utf-8 |
2 | 2 | # check-messaging |
3 | 3 | # http://docs.openstack.org/security-guide/messaging.html |
| 4 | + |
| 5 | +RABBITMQ_CONF_DIR = attribute( |
| 6 | + 'rabbitmq_conf_dir', |
| 7 | + description: 'Path to rabbitmq configuration folder', |
| 8 | + default: '/etc/rabbitmq' |
| 9 | +) |
| 10 | + |
| 11 | +RABBITMQ_CONF_FILE = attribute( |
| 12 | + 'rabbitmq_conf_file', |
| 13 | + description: 'Path to rabbitmq configuration file', |
| 14 | + default: '/etc/rabbitmq/rabbitmq.config' |
| 15 | +) |
| 16 | + |
| 17 | +TLSCACERT = attribute( |
| 18 | + 'tlscacert', |
| 19 | + description: 'Trust certificates which is signed only by this CA', |
| 20 | + default: '/etc/ssl/testca/cacert.pem' |
| 21 | +) |
| 22 | + |
| 23 | +TLSCERT = attribute( |
| 24 | + 'tlscert', |
| 25 | + description: 'Rabbitmq server certificate', |
| 26 | + default: '/etc/ssl/server/cert.pem' |
| 27 | +) |
| 28 | + |
| 29 | +TLSKEY = attribute( |
| 30 | + 'tlskey', |
| 31 | + description: 'Rabbitmq server key', |
| 32 | + default: '/etc/ssl/server/key.pem' |
| 33 | +) |
| 34 | + |
| 35 | +TLSPORT = attribute( |
| 36 | + 'tlsport', |
| 37 | + description: 'Specify rabbitmq tls server port', |
| 38 | + default: '5671' |
| 39 | +) |
| 40 | + |
| 41 | +control 'check-messaging-01' do |
| 42 | + title 'Check Rabbitmq config folder and file owner, group and permissions.' |
| 43 | + desc 'Rabbitmq config files should be owned by root user and root group' |
| 44 | + ref 'Rabbitmq Security', url: 'https://docs.openstack.org/security-guide/messaging/security.html' |
| 45 | + |
| 46 | + describe file(RABBITMQ_CONF_DIR) do |
| 47 | + it { should exist } |
| 48 | + it { should be_directory } |
| 49 | + it { should be_owned_by 'root' } |
| 50 | + it { should be_grouped_into 'root' } |
| 51 | + it { should be_readable.by('owner') } |
| 52 | + it { should be_readable.by('group') } |
| 53 | + it { should be_readable.by('other') } |
| 54 | + it { should be_executable.by('owner') } |
| 55 | + it { should be_executable.by('group') } |
| 56 | + it { should be_executable.by('other') } |
| 57 | + it { should be_writable.by('owner') } |
| 58 | + it { should_not be_writable.by('group') } |
| 59 | + it { should_not be_writable.by('other') } |
| 60 | + end |
| 61 | + |
| 62 | + describe file(RABBITMQ_CONF_FILE) do |
| 63 | + it { should exist } |
| 64 | + it { should be_file } |
| 65 | + it { should be_owned_by 'root' } |
| 66 | + it { should be_grouped_into 'root' } |
| 67 | + it { should_not be_executable } |
| 68 | + it { should be_readable.by('owner') } |
| 69 | + it { should be_readable.by('group') } |
| 70 | + it { should be_readable.by('other') } |
| 71 | + it { should be_writable.by('owner') } |
| 72 | + it { should_not be_writable.by('group') } |
| 73 | + it { should_not be_writable.by('other') } |
| 74 | + end |
| 75 | +end |
| 76 | + |
| 77 | +control 'check-messaging-02' do |
| 78 | + title 'Rabbitmq should listen only on ssl port' |
| 79 | + desc 'The tcp_listeners option is set to [] to prevent it from listening on a non-SSL port.' |
| 80 | + ref 'Rabbitmq Security', url: 'https://docs.openstack.org/security-guide/messaging/security.html' |
| 81 | + |
| 82 | + describe rabbitmq_config.params('rabbit', 'tcp_listeners') do |
| 83 | + it { should be_empty } |
| 84 | + end |
| 85 | + describe rabbitmq_config.params('rabbit', 'ssl_listeners') do |
| 86 | + it { should cmp TLSPORT } |
| 87 | + end |
| 88 | +end |
| 89 | + |
| 90 | +control 'check-messaging-03' do |
| 91 | + title 'Check rabbitmq SSL certificate configuration' |
| 92 | + desc 'Check if the correct ca and server certificate implemented and server key. The rabbitmq server should also check the client certificates.' |
| 93 | + ref 'Rabbitmq Security', url: 'https://docs.openstack.org/security-guide/messaging/security.html' |
| 94 | + |
| 95 | + describe rabbitmq_config.params('rabbit','ssl_options','cacertfile') do |
| 96 | + it { should cmp TLSCACERT } |
| 97 | + end |
| 98 | + describe rabbitmq_config.params('rabbit','ssl_options','certfile') do |
| 99 | + it { should cmp TLSCERT } |
| 100 | + end |
| 101 | + describe rabbitmq_config.params('rabbit','ssl_options','keyfile') do |
| 102 | + it { should cmp TLSKEY } |
| 103 | + end |
| 104 | +end |
| 105 | + |
| 106 | +control 'check-messaging-04' do |
| 107 | + title 'Check rabbitmq check peer certificates' |
| 108 | + desc 'Rabbitmq should verify the certificates from the clients and if the server does not receive a valid certificate it should not allow the connection from the client.' |
| 109 | + ref 'Rabbitmq Security', url: 'https://docs.openstack.org/security-guide/messaging/security.html' |
| 110 | + |
| 111 | + describe rabbitmq_config.params('rabbit','ssl_options','verify') do |
| 112 | + it { should cmp 'verify_peer' } |
| 113 | + end |
| 114 | + describe rabbitmq_config.params('rabbit','ssl_options','fail_if_no_peer_cert') do |
| 115 | + it { should cmp 'true' } |
| 116 | + end |
| 117 | +end |
| 118 | + |
| 119 | +control 'check-messaging-05' do |
| 120 | + title 'Check rabbitmq use only TLSv1.2' |
| 121 | + desc 'Rabbitmq should only use TLSv1.2.' |
| 122 | + ref 'Rabbitmq Security', url: 'https://docs.openstack.org/security-guide/messaging/security.html' |
| 123 | + |
| 124 | + describe rabbitmq_config.params('ssl','versions') do |
| 125 | + it { should cmp 'tlsv1.2' } |
| 126 | + end |
| 127 | + describe rabbitmq_config.params('rabbit','ssl_options','versions') do |
| 128 | + it { should cmp 'tlsv1.2' } |
| 129 | + end |
| 130 | +end |
| 131 | + |
| 132 | +control 'check-messaging-06' do |
| 133 | + title 'Check for strong ciphers' |
| 134 | + desc 'Use only strong ciphers for the rabbitmq TLSv1.2 connection.' |
| 135 | + ref 'BSI recommendation', url: 'https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102-2.pdf;jsessionid=30F658ACD2A772B0A2430C4DEC4AF7D1.1_cid341?__blob=publicationFile&v=4' |
| 136 | + ref 'Mozilla recommendation', url: 'https://wiki.mozilla.org/Security/Server_Side_TLS#Modern_compatibility' |
| 137 | + |
| 138 | + describe rabbitmq_config.params('rabbit','ssl_options','ciphers') do |
| 139 | + it { should eq [["ecdhe_ecdsa", "aes_256_gcm", "null", "sha384"], ["ecdhe_rsa", "aes_256_gcm", "null", "sha384"], ["ecdhe_ecdsa", "aes_128_gcm", "null", "sha256"], ["ecdhe_rsa", "aes_128_gcm", "null", "sha256"]] } |
| 140 | + end |
| 141 | +end |
| 142 | + |
| 143 | +control 'check-messaging-07' do |
| 144 | + title 'Check for tls cipher honor order' |
| 145 | + desc 'The rabbitmq server should force the tls cipher order' |
| 146 | + |
| 147 | + describe rabbitmq_config.params('rabbit','ssl_options','honor_cipher_order') do |
| 148 | + it { should eq true } |
| 149 | + end |
| 150 | +end |
0 commit comments