Linux distributions
TMA-ALMA8-5.4.2.5
Ensure root path integrity
Trung bìnhCấp 1Tự độnglinux
Mô tả
The root user can execute any command on the system and could be fooled into executing programs unintentionally if the PATH is not set correctly.
Cách kiểm tra
Phương pháp kiểm tra: Lệnh shell
shell
alt0() { o=$(bash -c '#!/usr/bin/env bash
{
l_output2=""
l_pmask="0022"
l_maxperm="$( printf '"'"'%o'"'"' $(( 0777 & ~$l_pmask )) )"
l_root_path="$(sudo -Hiu root env | grep '"'"'^PATH'"'"' | cut -d= -f2)"
unset a_path_loc && IFS=":" read -ra a_path_loc <<< "$l_root_path"
grep -q "::" <<< "$l_root_path" && l_output2="$l_output2\n - root'"'"'s path contains a empty directory (::)"
grep -Pq ":\h*$" <<< "$l_root_path" && l_output2="$l_output2\n - root'"'"'s path contains a trailing (:)"
grep -Pq '"'"'(\h+|:)\.(:|\h*$)'"'"' <<< "$l_root_path" && l_output2="$l_output2\n - root'"'"'s path contains current working directory (.)"
while read -r l_path; do
if [ -d "$l_path" ]; then
while read -r l_fmode l_fown; do
[ "$l_fown" != "root" ] && l_output2="$l_output2\n - Directory: \"$l_path\" is owned by: \"$l_fown\" should be owned by \"root\""
[ $(( $l_fmode & $l_pmask )) -gt 0 ] && l_output2="$l_output2\n - Directory: \"$l_path\" is mode: \"$l_fmode\" and should be mode: \"$l_maxperm\" or more restrictive"
done <<< "$(stat -Lc '"'"'%#a %U'"'"' "$l_path")"
else
l_output2="$l_output2\n - \"$l_path\" is not a directory"
fi
done <<< "$(printf "%s\n" "${a_path_loc[@]}")"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n *** PASS ***\n - Root'"'"'s path is correctly configured\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - * Reasons for audit failure * :\n$l_output2\n"
fi
}' 2>&1); printf '%s\n' "$o" | grep -q '\*\* PASS \*\*' || { echo "step1: script did not report PASS"; return 1; }; }; if alt0; then echo compliant; fi- Đầu ra mong đợi
compliant
Cách khắc phục
Phương pháp khắc phục: Hướng dẫn hoặc bản vá hạ tầng
Correct or justify any: • Locations that are not directories • Empty directories (::) • Trailing (:) • Current working directory (.) • Non root owned directories • Directories that less restrictive than mode 0755
Thuộc tính
- Hệ điều hành
- almalinux-8
- Thẻ
- cis-convertedlinux
- Tham chiếu
- CIS AlmaLinux OS 8 Benchmark v4.0.0 - 5.4.2.5
Kiểm tra máy này
Chạy lệnh này trên máy bạn được phép kiểm tra. Lần quét chỉ ở chế độ đọc.
shell
tmaegis scan --target linux