-
Notifications
You must be signed in to change notification settings - Fork 708
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12823 from alanmcanonical/ubt24_2311
Ubuntu 24.04: Implement 2.3.1.1 Ensure a single time synchronization daemon is in use
- Loading branch information
Showing
12 changed files
with
179 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
linux_os/guide/services/ntp/ntp_single_service_active/oval/shared.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<def-group> | ||
<!-- Check that exactly one time synchronization service is active --> | ||
<definition class="compliance" id="{{{ rule_id }}}" version="1"> | ||
{{{ oval_metadata("Ensure a Single Time Synchronization Service is in Use") }}} | ||
<criteria> | ||
<criterion comment="exactly one time synchronization service is active" | ||
test_ref="test_{{{ rule_id }}}_single_active_timesync"/> | ||
</criteria> | ||
</definition> | ||
|
||
<!-- Objects and states to identify active time synchronization services --> | ||
<linux:systemdunitproperty_object id="obj_{{{ rule_id }}}_timesync_services" version="1" | ||
comment="All active time synchronization services"> | ||
<linux:unit operation="pattern match">^(chrony|systemd-timesyncd).service$</linux:unit> | ||
<linux:property>ActiveState</linux:property> | ||
<filter action="include">ste_{{{ rule_id }}}_timesync_services</filter> | ||
</linux:systemdunitproperty_object> | ||
|
||
<linux:systemdunitproperty_state id="ste_{{{ rule_id }}}_timesync_services" version="1"> | ||
<linux:value>active</linux:value> | ||
</linux:systemdunitproperty_state> | ||
|
||
<!-- Count active time synchronization services --> | ||
<local_variable id="var_{{{ rule_id }}}_timesync_active_count" datatype="int" version="1" | ||
comment="Number of currently active time synchronization services"> | ||
<count> | ||
<regex_capture pattern="^active$"> | ||
<object_component item_field="value" object_ref="obj_{{{ rule_id }}}_timesync_services"/> | ||
</regex_capture> | ||
</count> | ||
</local_variable> | ||
|
||
<!-- Test that count equals one --> | ||
<ind:variable_test id="test_{{{ rule_id }}}_single_active_timesync" version="1" check="all" | ||
comment="Verify exactly one time synchronization service is active"> | ||
<ind:object object_ref="obj_{{{ rule_id }}}_count"/> | ||
<ind:state state_ref="ste_{{{ rule_id }}}_count"/> | ||
</ind:variable_test> | ||
|
||
<ind:variable_object id="obj_{{{ rule_id }}}_count" version="1"> | ||
<ind:var_ref>var_{{{ rule_id }}}_timesync_active_count</ind:var_ref> | ||
</ind:variable_object> | ||
|
||
<ind:variable_state id="ste_{{{ rule_id }}}_count" version="1"> | ||
<ind:value operation="equals" datatype="int">1</ind:value> | ||
</ind:variable_state> | ||
</def-group> |
33 changes: 33 additions & 0 deletions
33
linux_os/guide/services/ntp/ntp_single_service_active/rule.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: | ||
<ul> | ||
<li>chrony - A versatile NTP implementation</li> | ||
<li>systemd-timesyncd - A lightweight NTP client</li> | ||
</ul> | ||
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. |
15 changes: 15 additions & 0 deletions
15
linux_os/guide/services/ntp/ntp_single_service_active/tests/multiple.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
10 changes: 10 additions & 0 deletions
10
linux_os/guide/services/ntp/ntp_single_service_active/tests/none.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
13 changes: 13 additions & 0 deletions
13
linux_os/guide/services/ntp/ntp_single_service_active/tests/single.pass.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
23 changes: 23 additions & 0 deletions
23
linux_os/guide/services/ntp/service_chronyd_disabled/rule.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
documentation_complete: true | ||
|
||
title: 'The Chronyd service is disabled' | ||
|
||
description: |- | ||
{{{ describe_service_disable(service="chrony") }}} | ||
rationale: |- | ||
Disabling the <tt>chrony</tt> 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 |
25 changes: 25 additions & 0 deletions
25
linux_os/guide/services/ntp/service_timesyncd_disabled/rule.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
documentation_complete: true | ||
|
||
|
||
title: 'Disable systemd_timesyncd Service' | ||
|
||
description: |- | ||
{{{ describe_service_disable(service="systemd_timesyncd") }}} | ||
rationale: |- | ||
Disabling the <tt>systemd_timesyncd</tt> service ensures that there is | ||
only single one time service running. | ||
<br /><br /> | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters