One click at reception
The receptionist at a small firm opens a fake invoice. Their account can open every folder on the server, so everything is locked by lunch.
If that account could reach only reception's folders, payroll and the client files would still work. That is what segmentation buys.
By the end of this lesson
Note
I can split access so that one stolen account reaches only part of the data.
Key words
| Word | What it means | Example |
|---|---|---|
| Segmentation | splitting systems so a fault cannot spread | |
| Blast radius | how much one compromise can damage | |
| Group | a set of accounts given the same access | kfront |
| Zone | a part of a network with its own rules | |
| Flat network | one where every machine can reach every other |
The cells students fill in are left blank in this preview.
Starter
Have a go
Starter
3 questionsThe one rule
Important
The drill runs only in your own lab copy, as made-up accounts you create, on sample files. Never run anything like it on a real machine without written permission. Unauthorised access to a computer, or changing its data, is an offence under the Computer Misuse Act 1990.
An open share has the largest blast radius
Ransomware runs as the account it stole. If every account may change every folder, one account locks the lot. Its blast radius is the whole share.
You make two staff accounts, reception and payroll, each in its own group. Then you build the share open to everybody and run the drill as reception.
Check lesson 1's scripts are here
cd ~/rr && ls mkshare.py manifest.py drill.py compare.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
Put the drill where others can run it
sudo install -D -m 755 drill.py /opt/rr/drill.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
Make two staff accounts, each in a group
getent group kfront > /dev/null || sudo groupadd kfront; getent group kpay > /dev/null || sudo groupadd kpay; id reception > /dev/null 2>&1 || sudo useradd -m -G kfront reception; id payroll > /dev/null 2>&1 || sudo useradd -m -G kpay payroll; groups reception payrollShown here, not run. Press Start lab to type it into your own lab’s terminal.
Build the share open to everybody
sudo rm -rf /srv/kestrel && sudo install -d -o student -m 755 /srv/kestrel && python3 mkshare.py /srv/kestrel && sudo chmod -R a+rwX /srv/kestrelShown here, not run. Press Start lab to type it into your own lab’s terminal.
See which folders each account can change
for u in reception payroll; do echo "$u can change:"; sudo -u $u find /srv/kestrel -mindepth 1 -maxdepth 1 -writable; doneShown here, not run. Press Start lab to type it into your own lab’s terminal.
Run the drill as reception
sudo -u reception python3 /opt/rr/drill.py /srv/kestrelShown here, not run. Press Start lab to type it into your own lab’s terminal.
Check
Have a go
Check
3 questionsSplit the share by who needs what
Reception needs the client files and letters. Payroll needs the payroll folder. Nobody else needs either.
So each folder belongs to one group, and other accounts get nothing. You own the folders as the administrator, so you keep full access. That is why an admin account is never used for everyday work.
Build the share split by group
sudo rm -rf /srv/kestrel && sudo install -d -o student -m 755 /srv/kestrel && python3 mkshare.py /srv/kestrel && sudo chgrp -R kfront /srv/kestrel/clients /srv/kestrel/letters && sudo chgrp -R kpay /srv/kestrel/payroll && sudo chmod -R u=rwX,g=rwX,o= /srv/kestrel/clients /srv/kestrel/letters /srv/kestrel/payroll && ls -l /srv/kestrelShown here, not run. Press Start lab to type it into your own lab’s terminal.
See which folders each account can change now
for u in reception payroll; do echo "$u can change:"; sudo -u $u find /srv/kestrel -mindepth 1 -maxdepth 1 -writable; doneShown here, not run. Press Start lab to type it into your own lab’s terminal.
Run the drill as reception again
sudo -u reception python3 /opt/rr/drill.py /srv/kestrelShown here, not run. Press Start lab to type it into your own lab’s terminal.
Look in the payroll and client folders
sudo ls /srv/kestrel/payroll | head -3; sudo ls /srv/kestrel/clients | head -3Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Check
Have a go
Check
3 questionsNetworks are split into zones too
The same idea works for networks. In a flat network every machine can reach every other, so an attacker hops freely.
Split it into zones with rules between them: staff laptops reach the file server, not each other. Only the backup server reaches the backups, and admin work comes from its own zone.
Worked example: Kestrel's zones
| From | To | Allowed? | Why |
|---|---|---|---|
| Staff laptops | File server | Yes | People need their files |
| Staff laptops | Other staff laptops | No | Stops one laptop reaching the rest |
| Staff laptops | Backups | No | A stolen account cannot delete them |
| Backup server | Backups | Yes | Only it writes them |
| Admin zone | Everything | Yes | Used only for admin work, with a second step |
The cells students fill in are left blank in this preview.
A common mistake
Warning
Many people think a firewall at the edge stops ransomware spreading. It only watches traffic in and out. Once one machine inside is taken, a flat network lets the attacker reach the rest. Rules between zones inside are what slow them.
Try it: which zones can a laptop reach?
rules = {"workstations": ["files"], "files": [], "admin": ["files", "backups", "workstations"], "backups": []}
start = "workstations"
seen, todo = set(), [start]
while todo:
for zone in rules[todo.pop()]:
if zone not in seen:
seen.add(zone)
todo.append(zone)
print(start, "can reach", sorted(seen))
# Add "admin" to the workstations list, then press Run.
Make a free account to save your work and track your progress.
The fix and how to detect it
The fix is access split by need, for files and for networks, with admin accounts kept apart and used only for admin work.
Detect one account changing files in many places at once, and connections between staff laptops. Both are rare in normal work.
Assignment: work out the blast radius
rules is a list of (from_zone, to_zone) pairs: each says the first zone may connect to the second.
reachable(rules, start) returns the sorted zones that start can reach, directly or through other zones. It does not include start itself.
blast_radius(rules, start, files) returns how many files an attacker in start could reach: the files in start and in every zone it can reach. files maps a zone to its number of files; a zone missing from it has none.
risky(rules, zone, allowed) returns the sorted zones that connect directly to zone but are not in the list allowed.
def reachable(rules, start):
return []
def blast_radius(rules, start, files):
return 0
def risky(rules, zone, allowed):
return []
Make a free account to save your work and track your progress.
Exit quiz
Have a go