diff --git a/components/chrony.yml b/components/chrony.yml index ca380358021..cffe68f8cb4 100644 --- a/components/chrony.yml +++ b/components/chrony.yml @@ -17,3 +17,4 @@ rules: - chronyd_no_chronyc_network - chronyd_or_ntpd_specify_multiple_servers - chronyd_sync_clock +- service_chronyd_disabled diff --git a/components/ntp.yml b/components/ntp.yml index ef4ae2efac4..22c94f65fdc 100644 --- a/components/ntp.yml +++ b/components/ntp.yml @@ -22,15 +22,18 @@ rules: - ntpd_run_as_ntp_user - ntpd_specify_multiple_servers - ntpd_specify_remote_server +- ntp_single_service_active - package_chrony_installed - package_ntp_installed - package_ntp_removed - package_timesyncd_installed - package_timesyncd_removed - service_chronyd_enabled +- service_chronyd_disabled - service_chronyd_or_ntpd_enabled - service_ntp_enabled - service_ntpd_enabled - service_timesyncd_enabled +- service_timesyncd_disabled - service_timesyncd_configured - service_timesyncd_root_distance_configured diff --git a/components/systemd.yml b/components/systemd.yml index fef59d38de7..82f86d71e8b 100644 --- a/components/systemd.yml +++ b/components/systemd.yml @@ -35,6 +35,7 @@ rules: - service_timesyncd_configured - service_timesyncd_root_distance_configured - service_timesyncd_enabled +- service_timesyncd_disabled - socket_systemd-journal-remote_disabled - systemd_tmp_mount_enabled - systemd_journal_upload_server_tls diff --git a/controls/cis_ubuntu2404.yml b/controls/cis_ubuntu2404.yml index a50874b1fdf..9487c00323e 100644 --- a/controls/cis_ubuntu2404.yml +++ b/controls/cis_ubuntu2404.yml @@ -939,12 +939,9 @@ controls: levels: - l1_server - l1_workstation - related_rules: - - package_chrony_installed - - package_ntp_installed - - package_timesyncd_installed - status: planned - notes: TODO. Partial/incorrect implementation exists.See related rules. Analogous to ubuntu2204/2.1.1.1. + rules: + - ntp_single_service_active + status: automated - id: 2.3.2.1 title: Ensure systemd-timesyncd configured with authorized timeserver (Automated) @@ -962,6 +959,7 @@ controls: - l1_server - l1_workstation rules: + - service_chronyd_disabled - service_timesyncd_enabled status: automated @@ -995,7 +993,8 @@ controls: - l1_server - l1_workstation rules: - - service_chronyd_enabled + - "!service_chronyd_enabled" + - "!service_timesyncd_disabled" status: automated - id: 2.4.1.1 diff --git a/linux_os/guide/services/ntp/ntp_single_service_active/oval/shared.xml b/linux_os/guide/services/ntp/ntp_single_service_active/oval/shared.xml new file mode 100644 index 00000000000..c18d8a766e5 --- /dev/null +++ b/linux_os/guide/services/ntp/ntp_single_service_active/oval/shared.xml @@ -0,0 +1,47 @@ + + + + {{{ oval_metadata("Ensure a Single Time Synchronization Service is in Use") }}} + + + + + + + + ^(chrony|systemd-timesyncd).service$ + ActiveState + ste_{{{ rule_id }}}_timesync_services + + + + active + + + + + + + + + + + + + + + + + + + var_{{{ rule_id }}}_timesync_active_count + + + + 1 + + diff --git a/linux_os/guide/services/ntp/ntp_single_service_active/rule.yml b/linux_os/guide/services/ntp/ntp_single_service_active/rule.yml new file mode 100644 index 00000000000..1a55b10f63c --- /dev/null +++ b/linux_os/guide/services/ntp/ntp_single_service_active/rule.yml @@ -0,0 +1,33 @@ +documentation_complete: true + +title: 'Ensure a Single Time Synchronization Service is in Use' + +description: |- + The system must have exactly one active time synchronization service to avoid conflicts + and ensure consistent time synchronization. Only one of the following services should be + enabled and active at any time: + + Having zero active time synchronization services leaves the system without accurate + time synchronization, while having multiple active services can lead to unexpected and + unreliable results. + +rationale: |- + Running multiple time synchronization services simultaneously can lead to conflicts + in time synchronization, unpredictable behavior, and unreliable results. A single service + ensures consistent and accurate time synchronization. + + Having no active time synchronization service leaves the system without accurate + time synchronization, which can affect security mechanisms, log consistency, and forensic + investigations. + +severity: medium + +platform: machine + +warnings: + - general: |- + This rule does not come with a remediation. There are specific rules + for enabling each time synchronization service, which should be used instead. diff --git a/linux_os/guide/services/ntp/ntp_single_service_active/tests/multiple.fail.sh b/linux_os/guide/services/ntp/ntp_single_service_active/tests/multiple.fail.sh new file mode 100644 index 00000000000..ed754b0dace --- /dev/null +++ b/linux_os/guide/services/ntp/ntp_single_service_active/tests/multiple.fail.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# remediation = none + +{{{ bash_package_install("chrony") }}} +{{{ bash_package_install("systemd-timesyncd") }}} + +systemctl stop chrony.service +systemctl stop systemd-timesyncd.service +systemctl disable chrony.service +systemctl disable systemd-timesyncd.service + +systemctl start chrony.service +systemctl start systemd-timesyncd.service +systemctl enable chrony.service +systemctl enable systemd-timesyncd.service diff --git a/linux_os/guide/services/ntp/ntp_single_service_active/tests/none.fail.sh b/linux_os/guide/services/ntp/ntp_single_service_active/tests/none.fail.sh new file mode 100644 index 00000000000..c88e31fa5e3 --- /dev/null +++ b/linux_os/guide/services/ntp/ntp_single_service_active/tests/none.fail.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# remediation = none + +{{{ bash_package_install("chrony") }}} +{{{ bash_package_install("systemd-timesyncd") }}} + +systemctl stop chrony.service +systemctl stop systemd-timesyncd.service +systemctl disable chrony.service +systemctl disable systemd-timesyncd.service diff --git a/linux_os/guide/services/ntp/ntp_single_service_active/tests/single.pass.sh b/linux_os/guide/services/ntp/ntp_single_service_active/tests/single.pass.sh new file mode 100644 index 00000000000..e989b0d7820 --- /dev/null +++ b/linux_os/guide/services/ntp/ntp_single_service_active/tests/single.pass.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# remediation = none + +{{{ bash_package_install("chrony") }}} +{{{ bash_package_install("systemd-timesyncd") }}} + +systemctl stop chrony.service +systemctl stop systemd-timesyncd.service +systemctl disable chrony.service +systemctl disable systemd-timesyncd.service + +systemctl start chrony.service +systemctl enable chrony.service diff --git a/linux_os/guide/services/ntp/service_chronyd_disabled/rule.yml b/linux_os/guide/services/ntp/service_chronyd_disabled/rule.yml new file mode 100644 index 00000000000..58733e2ec9e --- /dev/null +++ b/linux_os/guide/services/ntp/service_chronyd_disabled/rule.yml @@ -0,0 +1,23 @@ +documentation_complete: true + +title: 'The Chronyd service is disabled' + +description: |- + {{{ describe_service_disable(service="chrony") }}} + +rationale: |- + Disabling the chrony service ensures that there is + only single one time service running. + +severity: medium + +platform: package[chrony] + +template: + name: service_disabled + vars: + packagename: chrony + servicename: chronyd + servicename@ubuntu2004: chrony + servicename@ubuntu2204: chrony + servicename@debian12: chrony diff --git a/linux_os/guide/services/ntp/service_timesyncd_disabled/rule.yml b/linux_os/guide/services/ntp/service_timesyncd_disabled/rule.yml new file mode 100644 index 00000000000..4128dcd2104 --- /dev/null +++ b/linux_os/guide/services/ntp/service_timesyncd_disabled/rule.yml @@ -0,0 +1,25 @@ +documentation_complete: true + + +title: 'Disable systemd_timesyncd Service' + +description: |- + {{{ describe_service_disable(service="systemd_timesyncd") }}} + +rationale: |- + Disabling the systemd_timesyncd service ensures that there is + only single one time service running. +

+ Additional information on Ubuntu network time protocol is + available at + {{{ weblink(link="https://ubuntu.com/server/docs/about-time-synchronisation") }}}. + +severity: medium + +platform: package[systemd-timesyncd] + +template: + name: service_disabled + vars: + servicename: systemd-timesyncd + packagename: systemd-timesyncd diff --git a/shared/applicability/package.yml b/shared/applicability/package.yml index 1a7cc04afbf..d2e7b75f5d7 100644 --- a/shared/applicability/package.yml +++ b/shared/applicability/package.yml @@ -118,6 +118,8 @@ args: pkgname: sudo systemd: pkgname: systemd + systemd-timesyncd: + pkgname: systemd-timesyncd telnet-server: pkgname: telnet-server tftp-server: