The idea
Solene runs the Harwick Shipping Forum, a community site where dock workers and freight firms swap news. A contact at Meridian Freight says their staff are being compromised, and the one thing those staff share is that they read Harwick's forum. That is the shape of a watering-hole attack. The attacker does not phish the target. They poison a site the target already trusts, and fire only for the target. To everyone else, the admin included, the site looks clean.
Solene has to find an injection that hides by being selective. Everything here is inert (marker
WATERHOLE-LAB-INERT): the injected script only calls the lab's own collector, and the cookie it takes is a lab
token. What such an injection leads to, like a harvested login, is covered in other labs.
Here the case is the selectivity itself.
Steps
-
The forum looks perfectly clean
Start the way Solene first checked, and the way the attacker expects an admin to check: load the page.
curlfetches the forum's HTML and prints it, running nothing.An injection shown to every visitor would be found in a day. So the first look at a selective injection is almost always clean, and that is what makes it dangerous.
Read the forum as an ordinary visitor. Look at the bottom of the page, where added scripts usually sit.
laptop:~# curl -sS http://10.0.1.25/
-
Not clean for the target
The tip said Meridian Freight's staff are the ones being hit. On this forum a logged-in member's browser sends a profile cookie that names their employer:
org=meridianfor a Meridian member. A watering hole aimed at them would key on that value. It would serve the clean page to everyone, and the poisoned page to anyone whose cookie says they are the target.You can test that without being a Meridian member, by sending the cookie a member's browser would.
curl -Hadds a request header, so-H "Cookie: org=meridian"asks for the page as a targeted member. Request it that way and compare it to the clean version.laptop:~# curl -sS -H "Cookie: org=meridian" http://10.0.1.25/
-
Read the condition in the server
You have seen both faces of the page. Now read what decides which face a visitor gets. The page source cannot tell you, because the choice is made on the server, per request, before the HTML is sent. Solene runs this forum, so she can read its code.
catprints the server program, running nothing.Look for the branch: a line that reads the request's cookie and picks the poisoned page for one value. That single
ifkeeps the injection invisible to everyone but the target.forum:~# cat /opt/forum.py
-
Watch it fire for a real member
Now let a targeted member load the forum and watch the request leave. A Meridian member's browser is open on this sealed network. It carries the
org=meridiancookie and reopens the forum as a member would, so it is served the poisoned page and runs the script.This is safe only because the network is isolated. Watching real traffic on a system whose owner has not authorised you in writing can break the law, even when you only meant to look.
The lab records the wire at the collector: the traffic arriving on its web port. You also read the collector's socket table. A browser that has made its request and closed leaves a
TIME-WAITsocket on port 80 for a short while. ATIME-WAITplus the request in the capture means a targeted member's browser reached the attacker.collector:~# ss -ant
-
The verdict, and closing it
The verdict is a watering hole. A trusted site that Solene runs was injected with a script that fires only for the target company's members and sends their cookie to an attacker. "It looks fine to us" is worth nothing when the attack is built to look fine to all but the target.
Closing it takes three moves. Remove the injected branch and the script. Then fix how it was written: someone got write access to the site, through a stolen admin login or a vulnerable plugin, and the injection comes back if that stays open.
Last, make a silent change loud. A Content Security Policy is a header that lists which hosts a page may talk to, so the browser refuses a request to an outside collector. Subresource Integrity pins a script file to a hash, so a swapped file does not run. Both turn a quiet injection into a blocked request.
Find the injection by its behaviour, and record the indicator.
forum:~# grep -n org=meridian /opt/forum.py
Run these steps on real machines