Users and Groups
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:
Username: e.g.,
root
.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
).
Command:
/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.
Command:
/etc/group
:Purpose: Defines group memberships.
Fields:
Group Name: e.g.,
sudo
.GID: Group ID.
Members: Users in the group.
Command:
/etc/sudoers
:Purpose: Configures sudo privileges.
Command:
Steps for Incident Response
1. Detect Suspicious Users
Attackers may create or modify accounts for persistence.
List All Users:
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.Identify Recent Changes:
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
Valid Login Users:
Review SSH Configuration: Check
AllowUsers
andAllowGroups
directives insshd_config
.Active SSH Sessions: List currently logged-in users via SSH.
4. Identify Unauthorized Logins
Failed Login Attempts:
Successful Logins:
Eradication and Remediation
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
Delete Old Keys:
Generate New Keys:
Key Commands
Task | Command |
List all users |
|
Check for suspicious usernames | `awk -F: '$NF !~ "nologin |
Review privileged groups |
|
List sudo users |
|
Find recent user changes |
|
Failed login attempts |
|
Successful SSH logins |
|
Key Points
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.
Last updated