Verify ownership of log files (ubuntu2404)
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 Ubuntu 24.04 must generate error messages that provide information
necessary for corrective actions without revealing information that could
be exploited by adversaries.
Shell script
The following script can be run on the host to remediate the issue.
#!/bin/bash
# default to root
group="root"
# see https://workbench.cisecurity.org/benchmarks/18959/tickets/23964
# regarding sssd and gdm exclusions
find -L /var/log/ -type f -regextype posix-extended \
! -group root ! -group adm \
! -name 'gdm' ! -name 'gdm3' \
! -name 'sssd' ! -name 'SSSD' \
! -name 'auth.log' \
! -name 'messages' \
! -name 'syslog' \
! -path '/var/log/apt/*' \
! -path '/var/log/gdm/*' \
! -path '/var/log/gdm3/*' \
! -path '/var/log/sssd/*' \
! -path '/var/log/[bw]tmp*' \
! -path '/var/log/cloud-init.log*' \
! -regex '.*\.journal[~]?' \
! -regex '.*/lastlog(\.[^\/]+)?$' \
! -regex '.*/localmessages(.*)' \
! -regex '.*/secure(.*)' \
! -regex '.*/waagent.log(.*)' \
-regex '.*' -exec chgrp $group {} \;