TMAegis베타
cos 관련 규칙 더 보기

Container-Optimized OS

TMA-COS-5.3.2

Ensure system accounts are secured

보통레벨 2자동cos

설명

There are a number of accounts provided with most distributions that are used to manage applications and are not intended to provide an interactive shell. It is important to make sure that accounts that are not being used by regular users are prevented from being used to provide an interactive shell. By default, most distributions set the password field for these accounts to an invalid string, but it is also recommended that the shell field in the password file be set to the nologin shell. This prevents the account from potentially being used to run any commands.

점검 방법

감사 방식: 셸 명령

shell
min=$(awk '/^[[:space:]]*UID_MIN/{print $2}' /etc/login.defs); min=${min:-1000}; shells=$(awk -F/ '/^\// && $NF != "nologin"' /etc/shells); bad=0; while IFS=: read -r u p uid g c h sh; do for x in root sync shutdown halt; do [ "$u" = "$x" ] && continue 2; done; case $u in +*) continue;; esac; [ "$uid" -lt "$min" ] 2>/dev/null || continue; printf "%s\n" "$shells" | grep -qxF -- "$sh" && bad=1; done < /etc/passwd; [ $bad -eq 0 ] && echo compliant || echo noncompliant
예상 출력
compliant

조치 방법

조치 방식: 가이드 또는 인프라 패치

Run the commands appropriate for your distribution: Set the shell for any accounts returned by the audit to nologin: # usermod -s $(which nologin) <user> Lock any non root accounts returned by the audit: # usermod -L <user> The following command will set all system accounts to a non login shell: awk -F: '($1!="root" && $1!="sync" && $1!="shutdown" && $1!="halt" && $1!~/^\+/ && $3>='"$(awk '/^\s*SYS_UID_MIN/{print $2}' /etc/login.defs)"' && $3<='"$(awk '/^\s*SYS_UID_MAX/{print $2}' /etc/login.defs)"' && $7!="'"$(which nologin)"'" && $7!="/bin/false") {print $1}' /etc/passwd | while read user; do usermod -s $(which nologin) $user; done The following command will automatically lock not root system accounts: awk -F: '($1!="root" && $1!~/^\+/ && $3>='"$(awk '/^\s*SYS_UID_MIN/{print $2}' /etc/login.defs)"' && $3<='"$(awk '/^\s*SYS_UID_MAX/{print $2}' /etc/login.defs)"') {print $1}' /etc/passwd | xargs -I '{}' passwd -S '{}' | awk '($2!="L" && $2!="LK") {print $1}' | while read user; do usermod -L $user; done

속성

운영 체제
모두
태그
container-optimized-oscos
참고 자료
CIS Google Container-Optimized OS Benchmark v1.2.0 - 5.3.2 Ensure system accounts are secured

이 호스트 점검하기

감사 권한이 있는 시스템에서 실행하세요. 스캔은 읽기 전용입니다.

shell
tmaegis scan --target cos --level 2