Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

Segmentation that limits the damage

After this lesson: I can split access so that one stolen account reaches only part of the data.

60 min lesson10 commandsIncident response and forensics lab: investigate a compromised server in your browser

A quick check that you are not a bot, then your own lab opens on the interactive lesson.

Already have an account? Sign in

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

WordWhat it meansExample
Segmentationsplitting systems so a fault cannot spread
Blast radiushow much one compromise can damage
Groupa set of accounts given the same accesskfront
Zonea part of a network with its own rules
Flat networkone where every machine can reach every other

The cells students fill in are left blank in this preview.

Starter

Have a go

Starter

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

The 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

Command
cd ~/rr && ls mkshare.py manifest.py drill.py compare.py

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Put the drill where others can run it

Command
sudo install -D -m 755 drill.py /opt/rr/drill.py

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Make two staff accounts, each in a group

Command
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 payroll

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Build the share open to everybody

Command
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/kestrel

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

See which folders each account can change

Command
for u in reception payroll; do echo "$u can change:"; sudo -u $u find /srv/kestrel -mindepth 1 -maxdepth 1 -writable; done

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Run the drill as reception

Command
sudo -u reception python3 /opt/rr/drill.py /srv/kestrel

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Check

Have a go

Check

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Split 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

Command
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/kestrel

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

See which folders each account can change now

Command
for u in reception payroll; do echo "$u can change:"; sudo -u $u find /srv/kestrel -mindepth 1 -maxdepth 1 -writable; done

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Run the drill as reception again

Command
sudo -u reception python3 /opt/rr/drill.py /srv/kestrel

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Look in the payroll and client folders

Command
sudo ls /srv/kestrel/payroll | head -3; sudo ls /srv/kestrel/clients | head -3

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Check

Have a go

Check

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Networks 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

FromToAllowed?Why
Staff laptopsFile serverYesPeople need their files
Staff laptopsOther staff laptopsNoStops one laptop reaching the rest
Staff laptopsBackupsNoA stolen account cannot delete them
Backup serverBackupsYesOnly it writes them
Admin zoneEverythingYesUsed 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?

Code: python
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.

Code: python
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

Exit quiz

5 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Teaching a class? Set this module for your students with a teacher guide, marked assignments and a lab for every student.