-
Notifications
You must be signed in to change notification settings - Fork 717
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Completed /var/log group ownership checks
- Loading branch information
1 parent
7ae5cf4
commit 774da99
Showing
60 changed files
with
630 additions
and
32 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
13 changes: 13 additions & 0 deletions
13
linux_os/guide/system/permissions/files/groupowner_local_var_log/bash/shared.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 @@ | ||
# platform = Ubuntu 24.04 | ||
# reboot = false | ||
# strategy = configure | ||
# complexity = low | ||
# disruption = low | ||
|
||
if getent group "adm" >/dev/null 2>&1; then | ||
group="adm" | ||
else | ||
group="root" | ||
fi | ||
|
||
find -L /var/log/ -maxdepth 1 -regextype posix-extended ! -group root ! -group adm -name '*' ! -path '/var/log/apt/*' ! -name 'auth.log' ! -path '/var/log/[bw]tmp*' ! -path '/var/log/cloud-init.log*' ! -name 'gdm' ! -name 'gdm3' ! -regex '.*\.journal[~]?' ! -regex '.*lastlog(\.[^\/]+)?$' ! -regex '.*localmessages(.*)' ! -name 'messages' ! -regex '.*secure(.*)' ! -name 'sssd' ! -name 'syslog' ! -regex '.*waagent.log(.*)' -regex '.*' -exec chgrp $group {} \; |
87 changes: 87 additions & 0 deletions
87
linux_os/guide/system/permissions/files/groupowner_local_var_log/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,87 @@ | ||
<def-group> | ||
<definition class="compliance" id="{{{ rule_id }}}" version="1"> | ||
{{{ oval_metadata("Group owner of /var/log/* should be root or adm.") }}} | ||
<criteria comment="Check group ownership of /var/log/*"> | ||
<criterion test_ref="test_group_ownership_var_log" /> | ||
</criteria> | ||
</definition> | ||
|
||
<ind:textfilecontent54_object id="object_adm_gid" version="1" comment="gid of the dedicated adm group"> | ||
<ind:filepath>/etc/group</ind:filepath> | ||
<ind:pattern operation="pattern match">^adm:\w+:(\w+):.*</ind:pattern> | ||
<ind:instance datatype="int" operation="equals">1</ind:instance> | ||
</ind:textfilecontent54_object> | ||
<local_variable id="var_adm_gid" datatype="int" version="1" | ||
comment="Retrieve the gid of adm group"> | ||
<object_component item_field="subexpression" object_ref="object_adm_gid"/> | ||
</local_variable> | ||
|
||
<unix:file_test check="all" comment="/var/log/* group owner is root|adm" | ||
id="test_group_ownership_var_log" state_operator="OR" version="1"> | ||
<unix:object object_ref="object_group_ownership_var_log" /> | ||
<unix:state state_ref="state_group_ownership_adm_var_log_auth_log"/> | ||
<unix:state state_ref="state_group_ownership_root_var_log_auth_log"/> | ||
</unix:file_test> | ||
<unix:file_object comment="/var/log/*" id="object_group_ownership_var_log" version="1"> | ||
<unix:path>/var/log</unix:path> | ||
<unix:filename operation="pattern match">.*</unix:filename> | ||
<filter action="exclude">exclude_files_apt</filter> | ||
<filter action="exclude">exclude_files_auth_log</filter> | ||
<filter action="exclude">exclude_files_bwtmp</filter> | ||
<filter action="exclude">exclude_files_cloudinit</filter> | ||
<filter action="exclude">exclude_files_gdm</filter> | ||
<filter action="exclude">exclude_files_journal</filter> | ||
<filter action="exclude">exclude_files_lastlog</filter> | ||
<filter action="exclude">exclude_files_localmessages</filter> | ||
<filter action="exclude">exclude_files_messages</filter> | ||
<filter action="exclude">exclude_files_secure</filter> | ||
<filter action="exclude">exclude_files_sssd</filter> | ||
<filter action="exclude">exclude_files_syslog</filter> | ||
<filter action="exclude">exclude_files_waagent</filter> | ||
</unix:file_object> | ||
<unix:file_state id="state_group_ownership_adm_var_log_auth_log" version="1"> | ||
<unix:group_id datatype="int" operation="equals" var_ref="var_adm_gid"/> | ||
</unix:file_state> | ||
<unix:file_state id="state_group_ownership_root_var_log_auth_log" version="1"> | ||
<unix:group_id datatype="int" operation="equals">0</unix:group_id> | ||
</unix:file_state> | ||
<unix:file_state id="exclude_files_apt" version="1"> | ||
<unix:path operation="pattern match">^.*apt</unix:path> | ||
</unix:file_state> | ||
<unix:file_state id="exclude_files_auth_log" version="1"> | ||
<unix:filename>auth.log</unix:filename> | ||
</unix:file_state> | ||
<unix:file_state id="exclude_files_bwtmp" version="1"> | ||
<unix:filename operation="pattern match">^.*[bw]tmp((\.|-).*)?$</unix:filename> | ||
</unix:file_state> | ||
<unix:file_state id="exclude_files_cloudinit" version="1"> | ||
<unix:filename operation="pattern match">^.*cloud-init\.log.*</unix:filename> | ||
</unix:file_state> | ||
<unix:file_state id="exclude_files_gdm" version="1" operator="AND"> | ||
<unix:path operation="pattern match">^.*gdm|gdm3</unix:path> | ||
</unix:file_state> | ||
<unix:file_state id="exclude_files_journal" version="1" operator="AND"> | ||
<unix:filename operation="pattern match">^.*\.journal.*$</unix:filename> | ||
</unix:file_state> | ||
<unix:file_state id="exclude_files_lastlog" version="1"> | ||
<unix:filename operation="pattern match">^.*lastlog.*$</unix:filename> | ||
</unix:file_state> | ||
<unix:file_state id="exclude_files_localmessages" version="1"> | ||
<unix:filename operation="pattern match">^.*localmessages.*$</unix:filename> | ||
</unix:file_state> | ||
<unix:file_state id="exclude_files_messages" version="1"> | ||
<unix:filename>messages</unix:filename> | ||
</unix:file_state> | ||
<unix:file_state id="exclude_files_secure" version="1"> | ||
<unix:filename operation="pattern match">^.*secure.*$</unix:filename> | ||
</unix:file_state> | ||
<unix:file_state id="exclude_files_sssd" version="1" operator="AND"> | ||
<unix:path operation="pattern match">^.*(sssd|SSSD)$</unix:path> | ||
</unix:file_state> | ||
<unix:file_state id="exclude_files_syslog" version="1"> | ||
<unix:filename>syslog</unix:filename> | ||
</unix:file_state> | ||
<unix:file_state id="exclude_files_waagent" version="1"> | ||
<unix:filename operation="pattern match">^.*waagent\.log.*$</unix:filename> | ||
</unix:file_state> | ||
</def-group> |
33 changes: 33 additions & 0 deletions
33
linux_os/guide/system/permissions/files/groupowner_local_var_log/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: 'Verify ownership of log files' | ||
|
||
description: |- | ||
Any operating system providing too much information in error messages | ||
risks compromising the data and security of the structure, and content | ||
of error messages needs to be carefully considered by the organization. | ||
Organizations carefully consider the structure/content of error messages. | ||
The extent to which information systems are able to identify and handle | ||
error conditions is guided by organizational policy and operational | ||
requirements. Information that could be exploited by adversaries includes, | ||
for example, erroneous logon attempts with passwords entered by mistake | ||
as the username, mission/business information that can be derived from | ||
(if not stated explicitly by) information recorded, and personal | ||
information, such as account numbers, social security numbers, and credit | ||
card numbers. | ||
rationale: |- | ||
The {{{ full_name }}} must generate error messages that provide information | ||
necessary for corrective actions without revealing information that could | ||
be exploited by adversaries. | ||
severity: medium | ||
|
||
ocil_clause: 'not all log files owned by root or syslog' | ||
|
||
ocil: |- | ||
Verify the operating system has all system log files under the | ||
<pre>/var/log</pre> directory, that are not excluded, with a group owner set to root | adm, | ||
44 changes: 44 additions & 0 deletions
44
...x_os/guide/system/permissions/files/groupowner_local_var_log/tests/excluded_files.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,44 @@ | ||
#!/bin/bash | ||
# platform = Ubuntu 24.04 | ||
# packages = rsyslog | ||
|
||
chgrp root /var/log/* | ||
mkdir -p /var/log/apt | ||
chgrp nogroup /var/log/apt | ||
touch /var/log/auth.log | ||
chgrp nogroup /var/log/auth.log | ||
touch /var/log/btmp.log | ||
touch /var/log/btmp.log.1 | ||
touch /var/log/btmp.log-1 | ||
chgrp nogroup /var/log/btmp* | ||
touch /var/log/wtmp.log | ||
touch /var/log/wtmp.log.1 | ||
touch /var/log/wtmp.log-1 | ||
chgrp nogroup /var/log/wtmp* | ||
touch /var/log/cloud-init.log | ||
touch /var/log/cloud-init.log.1 | ||
chgrp nogroup /var/log/cloud-init.log* | ||
mkdir -p /var/log/gdm | ||
chgrp nogroup /var/log/gdm | ||
mkdir -p /var/log/gdm3 | ||
chgrp nogroup /var/log/gdm3 | ||
touch /var/log/test.journal | ||
touch /var/log/test.journal~ | ||
chgrp nogroup /var/log/*.journal* | ||
touch /var/log/lastlog | ||
touch /var/log/lastlog.1 | ||
chgrp nogroup /var/log/lastlog* | ||
touch /var/log/localmessages | ||
touch /var/log/localmessages.1 | ||
chgrp nogroup /var/log/localmessages* | ||
touch /var/log/messages | ||
chgrp nogroup /var/log/messages | ||
touch /var/log/secure | ||
chgrp nogroup /var/log/secure* | ||
mkdir -p /var/log/sssd | ||
chgrp nogroup /var/log/sssd | ||
touch /var/log/syslog | ||
chgrp nogroup /var/log/syslog | ||
touch /var/log/waagent.log | ||
touch /var/log/waagent.log.1 | ||
chgrp nogroup /var/log/waagent.log* |
6 changes: 6 additions & 0 deletions
6
linux_os/guide/system/permissions/files/groupowner_local_var_log/tests/owned_by_adm.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,6 @@ | ||
#!/bin/bash | ||
# platform = Ubuntu 24.04 | ||
# packages = rsyslog | ||
|
||
touch /var/log/test.log | ||
chgrp adm /var/log/test.log |
6 changes: 6 additions & 0 deletions
6
..._os/guide/system/permissions/files/groupowner_local_var_log/tests/owned_by_nobody.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,6 @@ | ||
#!/bin/bash | ||
# platform = Ubuntu 24.04 | ||
# packages = rsyslog | ||
|
||
touch /var/log/test.log | ||
chgrp nogroup /var/log/test.log |
6 changes: 6 additions & 0 deletions
6
linux_os/guide/system/permissions/files/groupowner_local_var_log/tests/owned_by_root.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,6 @@ | ||
#!/bin/bash | ||
# platform = Ubuntu 24.04 | ||
# packages = rsyslog | ||
|
||
touch /var/log/test.log | ||
chgrp root /var/log/test.log |
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
6 changes: 6 additions & 0 deletions
6
...stem/permissions/files/permissions_var_log_dir/file_groupowner_var_log_apt/bash/shared.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,6 @@ | ||
# platform = Ubuntu 24.04 | ||
# reboot = false | ||
# strategy = configure | ||
# complexity = low | ||
# disruption = low | ||
find -L /var/log/ -maxdepth 1 ! -group root ! -group adm -type d -regextype posix-extended -name 'apt' -exec chgrp adm {} \; |
35 changes: 35 additions & 0 deletions
35
...tem/permissions/files/permissions_var_log_dir/file_groupowner_var_log_apt/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,35 @@ | ||
<def-group> | ||
<definition class="compliance" id="{{{ rule_id }}}" version="1"> | ||
{{{ oval_metadata("Group owner of /var/log/apt should be root or adm.") }}} | ||
<criteria comment="Check group ownership of /var/log/apt"> | ||
<criterion test_ref="test_group_ownership_var_log_apt" /> | ||
</criteria> | ||
</definition> | ||
|
||
<ind:textfilecontent54_object id="object_adm_gid" version="1" comment="gid of the dedicated adm group"> | ||
<ind:filepath>/etc/group</ind:filepath> | ||
<ind:pattern operation="pattern match">^adm:\w+:(\w+):.*</ind:pattern> | ||
<ind:instance datatype="int" operation="equals">1</ind:instance> | ||
</ind:textfilecontent54_object> | ||
<local_variable id="var_adm_gid" datatype="int" version="1" | ||
comment="Retrieve the gid of adm group"> | ||
<object_component item_field="subexpression" object_ref="object_adm_gid"/> | ||
</local_variable> | ||
|
||
<unix:file_test check="all" comment="/var/log/apt group owner is root|adm" | ||
id="test_group_ownership_var_log_apt" state_operator="OR" version="1"> | ||
<unix:object object_ref="object_group_ownership_var_log_apt" /> | ||
<unix:state state_ref="state_group_ownership_adm_var_log_apt"/> | ||
<unix:state state_ref="state_group_ownership_root_var_log_apt"/> | ||
</unix:file_test> | ||
<unix:file_object comment="/var/log/apt" id="object_group_ownership_var_log_apt" version="1"> | ||
<unix:path>/var/log/apt</unix:path> | ||
<unix:filename xsi:nil="true"/> | ||
</unix:file_object> | ||
<unix:file_state id="state_group_ownership_adm_var_log_apt" version="1"> | ||
<unix:group_id datatype="int" operation="equals" var_ref="var_adm_gid"/> | ||
</unix:file_state> | ||
<unix:file_state id="state_group_ownership_root_var_log_apt" version="1"> | ||
<unix:group_id datatype="int" operation="equals">0</unix:group_id> | ||
</unix:file_state> | ||
</def-group> |
16 changes: 16 additions & 0 deletions
16
...ide/system/permissions/files/permissions_var_log_dir/file_groupowner_var_log_apt/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,16 @@ | ||
documentation_complete: true | ||
|
||
title: 'Verify Group Who Owns /var/log/apt Directory' | ||
|
||
description: '{{{ describe_file_group_owner(file="/var/log/apt", group="root|adm") }}}' | ||
|
||
rationale: |- | ||
The <tt>/var/log/apt</tt> directory contains information about APT | ||
and should only be accessed by authorized personnel. | ||
severity: medium | ||
|
||
ocil_clause: '{{{ ocil_clause_file_group_owner(file="/var/log/apt", group="root|adm") }}}' | ||
|
||
ocil: |- | ||
{{{ ocil_file_group_owner(file="/var/log/apt", group="root|adm") }}} |
6 changes: 6 additions & 0 deletions
6
...ions/files/permissions_var_log_dir/file_groupowner_var_log_apt/tests/owned_by_adm.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,6 @@ | ||
#!/bin/bash | ||
# platform = Ubuntu 24.04 | ||
# packages = rsyslog | ||
|
||
mkdir -p /var/log/apt | ||
chgrp adm /var/log/apt |
6 changes: 6 additions & 0 deletions
6
.../files/permissions_var_log_dir/file_groupowner_var_log_apt/tests/owned_by_nogroup.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,6 @@ | ||
#!/bin/bash | ||
# platform = Ubuntu 24.04 | ||
# packages = rsyslog | ||
|
||
mkdir -p /var/log/apt | ||
chgrp nogroup /var/log/apt |
6 changes: 6 additions & 0 deletions
6
...ons/files/permissions_var_log_dir/file_groupowner_var_log_apt/tests/owned_by_root.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,6 @@ | ||
#!/bin/bash | ||
# platform = Ubuntu 24.04 | ||
# packages = rsyslog | ||
|
||
mkdir -p /var/log/apt | ||
chgrp root /var/log/apt |
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
Oops, something went wrong.