Skip to content

Commit ddefa78

Browse files
committed
Handle Ubuntu 26.04 sudo-rs logging
1 parent 1a5c77d commit ddefa78

6 files changed

Lines changed: 74 additions & 1 deletion

File tree

components/sudo.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ rules:
1919
- sudo_add_umask
2020
- sudo_add_use_pty
2121
- sudo_custom_logfile
22+
- sudo_logging_ubuntu2604
2223
- sudo_dedicated_group
2324
- sudo_remove_no_authenticate
2425
- sudo_remove_nopasswd
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# platform = Ubuntu 26.04
2+
# reboot = false
3+
# strategy = restrict
4+
# complexity = low
5+
# disruption = low
6+
7+
- name: Install rsyslog for sudo event logging
8+
ansible.builtin.package:
9+
name: rsyslog
10+
state: present
11+
12+
- name: Enable rsyslog for sudo event logging
13+
ansible.builtin.systemd_service:
14+
name: rsyslog.service
15+
enabled: true
16+
state: started
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# platform = Ubuntu 26.04
2+
# reboot = false
3+
# strategy = restrict
4+
# complexity = low
5+
# disruption = low
6+
7+
{{{ bash_package_install("rsyslog") }}}
8+
9+
systemctl enable --now rsyslog.service
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
documentation_complete: true
2+
3+
title: 'Ensure Sudo Events Are Logged'
4+
5+
description: |-
6+
Sudo events must be captured in a durable log. <tt>sudo-rs</tt> sends
7+
events to the <tt>authpriv</tt> syslog facility and does not support the
8+
classic sudo <tt>Defaults logfile=</tt> option.
9+
10+
rationale: |-
11+
A durable record of privilege escalation supports auditing and incident
12+
investigation.
13+
14+
severity: low
15+
16+
platform: package[sudo]
17+
18+
ocil_clause: 'sudo events are not present in the journal or a persistent log'
19+
20+
ocil: |-
21+
Run <tt>journalctl -t sudo -t sudo-rs</tt> and inspect
22+
<tt>/var/log/auth.log</tt>. At least one location must contain sudo events.
23+
Classic sudo may instead use a valid <tt>Defaults logfile=</tt> setting.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
# platform = Ubuntu 26.04
3+
# check-import = stdout
4+
5+
if journalctl -q -t sudo -t sudo-rs --since=-5min --no-pager 2>/dev/null |
6+
grep -q '[^[:space:]]'; then
7+
exit "$XCCDF_RESULT_PASS"
8+
fi
9+
10+
if grep -Eq '\b(sudo|sudo-rs)\[[0-9]+\]:' /var/log/auth.log 2>/dev/null; then
11+
exit "$XCCDF_RESULT_PASS"
12+
fi
13+
14+
if ! dpkg-query --show --showformat='${db:Status-Status}' sudo-rs 2>/dev/null |
15+
grep -qx installed; then
16+
if grep -rPsiq \
17+
'^\h*Defaults\h+([^#]+,\h*)?logfile\h*=\h*("|'"'"')?\H+("|'"'"')?(,\h*\H+\h*)*\h*(#.*)?$' \
18+
/etc/sudoers /etc/sudoers.d 2>/dev/null; then
19+
exit "$XCCDF_RESULT_PASS"
20+
fi
21+
fi
22+
23+
echo 'No sudo event was found in the journal or /var/log/auth.log.'
24+
exit "$XCCDF_RESULT_FAIL"

products/ubuntu2604/controls/cis_ubuntu2604.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1598,7 +1598,7 @@ controls:
15981598
- l1_server
15991599
- l1_workstation
16001600
rules:
1601-
- sudo_custom_logfile
1601+
- sudo_logging_ubuntu2604
16021602
status: automated
16031603
- id: 5.2.5
16041604
title: Ensure users must provide a password for privilege escalation (Automated)

0 commit comments

Comments
 (0)