| name | cis-ubuntu2004-v300-7-2-9 |
| description | Ensure local interactive user home directories are configured |
| category | cis-iam |
| version | 3.0.0 |
| author | cyberstrike-official |
| tags | ["cis","ubuntu","linux","ubuntu-20.04","users"] |
| cis_id | 7.2.9 |
| cis_benchmark | CIS Ubuntu Linux 20.04 LTS Benchmark v3.0.0 |
| tech_stack | ["ubuntu","linux"] |
| cwe_ids | [] |
| chains_with | [] |
| prerequisites | [] |
| severity_boost | {} |
7.2.9 Ensure local interactive user home directories are configured (Automated)
Profile
- Level 1 - Server
- Level 1 - Workstation
Description
The user home directory is space defined for the particular user to set local environment variables and to store personal files. While the system administrator can establish secure permissions for users' home directories, the users can easily override these. Users can be defined in /etc/passwd without a home directory or with a home directory that does not actually exist.
Rationale
Since the user is accountable for files stored in the user home directory, the user must be the owner of the directory. Group or world-writable user home directories may enable malicious users to steal or modify other users' data or to gain another user's system privileges. If the user's home directory does not exist or is unassigned, the user will be placed in "/" and will not be able to write any files or have local environment variables set.
Impact
None
Audit Procedure
Command Line
Run the following script to Ensure:
- local interactive user home directories exist
- Ensure local interactive users own their home directories
- Ensure local interactive user home directories are mode 750 or more restrictive
#!/usr/bin/env bash
{
a_output=() a_output2=() a_exists2=() a_mode2=() a_owner2=()
l_valid_shells="^$(awk -F\/ '$NF != "nologin" {print}' /etc/shells | sed -rn '/^\//{s,/,\\/,g;p}' | paste -s -d '|' - ))$"
l_mask='0027'; l_max="$(printf '%o' $(( 0777 & ~$l_mask)) )"
l_users="$(awk -v pat="$l_valid_shells" -F: '$(NF) ~ pat { print $1 " " $(NF-1) }' /etc/passwd | wc -l)"
[ "$l_users" -gt 10000 ] && printf '%s\n' "" " ** INFO **" \
" $l_users Local interactive users found on the system"
IFS= -r l_user l_home;
[ -d ];
IFS=: -r l_own l_mode;
[ != ] && a_owner2+=()
[ $(( & )) -gt 0 ] && a_mode2+=()
<<<
a_exists2+=()
<<<
[ -gt 0 ] && a_output2+=() || \
a_output+=()
[ -gt 0 ] && a_output2+=() || \
a_output+=()
[ -gt 0 ] && a_output2+=() || \
a_output+=()
[ -le 0 ];
[ -gt 0 ] &&
}