forked from mondoohq/cnspec-policies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchef-infra-client.mql.yaml
208 lines (202 loc) · 9.38 KB
/
chef-infra-client.mql.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
policies:
- uid: chef-infra-client
name: Chef Infra Client Policy
version: 1.0.1
license: MPL-2.0
tags:
mondoo.com/category: security
mondoo.com/platform: linux,unix
authors:
- name: Tim Smith
email: [email protected]
docs:
desc: "Chef Infra Client Policy identifies insecure Chef Infra Client installations that could expose node credentials, as well as end of life client releases that no longer receive security updates per the [Chef Supported Versions documentation](https://docs.chef.io/versions/).\n \nIf you have questions, comments, or have identified ways to improve this policy, please write me at [email protected], or reach out in the [Mondoo Slack Community](https://mondoo.link/slack)."
groups:
- filters: |
platform.family.contains(_ == 'unix')
file("/opt/chef").exists
checks:
- uid: avoid-reporting-tokens-in-config
- uid: client-pem-permissions
- uid: client-rb-permissions
- uid: disable-legacy-encrypted-data-bags
- uid: etc-chef-directory-permissions
- uid: non-eol-infra-client
- uid: validation-pem-not-present
- uid: var-chef-directory-permissions
- uid: var-log-chef-directory-permissions
queries:
- uid: etc-chef-directory-permissions
title: Ensure /etc/chef/ is owned by root with 750 permissions
impact: 80
mql: |
if (file("/etc/chef").exists) {
file("/etc/chef") {
user.name == 'root'
permissions.user_readable == true
permissions.user_writeable == true
permissions.user_executable == true
permissions.group_readable == true
permissions.group_writeable == false
permissions.group_executable == true
permissions.other_readable == false
permissions.other_writeable == false
permissions.other_executable == false
}
}
docs:
desc: |
The /etc/chef directory contains sensitive files configuring Chef Infra Client and should only be writeable by root and readable by root and the root group.
remediation: |
Run the following commands to set proper permissions on your /etc/chef directory:
```
chown root:root /etc/chef
chmod 700 /etc/chef
```
- uid: var-chef-directory-permissions
title: Ensure /var/chef/ is owned by root with 750 permissions
impact: 80
mql: |
if (file("/var/chef").exists) {
file("/var/chef") {
user.name == 'root'
permissions.user_readable == true
permissions.user_writeable == true
permissions.user_executable == true
permissions.group_readable == true
permissions.group_writeable == false
permissions.group_executable == true
permissions.other_readable == false
permissions.other_writeable == false
permissions.other_executable == false
}
}
docs:
desc: |
The /var/chef directory contains sensitive system configuration backup files and cached remote_file downloads. It should only be writeable by root and readable by root and the root group.
remediation: |
Run the following commands to set proper permissions on your /var/chef directory:
```
chown root:root /var/chef
chmod 700 /var/chef
```
- uid: var-log-chef-directory-permissions
title: Ensure /var/log/chef/ is owned by root with 750 permissions
mql: |
if (file("/var/log/chef").exists) {
file("/var/log/chef") {
user.name == 'root'
permissions.user_readable == true
permissions.user_writeable == true
permissions.user_executable == true
permissions.group_readable == true
permissions.group_writeable == false
permissions.group_executable == true
permissions.other_readable == false
permissions.other_writeable == false
permissions.other_executable == false
}
}
docs:
desc: |
The /var/log/chef directory contains sensitive log files and should only be writeable by root and readable by root and the root group.
remediation: |
Run the following commands to set proper permissions on your /var/log/chef directory:
```
chown root:root /var/log/chef
chmod 700 /var/log/chef
```
- uid: client-rb-permissions
title: Ensure /etc/chef/client.rb is owned by root with 640 permissions
impact: 100
mql: |
if (file("/etc/chef/client.rb").exists) {
file("/etc/chef/client.rb") {
user.name == 'root'
permissions.user_readable == true
permissions.user_writeable == true
permissions.user_executable == false
permissions.group_readable == true
permissions.group_writeable == false
permissions.group_executable == false
permissions.other_readable == false
permissions.other_writeable == false
permissions.other_executable == false
}
}
docs:
desc: The /etc/chef/client.rb configuration file contains sensitive Infra Client configuration information. It should be owned by root and permissions should be set to 640.
remediation: |
Run the following commands to set proper permissions on your /etc/chef/client.rb file:
```
chown root:root /etc/chef/client.rb
chmod 640 /etc/chef/client.rb
```
- uid: client-pem-permissions
title: Ensure /etc/chef/client.pem is owned by root with 640 permissions
impact: 100
mql: |
if (file("/etc/chef/client.pem").exists) {
file("/etc/chef/client.pem") {
user.name == 'root'
permissions.user_readable == true
permissions.user_writeable == true
permissions.user_executable == false
permissions.group_readable == true
permissions.group_writeable == false
permissions.group_executable == false
permissions.other_readable == false
permissions.other_writeable == false
permissions.other_executable == false
}
}
docs:
desc: The /etc/chef/client.pem key file contains the key used to communicate with Chef Infra Server. It should be owned by root and permissions should be set to 640.
remediation: |
Run the following commands to set proper permissions on your /etc/chef/client.pem file:
```
chown root:root /etc/chef/client.pem
chmod 640 /etc/chef/client.pem
```
- uid: validation-pem-not-present
title: Ensure /etc/chef/validation.pem is not present
impact: 100
mql: |
file("/etc/chef/validation.pem").exists == "false"
docs:
desc: The /etc/chef/validation.pem file can be used to register any system with Chef Infra Server and should not be left on system after they are bootstrapped into the Chef Infra organization.
remediation: |
Run the following command to remove the validation.pem file:
```
rm /etc/chef/validation.pem
```
- uid: non-eol-infra-client
title: Ensure a non-EOL Chef Infra Client release is used
impact: 70
mql: |
command("chef-client -v") {
stdout == /^Chef Infra Client: (16|17|18|19|20|21).*/
}
docs:
desc: Chef Infra Client is released once a year in April and 2 major versions are supported at any time (N-1). Prior releases do not receive security updates and should not be used in production environments. See the [Chef Supported Versions documentation](https://docs.chef.io/versions/) for an up-to-date list of supported Infra Client releases.
remediation: Upgrade to a non-EOL release of Chef Infra Client. Note that this will require validation of cookbook content for compatibility as newer major version releases introduce breaking changes.
- uid: disable-legacy-encrypted-data-bags
title: Disable support for less secure Encrypted Data Bag versions
impact: 80
mql: |
if (file("/etc/chef/client.rb").exists) {
file("/etc/chef/client.rb").content.contains("data_bag_decrypt_minimum_version 3")
}
docs:
desc: Encrypted Data Bags v0, v1, and v2 are less secure than v3 and should not be used. See https://docs.chef.io/data_bags/#encryption-versions for more details on the encryption versions.
remediation: To set the Infra Client to only accept encrypted data bags v3 or above set `data_bag_decrypt_minimum_version 3` in the `client.rb` file.
- uid: avoid-reporting-tokens-in-config
title: Avoid storing Automate tokens in the client.rb config
impact: 70
mql: |
if (file("/etc/chef/client.rb").exists) {
file("/etc/chef/client.rb").content.contains("data_collector.token") == false
}
docs:
desc: When sending reporting data directly to Automate an Automate API token must be stored in the `client.rb` configuration file. Instead of setting the token, proxy Infra Client report data through the Infra Server so that the Automate API token only needs to be stored in the Infra Server.
remediation: See https://docs.chef.io/server/config_rb_server_optional_settings/#data_collector-14 for more information on configuring the Infra Server to proxy reporting data. Once the Infra Server has been configured for proxying you can set `data_collector.server_url` in client.rb to the URL of the Infra Server and remove the `data_collector.token` configuration.