Skip to content

Commit addc64f

Browse files
committed
[Security] Disable unused background services: wpa_supplicant and cups.
Signed-off-by: Giacomo Marciani <[email protected]>
1 parent 51b2ec1 commit addc64f

File tree

4 files changed

+53
-22
lines changed

4 files changed

+53
-22
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This file is used to list changes made in each version of the AWS ParallelCluste
1212
- Add the configuration parameter `DeploymentSettings/DefaultUserHome` to allow users to move the default user's home directory to `/local/home` instead of `/home` (default).
1313
- SSH connections will be closed and rejected while the user's home directory is being moved during the bootstrapping process.
1414
- Add possibility to choose between Open and Closed Source Nvidia Drivers when building an AMI, through the ```['cluster']['nvidia']['kernel_open']``` cookbook node attribute.
15+
- Disable unused background services wpa_supplicant and cups to improve security.
1516

1617
**CHANGES**
1718
- Upgrade Slurm to 23.11.3 (from 23.02.7).

cookbooks/aws-parallelcluster-platform/recipes/install/disable_services.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,13 @@
2727
service 'log4j-cve-2021-44228-hotpatch' do
2828
action %i(disable stop mask)
2929
end unless on_docker?
30+
31+
# Necessary on Ubuntu and Amazon Linux 2
32+
service 'cups' do
33+
action %i(disable stop mask)
34+
end unless on_docker?
35+
36+
# Necessary on Ubuntu 22
37+
service 'wpa_supplicant' do
38+
action %i(disable stop mask)
39+
end unless on_docker?

cookbooks/aws-parallelcluster-platform/spec/unit/recipes/disable_services_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@
1818
is_expected.to stop_service('log4j-cve-2021-44228-hotpatch')
1919
is_expected.to mask_service('log4j-cve-2021-44228-hotpatch')
2020
end
21+
22+
it 'disables cups' do
23+
is_expected.to disable_service('cups')
24+
is_expected.to stop_service('cups')
25+
is_expected.to mask_service('cups')
26+
end
27+
28+
it 'disables wpa_supplicant' do
29+
is_expected.to disable_service('wpa_supplicant')
30+
is_expected.to stop_service('wpa_supplicant')
31+
is_expected.to mask_service('wpa_supplicant')
32+
end
2133
end
2234
end
2335
end

cookbooks/aws-parallelcluster-platform/test/controls/disable_services_spec.rb

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,46 @@
1010
# See the License for the specific language governing permissions and limitations under the License.
1111

1212
control 'tag:testami_tag:config_services_disabled_on_debian_family' do
13-
title 'Test that DLAMI multi eni helper is disabled and masked on debian family'
13+
services = %w(aws-ubuntu-eni-helper wpa_supplicant)
14+
15+
title "Test that #{services.join(',')} are disabled and masked on debian family"
1416

1517
only_if { os_properties.debian_family? && !os_properties.on_docker? }
1618

17-
describe service('aws-ubuntu-eni-helper') do
18-
it { should_not be_enabled }
19-
it { should_not be_running }
20-
end
19+
services.each do |service_name|
20+
describe service(service_name) do
21+
it { should_not be_enabled }
22+
it { should_not be_running }
23+
end
2124

22-
describe bash('systemctl list-unit-files --state=masked --no-legend') do
23-
its(:exit_status) { should eq 0 }
24-
its(:stdout) { should match /aws-ubuntu-eni-helper.service\s*masked/ }
25+
describe bash('systemctl list-unit-files --state=masked --no-legend') do
26+
its(:exit_status) { should eq 0 }
27+
its(:stdout) { should match /#{service_name}.service\s*masked/ }
28+
end
2529
end
2630
end
2731

2832
control 'tag:testami_tag:config_services_disabled_on_amazon_family' do
29-
title 'Test that log4j-cve-2021-44228-hotpatch is disabled and masked on amazon family'
33+
services = %w(log4j-cve-2021-44228-hotpatch cups)
3034

31-
only_if { os_properties.amazon_family? && !os_properties.on_docker? }
35+
title "Test that #{services.join(',')} are disabled and masked on amazon family"
3236

33-
describe service('log4j-cve-2021-44228-hotpatch') do
34-
it { should_not be_enabled }
35-
it { should_not be_running }
36-
end
37-
38-
describe bash('systemctl list-unit-files --state=masked --no-legend') do
39-
its(:exit_status) { should eq 0 }
40-
its(:stdout) { should match /log4j-cve-2021-44228-hotpatch.service\s*masked/ }
41-
end
37+
only_if { os_properties.amazon_family? && !os_properties.on_docker? }
4238

43-
describe bash('systemctl show -p LoadState log4j-cve-2021-44228-hotpatch') do
44-
its(:exit_status) { should eq 0 }
45-
its(:stdout) { should match /LoadState=masked/ }
39+
services.each do |service_name|
40+
describe service(service_name) do
41+
it { should_not be_enabled }
42+
it { should_not be_running }
43+
end
44+
45+
describe bash('systemctl list-unit-files --state=masked --no-legend') do
46+
its(:exit_status) { should eq 0 }
47+
its(:stdout) { should match /#{service_name}.service\s*masked/ }
48+
end
49+
50+
describe bash("systemctl show -p LoadState #{service_name}") do
51+
its(:exit_status) { should eq 0 }
52+
its(:stdout) { should match /LoadState=masked/ }
53+
end
4654
end
4755
end

0 commit comments

Comments
 (0)