Skip to content

Commit

Permalink
Merge pull request ComplianceAsCode#11640 from marcusburghardt/system…
Browse files Browse the repository at this point in the history
…map_files

Add new templated rules for System.map files
  • Loading branch information
jan-cerny authored Mar 6, 2024
2 parents 367afe5 + 87e45d2 commit d08e8ce
Show file tree
Hide file tree
Showing 26 changed files with 170 additions and 59 deletions.
2 changes: 2 additions & 0 deletions components/filesystem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ rules:
- file_groupowner_etc_passwd
- file_groupowner_etc_shadow
- file_groupowner_etc_shells
- file_groupowner_systemmap
- file_groupowner_var_log
- file_groupowner_var_log_messages
- file_groupowner_var_log_syslog
Expand All @@ -51,6 +52,7 @@ rules:
- file_owner_etc_passwd
- file_owner_etc_shells
- file_owner_etc_shadow
- file_owner_systemmap
- file_owner_var_log
- file_owner_var_log_messages
- file_owner_var_log_syslog
Expand Down
4 changes: 3 additions & 1 deletion controls/anssi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,10 @@ controls:
- file_owner_user_cfg
- file_permissions_efi_user_cfg
- file_permissions_user_cfg
- file_groupowner_systemmap
- file_owner_systemmap
- file_permissions_systemmap
related_rules:
- file_permissions_systemmap # missing remediation
- mount_option_boot_noauto

- id: R30
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
documentation_complete: true

title: 'Verify Group Who Owns System.map Files'

description: |-
The System.map files are symbol map files generated during the compilation of the Linux
kernel. They contain the mapping between kernel symbols and their corresponding memory
addresses. These files must be group-owned by root.
{{{ describe_file_group_owner(file="/boot/System.map*", group="root") }}}
rationale: |-
The purpose of <tt>System.map</tt> files is primarily for debugging and profiling the kernel.
Unrestricted access to these files might disclose information useful to attackers and
malicious software leading to more sophisticated exploitation.
severity: low

identifiers:
cce@rhel7: CCE-86582-4
cce@rhel8: CCE-86583-2
cce@rhel9: CCE-86584-0

ocil_clause: '{{{ ocil_clause_file_group_owner(file="/boot/System.map*", group="root") }}}'

ocil: |-
{{{ ocil_file_group_owner(file="/boot/System.map*", group="root") }}}
template:
name: file_groupowner
vars:
filepath: /boot/
file_regex: ^.*System\.map.*$
gid_or_name: root
missing_file_pass: 'true'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

mktemp -p /boot System.map-5.99.0-XXX
chgrp root /boot/System.map*
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

mktemp -p /boot System.map-5.99.0-XXX
mktemp -p /boot System.map-5.99.0-XXX
chgrp root /boot/System.map*
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

FAKE_FILE=$(mktemp -p /boot System.map-5.99.0-XXX)
chgrp 5 $FAKE_FILE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

FAKE_FILE1=$(mktemp -p /boot System.map-5.99.0-XXX)
chgrp root $FAKE_FILE1

FAKE_FILE2=$(mktemp -p /boot System.map-5.99.0-XXX)
chgrp 5 $FAKE_FILE2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

rm -f /boot/System.map*
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
documentation_complete: true

title: 'Verify User Who Owns System.map Files'

description: |-
The System.map files are symbol map files generated during the compilation of the Linux
kernel. They contain the mapping between kernel symbols and their corresponding memory
addresses. These files must be owned by root.
{{{ describe_file_owner(file="/boot/System.map*", owner="root") }}}
rationale: |-
The purpose of <tt>System.map</tt> files is primarily for debugging and profiling the kernel.
Unrestricted access to these files might disclose information useful to attackers and
malicious software leading to more sophisticated exploitation.
severity: low

identifiers:
cce@rhel7: CCE-86585-7
cce@rhel8: CCE-86586-5
cce@rhel9: CCE-86587-3

ocil_clause: '{{{ ocil_clause_file_owner(file="/boot/System.map*", owner="root") }}}'

ocil: |-
{{{ ocil_file_owner(file="/boot/System.map*", owner="root") }}}
template:
name: file_owner
vars:
filepath: /boot/
file_regex: ^.*System\.map.*$
fileuid: '0'
missing_file_pass: 'true'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

mktemp -p /boot System.map-5.99.0-XXX
chown root /boot/System.map*
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

mktemp -p /boot System.map-5.99.0-XXX
mktemp -p /boot System.map-5.99.0-XXX
chown root /boot/System.map*
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

FAKE_FILE=$(mktemp -p /boot System.map-5.99.0-XXX)
chown 5 $FAKE_FILE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

FAKE_FILE1=$(mktemp -p /boot System.map-5.99.0-XXX)
chown root $FAKE_FILE1

FAKE_FILE2=$(mktemp -p /boot System.map-5.99.0-XXX)
chown 5 $FAKE_FILE2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

rm -f /boot/System.map*

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
documentation_complete: true

title: 'Verify that local System.map file (if exists) is readable only by root'
title: 'Verify Permissions on System.map Files'

description: |-
Files containing sensitive informations should be protected by restrictive
permissions. Most of the time, there is no need that these files need to be read by any non-root user
{{{ describe_file_permissions(file="/boot/System.map-*", perms="0600") }}}
The System.map files are symbol map files generated during the compilation of the Linux
kernel. They contain the mapping between kernel symbols and their corresponding memory
addresses. In general, there is no need for non-root users to read these files.
{{{ describe_file_permissions(file="/boot/System.map*", perms="0600") }}}
rationale: |-
The <tt>System.map</tt> file contains information about kernel symbols and
can give some hints to generate local exploitation.
The purpose of <tt>System.map</tt> files is primarily for debugging and profiling the kernel.
Unrestricted access to these files might disclose information useful to attackers and
malicious software leading to more sophisticated exploitation.
severity: unknown
severity: low

identifiers:
cce@rhel7: CCE-82350-0
cce@rhel8: CCE-82892-1
cce@rhel9: CCE-86581-6

ocil_clause: '{{{ ocil_clause_file_permissions(file="/boot/System.map*", perms="-rw-------") }}}'

ocil: |-
{{{ ocil_file_permissions(file="/boot/Sysem.map-*", perms="-rw-------") }}}
{{{ ocil_file_permissions(file="/boot/System.map*", perms="-rw-------") }}}
template:
name: file_permissions
vars:
filepath: /boot/
file_regex: ^.*System\.map.*$
filemode: '0600'
allow_stricter_permissions: 'true'
missing_file_pass: 'true'
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

mktemp -p /boot System.map-5.99.0-XXX
mktemp -p /boot System.map-5.99.0-XXX
chmod 0600 /boot/System.map*
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

mktemp -p /boot System.map-5.99.0-XXX
chmod 0600 /boot/System.map*
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

FAKE_FILE1=$(mktemp -p /boot System.map-5.99.0-XXX)
chmod 0600 $FAKE_FILE1

FAKE_FILE2=$(mktemp -p /boot System.map-5.99.0-XXX)
chmod 0644 $FAKE_FILE2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

FAKE_FILE=$(mktemp -p /boot System.map-5.99.0-XXX)
chmod 0644 $FAKE_FILE
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

rm -f /boot/System.map*
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

mktemp -p /boot System.map-5.99.0-XXX
chmod 0400 /boot/System.map*
1 change: 0 additions & 1 deletion products/rhel7/profiles/default.profile
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@ selections:
- audit_rules_unsuccessful_file_modification_fchownat
- sebool_openvpn_enable_homedirs
- bios_disable_usb_boot
- file_permissions_systemmap
- service_docker_enabled
- file_owner_etc_hosts_allow
- audit_rules_unsuccessful_file_modification_open_o_creat
Expand Down
1 change: 0 additions & 1 deletion products/rhel8/profiles/default.profile
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,6 @@ selections:
- sebool_openvpn_enable_homedirs
- zipl_enable_selinux
- bios_disable_usb_boot
- file_permissions_systemmap
- audit_rules_unsuccessful_file_modification_open_o_creat
- kernel_config_ipv6
- service_rpcgssd_disabled
Expand Down
1 change: 0 additions & 1 deletion products/rhel9/profiles/default.profile
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ selections:
- audit_rules_unsuccessful_file_modification_fchownat
- sebool_openvpn_enable_homedirs
- zipl_enable_selinux
- file_permissions_systemmap
- audit_rules_unsuccessful_file_modification_open_o_creat
- kernel_config_ipv6
- audit_rules_successful_file_modification_chown
Expand Down
7 changes: 0 additions & 7 deletions shared/references/cce-redhat-avail.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,6 @@ CCE-86576-6
CCE-86577-4
CCE-86578-2
CCE-86579-0
CCE-86581-6
CCE-86582-4
CCE-86583-2
CCE-86584-0
CCE-86585-7
CCE-86586-5
CCE-86587-3
CCE-86589-9
CCE-86590-7
CCE-86591-5
Expand Down

0 comments on commit d08e8ce

Please sign in to comment.