diff --git a/components/pam.yml b/components/pam.yml
index b6789a9972c..9367a1c2bd6 100644
--- a/components/pam.yml
+++ b/components/pam.yml
@@ -65,6 +65,7 @@ rules:
- accounts_password_pam_retry
- accounts_password_pam_ucredit
- accounts_password_pam_unix_enabled
+- accounts_password_pam_unix_authtok
- accounts_password_pam_unix_remember
- accounts_password_pam_unix_rounds_password_auth
- accounts_password_pam_unix_rounds_system_auth
diff --git a/controls/cis_ubuntu2404.yml b/controls/cis_ubuntu2404.yml
index 74b56aa1cae..f1b7cc4f33d 100644
--- a/controls/cis_ubuntu2404.yml
+++ b/controls/cis_ubuntu2404.yml
@@ -2059,8 +2059,9 @@ controls:
levels:
- l1_server
- l1_workstation
- status: planned
- notes: TODO. Rule does not seem to be implemented, nor does it map to any rules in ubuntu2204 profile.
+ rules:
+ - accounts_password_pam_unix_authtok
+ status: automated
- id: 5.4.1.1
title: Ensure password expiration is configured (Automated)
diff --git a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_password_pam_unix_authtok/bash/shared.sh b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_password_pam_unix_authtok/bash/shared.sh
new file mode 100644
index 00000000000..1c7def053ef
--- /dev/null
+++ b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_password_pam_unix_authtok/bash/shared.sh
@@ -0,0 +1,14 @@
+# platform = multi_platform_ubuntu
+
+config_file="/usr/share/pam-configs/cac_unix"
+{{{ bash_pam_unix_enable() }}}
+sed -i -E '/^Password:/,/^[^[:space:]]/ {
+ /pam_unix\.so/ {
+ /use_authtok/! s/$/ use_authtok/g
+ }
+}' "$config_file"
+
+
+DEBIAN_FRONTEND=noninteractive pam-auth-update
+
+
diff --git a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_password_pam_unix_authtok/oval/shared.xml b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_password_pam_unix_authtok/oval/shared.xml
new file mode 100644
index 00000000000..452c7d05ccc
--- /dev/null
+++ b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_password_pam_unix_authtok/oval/shared.xml
@@ -0,0 +1,23 @@
+{{%- set accounts_password_pam_unix_file = '/etc/pam.d/common-password' -%}}
+
+
$ grep use_authtok {{{ configFile }}}+ The output should show use_authtok on the line. + +fixtext: |- + To configure the use_authtok option for the pam_unix + PAM modules, in the file {{{ configFile }}}, append use_authtok + to the line which refers to the pam_unix.so, as + shown below: + +
password [success=1 default=ignore] pam_unix.so ...existing_options... use_authtok+ +platform: package[pam] diff --git a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_password_pam_unix_authtok/tests/ubuntu_correct_value.pass.sh b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_password_pam_unix_authtok/tests/ubuntu_correct_value.pass.sh new file mode 100644 index 00000000000..bef6483a480 --- /dev/null +++ b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_password_pam_unix_authtok/tests/ubuntu_correct_value.pass.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# platform = multi_platform_ubuntu + +config_file=/usr/share/pam-configs/tmpunix + +cat << EOF > "$config_file" +Name: Unix authentication +Default: yes +Priority: 0 +Auth-Type: Primary +Auth: + [success=end default=ignore] pam_unix.so try_first_pass +Auth-Initial: + [success=end default=ignore] pam_unix.so +Account-Type: Primary +Account: + [success=end new_authtok_reqd=done default=ignore] pam_unix.so +Account-Initial: + [success=end new_authtok_reqd=done default=ignore] pam_unix.so +Session-Type: Additional +Session: + required pam_unix.so +Session-Initial: + required pam_unix.so +Password-Type: Primary +Password: + [success=end default=ignore] pam_unix.so obscure use_authtok try_first_pass yescrypt +Password-Initial: + [success=end default=ignore] pam_unix.so obscure yescrypt +EOF + +DEBIAN_FRONTEND=noninteractive pam-auth-update +rm "$config_file" diff --git a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_password_pam_unix_authtok/tests/ubuntu_missing_value.fail.sh b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_password_pam_unix_authtok/tests/ubuntu_missing_value.fail.sh new file mode 100644 index 00000000000..20f55baf479 --- /dev/null +++ b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_password_pam_unix_authtok/tests/ubuntu_missing_value.fail.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# platform = multi_platform_ubuntu + +config_file=/etc/pam.d/common-password +sed -i --follow-symlinks "s/use_authtok//g" $config_file diff --git a/shared/macros/10-bash.jinja b/shared/macros/10-bash.jinja index 82ac231dfac..96ab55f9f44 100644 --- a/shared/macros/10-bash.jinja +++ b/shared/macros/10-bash.jinja @@ -913,8 +913,8 @@ if [ ! -f "$conf_path"/"$conf_name" ]; then if [ -f "$conf_path"/unix ]; then if grep -q "$(md5sum "$conf_path"/unix | cut -d ' ' -f 1)" /var/lib/dpkg/info/libpam-runtime.md5sums;then cp "$conf_path"/unix "$conf_path"/"$conf_name" - sed -i '/Default: yes/a Priority: 257\ -Conflicts: unix' "$conf_path"/"$conf_name" + sed -i 's/Priority: [0-9]\+/Priority: 257\ +Conflicts: unix/' "$conf_path"/"$conf_name" DEBIAN_FRONTEND=noninteractive pam-auth-update else echo "Not applicable - checksum of $conf_path/unix does not match the original." >&2