Skip to content

Commit b528638

Browse files
authored
Merge pull request #13823 from alanmcanonical/root_pwd
[Ubuntu] Only allow password set for root on Ubuntu 2204
2 parents c6a4ed2 + aa17d59 commit b528638

3 files changed

Lines changed: 27 additions & 6 deletions

File tree

linux_os/guide/system/accounts/accounts-restrictions/root_logins/ensure_root_access_controlled/oval/shared.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
</ind:textfilecontent54_test>
1414
<ind:textfilecontent54_object id="obj_root_access_controlled_etc_shadow" version="1">
1515
<ind:filepath>/etc/shadow</ind:filepath>
16+
{{% if product == "ubuntu2204" %}}
17+
<ind:pattern operation="pattern match">^root:(\$(y|[0-9].+)\$).*$</ind:pattern>
18+
{{% else %}}
1619
<ind:pattern operation="pattern match">^root:(\$(y|[0-9].+)\$|!.*|\*.*).*$</ind:pattern>
20+
{{% endif %}}
1721
<ind:instance datatype="int">1</ind:instance>
1822
</ind:textfilecontent54_object>
1923
</def-group>

linux_os/guide/system/accounts/accounts-restrictions/root_logins/ensure_root_access_controlled/rule.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ documentation_complete: true
44
title: 'Ensure root account access is controlled'
55

66
description: |-
7-
There are a number of methods to access the root account directly.
8-
Without a password set any user would be able to gain access and
7+
There are a number of methods to access the root account directly.
8+
Without a password set any user would be able to gain access and
99
thus control over the entire system.
1010
1111
rationale: |-
@@ -14,22 +14,35 @@ rationale: |-
1414
severity: medium
1515

1616
platform: system_with_kernel
17-
17+
{{%- if product != "ubuntu2204" %}}
1818
ocil_clause: 'root password is not set or is not locked'
1919

2020
ocil: |-
2121
Run the following command to verify that either the root user's
2222
password is set or the root user's account is locked:
2323
<pre># passwd -S root | awk '$2 ~ /^(P|L)/ {print "User: \"" $1 "\" Password is status: " $2}'</pre>
24-
Verify the output is either:
24+
Verify the output is either:
2525
User: "root" Password is status: P
2626
- OR -
2727
User: "root" Password is status: L
2828
Note:
2929
- P - Password is set
3030
- L - Password is locked
31-
3231
3332
warnings:
3433
- general: This rule doesn't come with a remediation, as the exact requirement allows root to either have a password or be locked.
35-
34+
{{%- else %}}
35+
ocil_clause: 'root password is not set'
36+
37+
ocil: |-
38+
Run the following command to verify that the password is set for root:
39+
<pre># passwd -S root | awk '$2 ~ /^P/ {print "User: \"" $1 "\" Password is status: " $2}'</pre>
40+
Verify the output is: User: "root" Password is status: P
41+
Note:
42+
- P - Password is set
43+
44+
warnings:
45+
- general: This rule doesn't come with a remediation, as the exact requirement allows root to have a password.
46+
{{% endif %}}
47+
48+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/bin/bash
22
# packages = passwd
3+
{{% if product == 'ubuntu2204' %}}
4+
# platform = Not Applicable
5+
{{% else %}}
36
# platform = multi_platform_all
7+
{{% endif %}}
48
# remediation = none
59

610
passwd -d root

0 commit comments

Comments
 (0)