Case study · anonymised

An intrusion on an online store, from alert to healthy prod

A compromised online store, an attacker who had been inside for months. Here is the investigation, phase by phase: the original log lines, what they mean, and why I made the calls I made.

In plain words: an attacker was stealing card data on the checkout page. I tracked it down, shut the attacker out, rebuilt the store elsewhere and set an alarm. On the second attempt the alarm went off and nothing got out.

No name, no date: only what happened and what I did about it.

Detect: abnormal behaviour in the checkout flow

Incident log

[detection] Abnormal behaviour in the checkout flow.

It starts with something off in the checkout flow, the pages where a customer types in their card.

A skimmer is quiet: it lives off payments going through, so it has no reason to break the store. That is what lets it last. Here, the attacker had been inside for months.

My rule: anything odd on a payment page is an incident until proven otherwise.

Investigate: a skimmer the CSP did not stop

Incident log

[investigation] Card skimmer: data exfiltrated over WebRTC, CSP nonce stolen. The CSP did not stop it.

A skimmer is a malicious script slipped into a payment page. It copies what the customer types, card number included, and sends it to the attacker.

The CSP (Content Security Policy) tells the browser which scripts may run and which servers the page may talk to. The store's policy was not enough, for two reasons.

First, the stolen nonce. A nonce is a random token, renewed on every page load: only scripts carrying it get to run. It proves a script came from the server, not that it belongs there. An attacker who can write to the server can reuse it for their own script.

Second, the exit over WebRTC. The connect-src directive governs fetch, XHR and WebSocket. WebRTC, the technology behind in-browser video calls, opens its own connections, which connect-src does not block.

A variant hidden in a blockchain

Incident log

[investigation] A variant hidden in a Polygon smart contract, with a fake “ClickFix” captcha.

A smart contract is a program published on a blockchain, Polygon in this case. For an attacker, keeping code there has one advantage: no hosting provider to send a takedown request to.

The fake “ClickFix” captcha is a bogus “prove you are human” check that gets the visitor to copy a command and run it on their own computer. A compromised site then becomes a trap for its own visitors.

Ways back in

Incident log

[investigation] 5 PHP backdoors, plus a reverse shell disguised as a system process and relaunched by cron.

A backdoor is a file left on the server so the attacker can return, even after the hole is fixed. A reverse shell is the hacked server calling the attacker and handing over a command line. This one posed as a system process, and cron kept relaunching it.

So removing the skimmer would have fixed nothing.

The cause: credentials in the wrong place

Incident log

[cause] SFTP credentials in the web root, one password reused across 5 services.

The web root is the folder the server publishes: credentials have no business being in it. And one password reused across 5 services turns one leak into five.

Until the cause is found, everything else is tidying up: the attacker comes back the same way.

Contain: cut access, keep the evidence

Incident log

[contain] Processes killed, attacker servers blocked, evidence preserved and hashed.

Cut: kill the attacker's processes and block their servers, so nothing else gets out. Keep: evidence is set aside before the clean-up, not after.

I hashed it: a fingerprint computed on each item lets you show later that it has not been touched.

Check who came in, log everyone out

Incident log

[audit] 360 SSH logins audited, 1,204 back-office sessions purged.

Auditing SSH logins means going back through the server's access history to separate the legitimate from the rest.

Purging back-office sessions, because changing a password does not necessarily log out someone who is already logged in. A stolen session is a key for as long as it stays valid.

Rebuild instead of cleaning up

Incident log

[decision] Rebuild on fresh hosting instead of cleaning up the compromised server.

Cleaning a compromised server is a bet that you found everything. With 5 backdoors already uncovered, I had no way to prove there wasn't a sixth, on a machine someone else had held for months.

A rebuild turns the problem around: you start from fresh hosting, a known state. It is the logic of my deployments: a known state, not a state that is presumed clean.

Monitor: the second attack

Incident log

[monitor] SHA-256 integrity checks every 15 minutes on about 43,500 files, with email alerts.

An integrity check computes the SHA-256 fingerprint of every file and compares it to a reference. A file gets modified or added, and the alert goes out.

It doesn't keep anyone out. It changes how long an intruder has before being seen.

The alarm went off

Incident log

[2nd attack] 3 webshells caught: 278 files quarantined, no data exfiltrated.

[status] Prod healthy. Monitoring active.

The attacker came back. A webshell is a backdoor driven from a browser: 3 were caught, and no data got out.

The first time, the attacker had months. The second time, the alarm went off.

What I take from it

What it says about how I work: I don't stop at the first culprit. I trace the cause, keep the evidence, rebuild instead of cleaning up, and leave monitoring behind me. It got used.

What it changes for you

The day it happens, you already have someone on the team who has done it. The rest of the time, someone hunting the holes first.

The habit didn't stop at that store: my in-house tool now monitors 44 sites and alerts me when a file changes for no reason.

2 intrusions handled end to end, the second one stopped by my own detection. 17 audit findings on a site taking payments, 5 critical ones fixed.

Want to talk about it?

If you are looking for someone who owns production and can run an incident, write to me. I'm open to opportunities, remote preferred.