I run my business on a single VPS — Debian 12, nginx, CloudPanel. In thirteen months it was hacked three times, and I never wiped it — every attack was traced to a specific cause, the vulnerability was addressed, and a specific fix was designed and implemented.

I am a database application developer, and the production VPS in this story is the one I run myself. Everything below is told from the server logs and the malware specimens themselves.

Hack #1 — The door I never used

Before the first hack, I had almost nothing in place. No file-change history. No function restrictions. If you don't know, you don't know.

My nginx configuration had a missing-file fallback I never used — the pretty-URL behavior, on by default, where a request for a page that does not exist gets routed to index.php. An attacker used it to invent URLs on my domain at will.

He used it to generate more than 60,000 spam pages, on demand, per request — flawless formatting, real product data, links to stores where the products were actually for sale. It looked as if my site endorsed them. My real pages were never touched, and I bounced around the site testing things for about two weeks with no clue the extra pages were being served right alongside mine.

The payload never existed as a PHP file. It lived inside a zip archive in the web root, pulled in by one line injected at the top of my homepage. The doorway pages didn't need even that. The attacker had scattered files named Index.php — capital I — through my folders, and my configuration served those first: a request for a page that didn't exist ran his file, not mine. My own server did the advertising, too: the payload rewrote my robots.txt to list twenty-five numbered sitemaps full of spam URLs. Nobody had to touch my Search Console — the server advertised its own poison.

When I cleared it out, it came back. In January the persistence surfaced: a poisoned setting injected into every PHP configuration on the server, and a cron job re-injecting it every five minutes. The attacker needed my server up and working. A dead server serves no spam. The consequences ran for months. Finding the loader took detective work; finding the January persistence took more.

Lesson: a fallback you don't use is a door you didn't know was open. And check cron — hacks come back after you "fixed" them.

Hack #2 — The sample file

The second hack came through a sample script that shipped with CloudPanel. It came in with the configuration I selected in the Vultr server creation wizard, and I never removed it. The attacker used it to plant a cron job whose whole purpose was to bring back a malicious server configuration change.

This one I found by accident, in Google Search Console, looking at a live page the way Google sees it: tennis shoes and barbecue grills tacked onto the tail end of my page. Someone else's products, riding on my domain's credibility.

The detective work went like this: a bot hammering the panel login — something like 1,500 distinct address variations in a very short window — gave me the timeframe. I searched the server for files changed inside that window, and the cron job fell out.

What made that search possible: during the first hack, I had installed auditd, a tool that keeps a history of file changes. The first investigation had been blind forensics. This one took an afternoon.

Lesson: sample and example files are attacker tooling — whether you installed them or they arrived with your panel. Delete every one.

Hack #3 — The whitelist that couldn't tell

The third hack rode in on an IP whitelist — mine. I had whitelisted the Starbucks public address so I could reach the panel from the café, and I was working there the day of the break-in.

What I found was my own page replaced wholesale with Indonesian gambling spam — cloaked by geography and audience, so my own visits never showed it. auditd's record showed when the malware files were modified. The access logs did the rest: their timestamps, the malware files' dates, and my own timestamps from what I was working on at Starbucks that day all coincide exactly. The logs traced the break-in to the café.

A café puts everyone on its Wi-Fi behind one public address. The attacker came from that same address, so the whitelist let him straight through. A whitelist that can't tell me apart from the stranger at the next table is not access control.

The panel now sits behind Tailscale — software I installed on the server and on my own devices, which puts them on a private network only they can join. There is no public panel address anymore, and nothing for a whitelist to judge.

Lesson: a whitelist judges the address, not the person behind it.

The tool I now install first

auditd. Debian keeps no history of file changes by itself. auditd is the flight recorder: install it on day one, before you need it, and configure it to watch the folders that matter. You cannot reconstruct an incident without a record — the difference between my first investigation and my second is the whole argument.

Three hacks produced a thirteen-change hardening checklist, every change documented with the incident that taught it. The full story and the checklist:

Three Hacks, Zero Wipes — the guide I sell

If you run a Linux server: when was something on it last changed, and who or what changed it — and could you prove it?