User Account and Group Analysis in Incident Response (Linux Systems)
When investigating a potential compromise on a Linux system, analyzing user accounts and group memberships is essential for detecting unauthorized access, privilege escalation, and persistence mechanisms. Below is a systematic approach to investigating and remediating compromised user accounts.
Critical Files for User and Group Management
/etc/passwd:
Purpose: Contains basic user account information.
Fields:
Password placeholder (x): Points to /etc/shadow.
UID/GID: User and group IDs.
Home Directory: User’s home directory.
Shell: Default shell (e.g., /bin/bash, /bin/false).
/etc/shadow:
Purpose: Stores hashed passwords and password policies.
Fields:
Encrypted Password: e.g., $6$random_salt$hashed_password.
Password Policy: Expiration and change intervals.
/etc/group:
Purpose: Defines group memberships.
Fields:
Members: Users in the group.
/etc/sudoers:
Purpose: Configures sudo privileges.
Steps for Incident Response
1. Detect Suspicious Users
Attackers may create or modify accounts for persistence.
Check for Suspicious Usernames: Look for generic or unexpected names like admin, support, backup.
Verify User Shells: Identify accounts with interactive shells (/bin/bash) and flag suspicious ones.
2. Analyze User Permissions
Group Memberships: Review privileged groups (sudo, adm, root) and their members.
Sudo Privileges: Check users with sudo access.
Recent Group Modifications:
3. Identify Users with SSH Access
Review SSH Configuration: Check AllowUsers and AllowGroups directives in sshd_config.
Active SSH Sessions: List currently logged-in users via SSH.
4. Identify Unauthorized Logins
1. Remove Malicious Users
Delete unauthorized accounts and their home directories.
2. Remove Unauthorized Group Memberships
Revoke privileged group access.
3. Revoke Sudo Privileges
Edit the sudoers file securely:
Remove unauthorized sudo entries.
4. Change Compromised User Passwords
Force legitimate users to reset their passwords.
5. Regenerate SSH Keys
Check for suspicious usernames
`awk -F: '$NF !~ "nologin
grep useradd /var/log/auth.log
grep "Failed password" /var/log/auth.log
grep "Accepted password" /var/log/auth.log
By systematically reviewing user accounts, group memberships, and login activity, you can detect and respond to compromised accounts effectively. Regular monitoring and hardening user management practices are essential to prevent unauthorized access and maintain system integrity.