Skip to content

Commit dfdd193

Browse files
authored
Merge pull request #12721 from mpurg/ubuntu2404_cis_5.4.2.6
Implement rule accounts_umask_root
2 parents f6ac5a4 + 9d9eee2 commit dfdd193

File tree

15 files changed

+85
-2
lines changed

15 files changed

+85
-2
lines changed

components/bash.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ packages:
33
- bash
44
rules:
55
- accounts_umask_etc_bashrc
6+
- accounts_umask_root

components/pam.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ rules:
9292
- accounts_umask_etc_login_defs
9393
- accounts_umask_etc_profile
9494
- accounts_umask_interactive_users
95+
- accounts_umask_root
9596
- accounts_user_dot_group_ownership
9697
- accounts_user_dot_no_world_writable_programs
9798
- accounts_user_dot_user_ownership

controls/cis_ubuntu2404.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,8 +2167,9 @@ controls:
21672167
levels:
21682168
- l1_server
21692169
- l1_workstation
2170-
status: planned
2171-
notes: TODO. Rule does not seem to be implemented, nor does it map to any rules in ubuntu2204 profile.
2170+
rules:
2171+
- accounts_umask_root
2172+
status: automated
21722173

21732174
- id: 5.4.2.7
21742175
title: Ensure system accounts do not have a valid login shell (Automated)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# platform = multi_platform_all
2+
3+
sed -i -E -e "s/^([^#]*\bumask)[[:space:]]+[[:digit:]]+/\1 0027/g" /root/.bashrc /root/.profile
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<def-group>
2+
<definition class="compliance" id="{{{ rule_id }}}" version="1">
3+
{{{ oval_metadata("The umask for root user of the bash shell") }}}
4+
<criteria operator="AND">
5+
<criterion test_ref="tst_{{{ rule_id }}}" />
6+
</criteria>
7+
</definition>
8+
9+
<ind:textfilecontent54_object id="obj_{{{ rule_id }}}"
10+
comment="Umask value from /root/.bashrc and /root/.profile" version="1">
11+
<ind:filepath operation="pattern match">^(/root/.bashrc|/root/.profile)$</ind:filepath>
12+
<ind:pattern operation="pattern match">^[^#]*\bumask\s+[0-7]?[0-7]([0-1][0-7]|[0-7][0-6])\s*$</ind:pattern>
13+
<ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
14+
</ind:textfilecontent54_object>
15+
16+
<ind:textfilecontent54_test id="tst_{{{ rule_id }}}" check="all" check_existence="none_exist"
17+
comment="Test that no umask with lenient permissions exists" version="1">
18+
<ind:object object_ref="obj_{{{ rule_id }}}"/>
19+
</ind:textfilecontent54_test>
20+
21+
</def-group>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
documentation_complete: true
2+
3+
title: 'Ensure the Root Bash Umask is Set Correctly'
4+
5+
description: |-
6+
To ensure the root user's umask of the Bash shell is set properly,
7+
add or correct the <tt>umask</tt> setting in <tt>/root/.bashrc</tt>
8+
or <tt>/root/.bashrc</tt> to read as follows:
9+
<pre>umask 0027</pre>
10+
11+
rationale: |-
12+
The umask value influences the permissions assigned to files when they are created.
13+
A misconfigured umask value could result in files with excessive permissions that can be read or
14+
written to by unauthorized users.
15+
16+
severity: medium
17+
18+
platform: package[bash]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
sed '/umask/d' -i /root/.bashrc /root/.profile
4+
echo "# umask 0022" >> /root/.bashrc
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
sed '/umask/d' -i /root/.bashrc /root/.profile
4+
echo "umask 0027" >> /root/.bashrc
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
sed '/umask/d' -i /root/.bashrc /root/.profile
4+
echo "umask 0027" >> /root/.profile
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
sed '/umask/d' -i /root/.bashrc /root/.profile
4+
echo "umask 0022" >> /root/.profile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
sed '/umask/d' -i /root/.bashrc /root/.profile
4+
echo "umask 0017" >> /root/.profile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
sed '/umask/d' -i /root/.bashrc /root/.profile
4+
echo "umask 0000" >> /root/.bashrc
5+
echo "umask 0027" >> /root/.profile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
sed '/umask/d' -i /root/.bashrc /root/.profile
4+
echo "umask 022" >> /root/.profile
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
sed '/umask/d' -i /root/.bashrc /root/.profile
4+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
sed '/umask/d' -i /root/.bashrc /root/.profile
4+
echo "umask 0777" >> /root/.profile

0 commit comments

Comments
 (0)