Scenario test · 75 minutes
Review the security of a small company
- Rank the risks of a small company from a scored asset list
- Find the accounts, the login pattern and the changed file that need action
- Write a one-page review report that cites its evidence
The lab folder as it stands after this lesson. Unzip it in ~/krlab.
More
The zip holds every file that the course has printed up to here. To start this lesson with the files of the earlier lessons only, take the zip of the lesson before. Type the code yourself first: you learn more.
Scenario
Harbour Tea Co. sells loose-leaf tea online. It has 14 staff and one person who left last month: three in sales, four in the warehouse, three in finance, two in support and two in IT. The web shop and its customer database run on one rented server, krbox. Staff log in to krbox over SSH with a password. Finance prepares payments to suppliers from files on that server.
The owner writes to you: "We have never had a security review. We have a few rules, but I do not know whether we keep them. Look at what I give you, tell me what matters most, and tell me what to do." The rules of the owner:
- Only IT staff may hold the
adminrole. - Nobody who has left the firm may keep an enabled account.
- Nobody may both create and approve a payment.
- Five or more failed logins from one address, followed by a success, need a response.
- The supplier and price files must not change without a record.
You get the data from a program with a fixed seed, so that everyone who does this test sees the same data. Save the program as make_company.py and run it with Python. It makes the folder ~/krlab/security-basics/review with these files:
| File | What it is |
|---|---|
assets.csv | The asset list, in the format of lesson 1: likelihood and impact are scored 1 to 5. |
roles.csv | Each role and its permissions. |
users.csv | Each account: department, roles, whether the person is employed, and whether the account is enabled. |
logins.log | One week of SSH logins on krbox, in the format of lesson 6. |
price-list.csv, supplier-bank.csv | Two files that finance uses. |
SHA256SUMS | The hashes of those two files, made last Monday. |
- Staff → krbox: log in over SSH with a password
- Unknown address → krbox: guesses passwords
- krbox → Customer database: the web shop reads and writes
- krbox → Payment files: finance prepares payments
make_company.py
import csv
import hashlib
import os
import random
from datetime import datetime, timedelta, timezone
random.seed(2026)
out = os.path.expanduser("~/krlab/security-basics/review")
os.makedirs(out, exist_ok=True)
os.chdir(out)
# 1. The asset list: (asset, threat, weakness, likelihood range, impact)
assets = [
("Payment batch files", "Fraud with changed bank details", "No second check of supplier accounts", (4, 4), 5),
("Staff accounts on krbox", "Password guessing", "Passwords only, no second factor", (4, 4), 4),
("Shop backups", "Ransomware encrypts them", "Copies sit on the same server", (3, 3), 5),
("Web shop", "Defacement or downtime", "Old shop plugin, no update plan", (3, 3), 4),
("Customer database", "Theft of the database", "On the shop server, backups not encrypted", (2, 2), 5),
("Warehouse stock sheet", "Accidental deletion", "No version history", (2, 3), 2),
("Office Wi-Fi", "Guest joins the staff network", "One network for everyone", (2, 3), 2),
("Support laptops", "Theft from a car", "Disks are not encrypted", (1, 2), 3),
]
with open("assets.csv", "w", newline="") as f:
w = csv.writer(f)
w.writerow(["asset", "threat", "vulnerability", "likelihood", "impact", "control"])
for name, threat, weak, (lo, hi), impact in assets:
w.writerow([name, threat, weak, random.randint(lo, hi), impact, "none yet"])
# 2. Roles and users
roles = {
"sales": "order:read;order:create",
"stock": "stock:read;stock:update",
"helpdesk": "order:read;customer:read",
"clerk": "payment:read;payment:create",
"approver": "payment:read;payment:approve",
"admin": "user:manage;server:admin",
}
with open("roles.csv", "w", newline="") as f:
w = csv.writer(f)
w.writerow(["role", "permissions"])
for role, perms in roles.items():
w.writerow([role, perms])
users = [ # user, department, roles, employed, enabled
("ana", "sales", "sales", "yes", "yes"),
("ben", "sales", "sales", "yes", "yes"),
("cai", "sales", "sales", "yes", "yes"),
("pia", "sales", "sales", "no", "yes"),
("dev", "warehouse", "stock", "yes", "yes"),
("eli", "warehouse", "stock", "yes", "yes"),
("fay", "warehouse", "stock", "yes", "yes"),
("gus", "warehouse", "stock;admin", "yes", "yes"),
("hal", "finance", "clerk", "yes", "yes"),
("ivy", "finance", "approver", "yes", "yes"),
("jon", "finance", "clerk;approver", "yes", "yes"),
("kim", "support", "helpdesk", "yes", "yes"),
("lou", "support", "helpdesk;admin", "yes", "yes"),
("max", "it", "admin", "yes", "yes"),
("ned", "it", "admin", "yes", "yes"),
]
with open("users.csv", "w", newline="") as f:
w = csv.writer(f)
w.writerow(["user", "department", "roles", "employed", "enabled"])
w.writerows(users)
# 3. One week of logins on krbox, Monday 2026-11-16 to Sunday 2026-11-22
start = datetime(2026, 11, 16, 0, 0, 0, tzinfo=timezone.utc)
events = [] # (seconds after start, result, user, address)
for n, (user, dept, _, employed, _) in enumerate(users):
if employed == "no":
continue
ip = f"192.0.2.{10 + n}"
for day in range(5):
for _ in range(random.randint(1, 2)):
t = day * 86400 + random.randint(7 * 3600, 18 * 3600)
if random.random() < 0.15:
events.append((t, "Failed", user, ip))
t += random.randint(3, 8)
events.append((t, "Accepted", user, ip))
events.append((3 * 86400 + 10 * 3600, "Accepted", "pia", "192.0.2.99")) # the person who left
for i in range(12): # a scanner on Tuesday that never gets in
events.append((86400 + 14 * 3600 + i * 6, "Failed", "root", "198.51.100.9"))
for i in range(9): # guessing against max on Thursday night, then a success
events.append((3 * 86400 + 3 * 3600 + 12 * 60 + i * 4, "Failed", "max", "203.0.113.99"))
events.append((3 * 86400 + 3 * 3600 + 12 * 60 + 40, "Accepted", "max", "203.0.113.99"))
with open("logins.log", "w") as f:
for i, (t, result, user, ip) in enumerate(sorted(events)):
stamp = (start + timedelta(seconds=t)).strftime("%Y-%m-%dT%H:%M:%SZ")
f.write(f"{stamp} krbox sshd[{7000 + i}]: {result} password for {user} from {ip}\n")
# 4. Two files and the list of their hashes from last Monday; one file was changed since
good = {
"price-list.csv": "item,price\ngreen tea 100g,6.50\nblack tea 100g,5.90\nchai blend 100g,7.20\n",
"supplier-bank.csv": "supplier,account\nHillside Estates,20-45-67 31926819\nRiver Packaging,40-11-52 70458213\n",
}
with open("SHA256SUMS", "w") as f:
for name, text in good.items():
f.write(f"{hashlib.sha256(text.encode()).hexdigest()} {name}\n")
good["supplier-bank.csv"] = good["supplier-bank.csv"].replace("31926819", "31926891")
for name, text in good.items():
with open(name, "w") as f:
f.write(text)
print("wrote the review files in", out)Everything runs on your own machine, on files that the program made. Use the scripts that you wrote in the course (risk.py in ~/krlab/security-basics, detect.py in the logs folder, and the tools of lessons 2 and 4). Work in the review folder and name the scripts by their path, for example python3 ../risk.py assets.csv and python3 ../logs/detect.py logins.log. If you did not do the earlier lessons, build the lab from the zip: in the folder that holds kr-lab.sh, run sh kr-lab.sh 09-scenario-test ~/krlab/security-basics. It puts risk.py, logs/detect.py and make_company.py in place. No step is given.
Your tasks
1. Rank the risks
Score every row of assets.csv and put the register in order. The owner has money for the top three only.
2. Check the accounts against the rules
Join users.csv and roles.csv: a person holds the permissions of all their roles. The table has 15 rows, so you may check it by eye or with a short script. Check rules 1, 2 and 3.
3. Find the login that needs a response
Read the week of logins with your detector, and with plain tools. Check rule 4. Then look for what the detector cannot see on its own: use what task 2 told you.
4. Check the integrity of the two files
Check rule 5 against the list of hashes.
5. Write the report
Combine your results in the report described below.
Hand in
Write a one-page review report in a file review.md. It is the proof that you can show to an employer: it shows that you can find a problem, prove it and say what to do. Give it the title "Security review of Harbour Tea Co." and these four headings, in this order:
| Heading | What goes under it |
|---|---|
| Top risks | The three risks that matter most, each with its number, in plain words for the owner. |
| Findings with evidence | Each finding: what is wrong, which rule or goal it breaks, and the evidence (a file name, a line, a count or a hash) that anyone can check. |
| Recommended controls | For each top risk and each finding, one control, in the order to do them, and who does it. |
| What I did not check | What was out of reach or out of scope, so that the owner does not think it is safe. |
Keep it to one page, about 400 words. Write for the owner: no jargon without an explanation.
Review your work
First compare your answers with the check blocks above. Then compare your report with this model.
Model answers and a model report
The results:
- Risk ranking: Payment batch files 20, Staff accounts on krbox 16, Shop backups 15, Web shop 12, Customer database 10. Three are HIGH. The other three rows score 6, 6 and 3.
- Accounts:
gus(warehouse) andlou(support) hold the admin role outside IT.jonholds the roles clerk and approver, so he can create and approve a payment.piahas left and her account is enabled. - Logins: one alert, for
maxfrom203.0.113.99on 2026-11-19 at 03:12:40 UTC, after 9 failures in 32 seconds. The detector does not say thatpialogged in once, on 2026-11-19 at 10:00 UTC, from192.0.2.99: a leaver's account was used. The scanner at198.51.100.9failed 12 times on Tuesday and never got in. - Integrity:
supplier-bank.csvfails.price-list.csvis unchanged. The file now gives the account of Hillside Estates as 20-45-67 31926891. The first version is not on the machine, so the supplier must confirm the right number.
A model report (in your file, make the four bold lines into headings):
Security review of Harbour Tea Co.
**Top risks**
1. Fraud with changed bank details on payment files (risk 20). One supplier
account number has already changed without a record.
2. Password guessing against staff accounts on krbox (risk 16). One guessing
attack succeeded against the account max on 19 November.
3. Ransomware on the shop backups (risk 15). The copies sit on the same server.
**Findings with evidence**
- The supplier file changed: supplier-bank.csv fails its hash in SHA256SUMS
(current hash starts 79c145c5). Goal broken: integrity. Rule 5.
- The account max was guessed: 9 failures from 203.0.113.99 between 03:12:00
and 03:12:32 UTC, then a success at 03:12:40 (logins.log). Rule 4.
- The account of a leaver, pia, is enabled and logged in on 19 November at
10:00 UTC from 192.0.2.99 (users.csv, logins.log). Rule 2.
- Two accounts outside IT hold admin: gus (warehouse) and lou (support).
Least privilege. Rule 1.
- jon holds clerk and approver, so he can create and approve a payment.
Separation of duties. Rule 3.
**Recommended controls**
1. Today: disable pia, reset the password of max, block 203.0.113.99, and
check what max did after 03:12 (IT).
2. This week: confirm the bank details of Hillside Estates with the supplier
by phone, and restore the file from a trusted copy (finance).
3. This week: remove admin from gus and lou, and remove approver from jon (IT).
4. This month: a second factor for every login to krbox, and a copy of the
backups on a different system that krbox cannot change (IT).
5. Monthly: run the hash check and the account check again and keep the output.
**What I did not check**
The web shop code and its plugin, the customer database settings, the office
Wi-Fi, the laptops, and whether the backups restore. I used the files that I was
given and no other source, so the scores of the assets are the owner's estimate.Mark your report
You mark this yourself, or you ask a colleague or a mentor to mark it. The page checks the numbers above; it cannot read your report.
| Criterion | Not yet | Meets the standard | Strong |
|---|---|---|---|
| Top risks | No numbers, or the wrong order. | Payment files 20, staff accounts 16, backups 15, in plain words. | Links each top risk to a finding that shows it. |
| Findings | A finding is missing, or names no rule. | All five: changed bank file, max guessed, pia used, two admins, jon. | Also the failed scanner, and why it needs no action. |
| Evidence | A finding is an opinion. | Each finding cites a file, a count, a hash or a time. | Another person checks every finding from the report alone. |
| Judgement | Claims more than the evidence, such as "pia is the attacker". | Says what was not checked, and that the bank number needs the supplier. | Says the asset scores are the owner's estimate. |
| Controls | Vague, such as "improve security". | In order, each with an owner; the first can be done today. | Each control names the risk or rule it closes. |
| Writing | Unexplained jargon, or over one page. | Dated, about 400 words; the owner can act on it. | Neutral words about staff; facts, not blame. |
Meets the standard in every row: you can show this report as a work sample. Remove names and data that are not yours to share.
The report shows your work on this scenario, done on your own machine without a proctor. It does not show work on a real company's systems.
Where to go next: this course used a network only as a place where logins come from. The Networking course shows firewalls, segmentation and a default-deny rule on a network. The Web applications course shows how the weak spots of lesson 7, such as injection and broken access control, are found and fixed in a web service.