This was a small cloud VPS that had been up for 1,348 days without a reboot. It hosted a website, a couple of Node.js apps and a lot of leftovers from old experiments. Before changing anything, the first question was whether it had been compromised.
Below is how I went about it, what I found, and what the logs could not tell me.
All identifying details (domain, IPs, file and account names) are removed or generalized.
Scope and ground rules
- Read-only first. Nothing on the host changes until the investigation phase is done. Remediation comes after, one approved step at a time.
- Preserve before you touch. A provider-level snapshot is the right first move; it lets you investigate a copy offline later.
- Order of volatility (RFC 3227). Processes and network connections first, then persistence, then logs, then the filesystem.
- Don’t trust the host’s own tools blindly. A rootkit can lie to
psandnetstat, so cross-check where you can.
Phase 1: Live triage
| Check | How | Result |
|---|---|---|
| Hidden processes | ps count vs. entries in /proc |
Equal, nothing hidden |
| Processes running from writable dirs | executables under /tmp, /dev/shm, /var/tmp |
None |
| Processes with deleted executables | ls -l /proc/*/exe | grep deleted |
9 hits, all system daemons that were updated on disk but never restarted |
| Outbound connections | ss -tnp |
Only the investigation’s own SSH session |
The “deleted executable” hits are a common false positive on machines with long uptime: the packages were upgraded but the old binaries were still running. Not malicious, but it meant years of patches had never actually been loaded.
Phase 2: Persistence
I went through the usual Linux persistence locations (MITRE ATT&CK TA0003):
- Extra UID 0 accounts,
/etc/passwdand/etc/shadowchanges ld.so.preload,rc.local, cron (system and per-user), systemd units and timers- PAM stack, sudoers, SSH
authorized_keys - SUID binaries not owned by any package
Results:
- Clean: no extra UID 0, no preload, no unusual cron, standard PAM.
- SUID false positives: a few SUID binaries looked “unpackaged”. On distributions with
usrmerge,/usr/bin/suis recorded in the package database as/bin/su.dpkg -Son the canonical path resolved them all. - Worth a closer look: an inactive third-party agent from an old evaluation, desktop and VPN leftovers, and four SSH keys in root’s
authorized_keys, one of which no longer had a clear owner.
Phase 3: Logs
- SSH: every successful login used a known key from known source addresses. No password logins, no new users, no unexpected
sudo. - Web server:
- Thousands of requests to
.phppaths returned200with 0 bytes. An old port-80 server block answered every unknown request with an empty200. That fooled scanners and also cluttered the logs. A misconfiguration, not a breach. - Requests like
/?file=../../.envalso returned200, but those were the 749-byte home page; the query string was ignored.
- Thousands of requests to
Phase 4: File integrity
dpkg -Vshowed no modified package files, apart from expected configuration changes.- No webshell patterns in the web roots; old research samples were present but stored with non-executable extensions and never requested.
- Unpackaged files in
/usr/local/binwere allpip/gementry points from years earlier.
What I actually found
No compromise, but a lot of things left open:
| # | Finding | Why it matters |
|---|---|---|
| 1 | A MongoDB container published on 0.0.0.0:27017 for four months |
1,530 unique external IPs, 11,510 connections. Authentication held: no successful external logins, no drops, no ransom notes. Docker publishes ports through its own iptables rules, so the host firewall did not apply. |
| 2 | An app’s source tree inside the web root | .env (database URI, JWT secret) and .git/config were downloadable. The git remote URL contained a personal access token. |
| 3 | SMB/NetBIOS listening on all interfaces | Old firewall rules allowed it the moment the firewall was enabled. |
| 4 | Disk 100% full | Crashed the database; also stops logging and certificate renewal. |
| 5 | Kernel unpatched for 3.7 years, OS out of standard support | Every local privilege-escalation bug from that period applies. |
| 6 | A full desktop environment on a server | Hundreds of packages and daemons (mDNS, printing, display manager) with no purpose. |
Mapping to MITRE ATT&CK (what an attacker could have used)
| Exposure | Technique |
|---|---|
| Internet-facing database and SMB | T1190 Exploit Public-Facing Application |
Credentials in .env and .git/config |
T1552.001 Unsecured Credentials: Credentials in Files |
| Leaked database and API credentials | T1078 Valid Accounts |
| Stale, unowned SSH keys | T1098.004 Account Manipulation: SSH Authorized Keys |
Verdict and its limits
No evidence of compromise in the available data, with moderate confidence.
The limit is retention. SSH logs went back about four weeks and web logs only 14 days, while the most sensitive files had been publicly reachable for over a year. Absence of evidence in a 14-day window says nothing about the year before it. So every exposed secret was treated as compromised and rotated anyway. A full answer would need offline analysis of a snapshot and memory forensics, which this engagement didn’t include.
Remediation
- Close the doors: firewall default-deny, only HTTP/HTTPS/SSH open; SMB, the stray VPN and mDNS disabled; the database re-bound to
127.0.0.1. - Web server: hidden files, source trees and backup/config extensions return
404; version banner off; TLS 1.0/1.1 off; HSTS and other security headers on. The empty-200catch-all now closes the connection (444). - Rotate everything that was exposed: database password, JWT secret, the git token. Old credentials verified to fail.
- Disk: removed about 11 GB of unused ML libraries, attack tools, snaps and archives, after backing up and verifying anything worth keeping.
- Upgrade: Ubuntu 20.04 → 22.04 → 24.04 in place, after removing 380 desktop packages to shrink the upgrade.
Lessons
- Exposed doesn’t mean compromised, but you need evidence to say so. State your confidence level and what you couldn’t see.
- Docker bypasses host firewalls. Publish only on
127.0.0.1unless something truly needs to be public. - Retention decides what you can prove. Fourteen days of logs can’t clear a year of exposure.
- Most of the time went into ruling out false positives: SUID paths under
usrmerge, deleted executables after upgrades, fake200responses. - Mistakes and surprises during the cleanup:
set -o pipefailplusgrep -qcan turn a successful command into a “failure”, becausegrepexits early and the writer getsSIGPIPE. In a password-rotation script this cost me the new password; I recovered by starting the database on the same volumes with no network attached and authentication off, and setting a known password. Rule since then: persist new secrets before you apply them.- A distribution upgrade can disable the host firewall. Check it immediately afterwards.
- On Ubuntu 24.04, SSH moves to socket activation. During the upgrade there was a ~17-minute window with no SSH listener. That was normal. I assumed it was broken at first; I should have kept reading the upgrade log.