Lesson 07 · 40 minutes
Review access against HR data and record the decisions
- Describe the joiner, mover and leaver process and where it fails
- Find orphan, leaver, over-privileged and dormant accounts with a program
- Record a decision for every finding and check that the review is complete
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
The access control standard of Brindle Books says: "Access rights are reviewed every quarter. A leaver's accounts are disabled within one working day." Jonas asks for the last review. There is none on file. Carys decides to run the first one today, and she wants it done in a way that can be repeated: export the accounts, compare them with the staff list from HR, find what does not fit, and let the right person decide about each case, on the record.
Recall
Lesson 6: which six questions does good audit evidence answer?
What it shows, from which system, who collected it, when, whether it is complete, and whether it is unchanged. The manifest records the source, the collector, the date and a hash.
Lesson 3: who decides who gets access to an asset?
The asset owner: the one named person who answers for the asset. The administrator gives the access as the owner decides.
The idea
People's access must follow their job. Three events change it, and together they are called joiner, mover, leaver (JML).
| Event | What must happen | What goes wrong |
|---|---|---|
| Joiner | The manager asks for the rights of the role, and no more | Rights are copied from a colleague who had too many |
| Mover | The rights of the new role are added, and those of the old role are removed | The old rights stay: access grows with every move |
| Leaver | Every account is disabled on the last day | Nobody tells IT, or one system is forgotten |
The process fails quietly, so a second control looks at the result. An access review compares the accounts that exist with the people and roles that should have them. The course "Security fundamentals" (lesson 4) taught the rule behind it: least privilege, the fewest rights that the job needs. The review finds four kinds of account that break it.
| Finding | Meaning |
|---|---|
orphan | The account belongs to nobody on the staff list |
leaver | The person left, and the account still works |
excess | The person has a system or a level that their role does not allow |
dormant | Nobody has used the account for more than 90 days |
A finding is a question, and a person answers it. The decision is remove, reduce (lower the level) or keep with a reason. The manager of the person or the owner of the system decides. Nobody decides about their own access.
- IT → Reviewer: export of all accounts
- HR → Reviewer: staff list with roles and leavers
- Reviewer → Manager: findings to decide
- Manager → Reviewer: remove, reduce or keep, with a reason
- Reviewer → IT: decisions to apply
Worked example
Work in ~/krlab/security-governance.
1. Save the three exports
hr.csv is the staff list. Ines and Kofi left the company. Greta moved from finance to customer service in September. role_rights.csv says which system and which level each role may have. accounts.csv is the export of all accounts from the three systems.
hr.csv
person,role,status,manager,left_on
Asha,director,active,,
Ben,it,active,Asha,
Carys,operations,active,Asha,
Dev,developer,active,Carys,
Efe,finance,active,Asha,
Greta,service,active,Carys,
Hal,warehouse,active,Carys,
Ines,service,leaver,Greta,2026-10-30
Kofi,warehouse,leaver,Hal,2026-08-14role_rights.csv
role,system,privilege
director,shop-admin,user
director,payroll,user
it,shop-admin,admin
it,payroll,admin
it,warehouse,admin
operations,shop-admin,user
developer,shop-admin,admin
finance,payroll,user
finance,shop-admin,user
service,shop-admin,user
warehouse,warehouse,useraccounts.csv
account,person,system,privilege,last_login,enabled
asha,Asha,shop-admin,user,2026-11-18,yes
asha,Asha,payroll,user,2026-11-02,yes
ben,Ben,shop-admin,admin,2026-11-20,yes
ben,Ben,payroll,admin,2026-10-30,yes
ben,Ben,warehouse,admin,2026-11-12,yes
carys,Carys,shop-admin,admin,2026-11-19,yes
dev,Dev,shop-admin,admin,2026-11-20,yes
efe,Efe,payroll,user,2026-11-20,yes
efe,Efe,shop-admin,user,2026-05-02,yes
greta,Greta,shop-admin,user,2026-11-20,yes
greta,Greta,payroll,user,2026-09-01,yes
hal,Hal,warehouse,user,2026-11-20,yes
ines,Ines,shop-admin,user,2026-10-29,yes
kofi,Kofi,warehouse,user,2026-08-13,no
temp1,,warehouse,user,2026-11-10,yes2. Write the review program
findings looks at each enabled account and gives it at most one finding, the most serious first. {p["person"]: p for p in ...} builds a dictionary from the staff list, with the name as the key. rights.get((role, system)) looks up a pair of values and returns None when the role has no right on that system. problems then checks the decisions: every finding has one, with a known decision, a name and a date. Nobody decides about their own access. A leaver's account is never kept, and any keep has a reason.
access_review.py
"""access_review.py: review accounts against HR data, and check the recorded decisions.
python3 access_review.py find FOLDER list the findings
python3 access_review.py check FOLDER [DECISIONS] every finding needs a valid decision
FOLDER holds hr.csv, accounts.csv, role_rights.csv and access_decisions.csv.
"""
import sys
from pathlib import Path
from grc import TODAY, day, finish, load
DORMANT = 90 # days without a login
def findings(folder):
folder = Path(folder)
staff = {p["person"]: p for p in load(folder / "hr.csv")}
rights = {(r["role"], r["system"]): r["privilege"] for r in load(folder / "role_rights.csv")}
out = []
for a in load(folder / "accounts.csv"):
if a["enabled"] != "yes":
continue
person = staff.get(a["person"])
allowed = rights.get((person["role"], a["system"])) if person else None
if person is None:
kind = "orphan"
elif person["status"] == "leaver":
kind = "leaver"
elif allowed is None or (a["privilege"] == "admin" and allowed != "admin"):
kind = "excess"
elif (TODAY - day(a["last_login"])).days > DORMANT:
kind = "dormant"
else:
continue
out.append({"account": a["account"], "system": a["system"], "person": a["person"], "finding": kind})
return out
def problems(folder, decisions=None):
decided = {(d["account"], d["system"]): d for d in load(decisions or Path(folder) / "access_decisions.csv")}
found = []
for f in findings(folder):
name = f"{f['account']} on {f['system']} ({f['finding']})"
d = decided.get((f["account"], f["system"]))
if d is None:
found.append(f"{name}: no decision")
continue
if d["decision"] not in ("remove", "reduce", "keep"):
found.append(f"{name}: unknown decision: {d['decision'] or 'none'}")
if not d["decided_by"] or not d["decided_on"]:
found.append(f"{name}: the decision has no name or no date")
elif d["decided_by"] == f["person"]:
found.append(f"{name}: {d['decided_by']} decided about their own access")
if d["decision"] == "keep" and (f["finding"] == "leaver" or not d["reason"]):
found.append(f"{name}: kept for a leaver, or kept without a reason")
return found
if __name__ == "__main__":
if sys.argv[1] == "find":
rows = findings(sys.argv[2])
for f in rows:
print(f"{f['finding']:<8}{f['account']:<8}{f['system']:<11}{f['person'] or '(nobody)'}")
print("findings:", len(rows))
else:
finish(problems(*sys.argv[2:4]))The last line uses *sys.argv[2:4]: the star hands the one or two words after check to the function as separate arguments.
3. Find what does not fit
python3 access_review.py find .excess carys shop-admin Carys
dormant efe shop-admin Efe
excess greta payroll Greta
leaver ines shop-admin Ines
orphan temp1 warehouse (nobody)
findings: 5Five findings in 14 enabled accounts. Carys is an administrator of the shop, and her role allows only a user. Efe has not used the shop for more than 200 days. Greta still has payroll from her old job: the mover case. Ines left three weeks ago and her account works. Nobody knows who temp1 is. Kofi's account does not appear: it was disabled, so the leaver process worked for him.
4. Record the decisions
Each manager decides. Asha decides about Carys and Efe, Carys about Greta, Greta about her former team member Ines, and Hal, the owner of the warehouse scanners, about temp1.
access_decisions.csv
account,system,finding,decision,decided_by,decided_on,reason
carys,shop-admin,excess,reduce,Asha,2026-11-21,
efe,shop-admin,dormant,keep,Asha,2026-11-21,Needed for the year-end stock count in December
greta,payroll,excess,remove,Carys,2026-11-21,
ines,shop-admin,leaver,remove,Greta,2026-11-21,
temp1,warehouse,orphan,remove,Hal,2026-11-21,python3 access_review.py check .problems: 0The review is complete: five findings, five valid decisions. Ben now applies them in the systems, and the next export shows whether he did. The decisions file is the evidence of the control C03, and the evidence plan of lesson 6 already lists it.
5. Break the review on purpose
In a copy of the decisions, drop the decision about Ines and let Carys decide about her own administrator rights.
grep -v "^ines" access_decisions.csv > test-decisions.csv
sed -i '/^carys/s/reduce,Asha/keep,Carys/' test-decisions.csv
python3 access_review.py check . test-decisions.csvPROBLEM carys on shop-admin (excess): Carys decided about their own access
PROBLEM carys on shop-admin (excess): kept for a leaver, or kept without a reason
PROBLEM ines on shop-admin (leaver): no decision
problems: 3Carys's own decision breaks two rules at once: she decided about her own access, and she kept it with no reason. Remove the copy with rm test-decisions.csv.
Your turn
Marlow Physio ran its first review. Save the four files in marlow, then find and check. There are no steps.
marlow/hr.csv
person,role,status,manager,left_on
Nadia,manager,active,,
Omar,it,active,Nadia,
Priya,physio,active,Nadia,
Quentin,physio,active,Priya,
Rosa,billing,active,Nadia,
Sam,physio,active,Priya,
Tess,reception,active,Nadia,
Vince,physio,leaver,Priya,2026-09-12
Wanda,reception,leaver,Nadia,2026-11-06marlow/role_rights.csv
role,system,privilege
manager,booking,user
manager,billing,user
it,booking,admin
it,billing,admin
physio,booking,user
billing,billing,user
billing,booking,user
reception,booking,usermarlow/accounts.csv
account,person,system,privilege,last_login,enabled
nadia,Nadia,booking,admin,2026-11-19,yes
nadia,Nadia,billing,user,2026-11-17,yes
omar,Omar,booking,admin,2026-11-20,yes
omar,Omar,billing,admin,2026-06-30,yes
priya,Priya,booking,user,2026-11-20,yes
quentin,Quentin,booking,user,2026-11-18,yes
rosa,Rosa,billing,user,2026-11-20,yes
rosa,Rosa,booking,user,2026-11-12,yes
sam,Sam,booking,user,2026-11-20,yes
sam,Sam,billing,user,2026-10-22,yes
tess,Tess,booking,user,2026-11-20,yes
vince,Vince,booking,user,2026-09-10,yes
wanda,Wanda,booking,user,2026-11-05,yes
locum2,,booking,user,2026-10-01,yes
student,Zed,booking,user,2026-11-13,yesmarlow/access_decisions.csv
account,system,finding,decision,decided_by,decided_on,reason
nadia,booking,excess,keep,Nadia,2026-11-20,I need it to add new staff
omar,billing,dormant,remove,Nadia,2026-11-20,
sam,billing,excess,reduce,,2026-11-20,
vince,booking,leaver,keep,Priya,2026-11-20,He may come back in spring
locum2,booking,orphan,remove,Nadia,2026-11-20,Then write the two decisions that are missing, and say who should take each one.
Check yourself
Greta moved from finance to customer service and kept her payroll access. Which part of the process failed, and why is this case hard to see?
The mover step: the rights of the old role were not removed. It is hard to see because nothing breaks. Greta is a trusted member of staff, the account is used correctly, and no alarm fires. Only a comparison of her rights with her current role shows it, and that is what the review does.
Why may a manager not decide about their own access?
A person who judges their own rights has a reason to keep them. The decision needs somebody with authority and no personal interest: the person's manager, or the owner of the system. This is separation of duties, and lesson 8 uses it again for changes.
The review finds no problems for Kofi, a leaver. What does that show?
That his account is disabled, so the leaver procedure worked in his case. It does not show when the account was disabled. The standard says "within one working day", and proving that needs the date of the change, which this export does not hold. Lesson 11 tests exactly that with a sample.
Why is a dormant account a finding, when its owner is an active member of staff with the right role?
An account that nobody uses is one that nobody watches. If its password leaks, no person will notice strange logins. Ask whether the access is still needed. If it is, as for the yearly stock count, record the reason. If not, remove it.
Field notes
- Start the leaver process from HR data, not from a mail to IT. The staff list is the one source that knows every leaver, including contractors if HR records them. Where it does not, contractors are your orphan accounts.
- Service accounts, which programs use, have no person behind them and show up as orphans. Give each one a named owner in the staff list or in a separate register, and review them in the same way.
- Review privileged accounts more often than ordinary ones. A quarter is a long time for an administrator account that should not exist.
- A review that always ends in "keep all" is a ritual. Watch the share of findings that lead to a removal, and sample a few "keep" decisions in the internal audit.
- Record the review even when it finds nothing. An empty findings list with a date and a reviewer is the evidence that the control ran.