TL;DR
This guide helps you investigate a potential attack targeting your Unix system’s procmail process. We’ll cover identifying suspicious activity, examining logs, and cleaning up compromised configurations.
1. Identify Suspicious Activity
- Check Running Processes: Use
psto look for unusual procmail instances or processes spawned by procmail that don’t match expected behaviour.ps aux | grep procmailLook for high CPU usage, unexpected command-line arguments, or processes running as a different user than usual.
- Monitor System Logs: Examine
/var/log/syslog(or your system’s equivalent) for errors related to procmail.grep -i procmail /var/log/syslogPay attention to messages about failed deliveries, unexpected script executions, or permission issues.
- Network Connections: Use
netstatorssto see if procmail is making any unusual network connections.netstat -tulnp | grep procmailUnexpected outbound connections could indicate a compromised process sending spam or exfiltrating data.
2. Examine Procmail Configuration Files
- Locate Configuration Files: The main configuration file is typically
~/.procmailrcfor each user. System-wide configurations might be in/etc/procmailrcor similar locations. - Review .procmailrc Contents: Carefully inspect the contents of each
.procmailrcfile for suspicious entries.- Look for unexpected forwarding addresses or scripts.
- Check for lines that execute external commands without proper validation.
- Be wary of complex filtering rules that might be used to hide malicious activity.
- Identify Suspicious Scripts: If your
.procmailrcfile calls external scripts, examine those scripts for malicious code.cat ~/.procmailrc | grep -oP '(?<=exec ).*'This command will extract the commands being executed by procmail.
3. Investigate Mail Logs
- Check Mail Delivery Logs: Examine your mail server's logs (e.g., Postfix, Sendmail) for messages related to the affected users.
Look for bounced emails, delivery failures, or unusual email patterns. - Examine Mail Queues: Check the mail queue for stuck or suspicious messages.
mailqThis can reveal if an attacker is attempting to use your system as a relay.
4. Clean Up Compromised Configurations
- Remove Suspicious Entries: Delete any malicious entries from the
.procmailrcfiles.
Be careful not to remove legitimate configurations accidentally. Back up the original file before making changes. - Replace Compromised Scripts: Replace any compromised scripts with clean versions.
If you are unsure, delete the script entirely and reconfigure procmail without it. - Reset User Passwords: If a user account has been compromised, reset their password immediately.
- Scan for Rootkits: Run a rootkit scanner to ensure that the system hasn't been further compromised.
sudo apt-get install rkhunter # Example on Debian/UbuntuThen run
rkhunter --checkall - Update System: Ensure your system is fully patched with the latest security updates.
5. Further Analysis (Optional)
- Packet Capture: If you suspect network activity, capture network traffic using tools like
tcpdumpor Wireshark to analyze communication patterns.sudo tcpdump -i eth0 port 25 # Example capturing SMTP traffic on interface eth0 - Memory Dump: In advanced cases, you might need to perform a memory dump of the procmail process for detailed analysis. This requires specialized tools and expertise.

