Monitoring shows a web server making outbound connections to an unknown IP on port 4444 at 2 AM. You suspect it is compromised. What do you do?
AdvancedScenarioSecurity, hardening and incident response
Answer
Situation read → Contain, preserve evidence, then investigate. Don't "clean" a live box and put it back.
What I'd do →
- Contain: pull it out of the load balancer and restrict network at the security group/firewall to your forensic IPs only. Don't power it off yet (memory is evidence).
- Capture volatile data:
ss -tanp > /tmp/ir/conns.txt
ps auxwwf > /tmp/ir/ps.txt
ls -l /proc/*/exe 2>/dev/null | grep deleted > /tmp/ir/deleted-exe.txt
last -F > /tmp/ir/last.txt
- Snapshot the disk (EBS snapshot) for offline forensics.
- Check persistence: crontabs, systemd units,
~/.ssh/authorized_keys,/etc/ld.so.preload, new users. - Rebuild from a known-good image, rotate every credential the host had, and patch the entry point.
Why → You can't trust a compromised kernel or binaries; rebuilding is the only clean state.
Interview tip → Say "isolate, preserve, investigate, rebuild, rotate", and that you'd involve the security team immediately.
More on Security, hardening and incident response
After the compromise you need to find how the attacker got in. Where do you look?AdvancedYour CISO asks you to harden a fresh Linux server baseline. What's on your list?IntermediateA developer says "SELinux keeps breaking my app, can we just disable it?" How do you respond and what do you do?IntermediateYou need to know when anyone modifies `/etc/sudoers`, `/etc/passwd` or SSH config. How?IntermediateA critical OpenSSL CVE is announced. How do you find and patch affected servers quickly?IntermediateHow do you make sure only signed, approved packages can be installed on your servers?Intermediate