Privileged Access and Running an Access Review
Define controls for privileged access (just-in-time elevation, break-glass accounts, session recording through jump servers and privileged access workstations, owned service accounts), then run a scripted access review over HR, directory, role and usage exports and record a decision for every finding.
Contentsand lesson path
On this page
- The problem
- Privileged access controls
- Step 1: Encode the JIT rules
- Step 2: Load the review data
- Step 3: Run the review
- Step 4: Record a decision for every finding
- Common mistakes
- Check your understanding
- Apply it
- Review prompt
Lessons of Identity & Access Management
- Identity Lifecycle and Access Models Concept · 20 min
- From Passwords to Phishing-Resistant Authentication Concept · 15 min
- Federating an App with a Lab Identity Provider Lab · 30 min
- Privileged Access and Running an Access Review Worked example · 20 min
- Reading Sign-In Logs for Identity Attacks Lab · 25 min
- Identity & Access Check Knowledge check · 8 questions
What you will learn
- Define privileged access controls (just-in-time elevation, break-glass accounts, session logging) and run an access review that finds excess entitlements.
- Design a role- or attribute-based access model with least privilege and separation of duties, including joiner, mover and leaver processes.
01. The problem
You are the security engineer at a company of about 300 people. The auditors arrive next month, and two tasks are yours. First, write down how privileged access works: who may become an administrator, for how long, with whose approval, and what evidence remains. Second, run the quarterly access review, the regular check that each identity still needs the access it holds, and record a decision for every problem found.
You have five exports: the HR roster (who works here, in which job, since when), the directory accounts (enabled or not, human or not), the entitlements with their last-used dates, the role baselines that say what each job should get, and the separation-of-duties rules. An entitlement is one access right held by an account, such as aws-prod:admin. You will work through the problem in four steps, with a short script for each.
02. Privileged access controls
An attacker who phishes an ordinary account gets ordinary access. One who phishes an administrator gets the organisation. Standing privilege, admin rights that are always on, means every admin account is a high-value target every hour of the day. Four controls shrink that exposure.
Just-in-time (JIT) elevation makes admins eligible for a role instead of holding it. To use it, they request it for a task with a ticket number, someone else approves, and the role expires on its own after a short window. The request and approval are logged. Cloud platforms and privileged access management (PAM) products offer this, for example Microsoft Entra Privileged Identity Management. JIT with automatic approval and an eight-hour window behaves much like standing access, so the window and the approval rule matter.
Break-glass accounts are emergency accounts for the day the normal path fails: the federation server is down, the MFA service is unreachable, or a bad conditional access policy locks every admin out. They hold standing admin rights by design, so they need other protection. Microsoft's guidance is a good model: at least two accounts, cloud-only so they do not depend on an on-premises directory, phishing-resistant credentials such as FIDO2 security keys kept in separate safes, an alert to the security team on every sign-in, a review after every use, and a test at least every 90 days to prove they still work and the alert still fires. They are never used for daily work.
Session logging and recording answers the question an approval cannot: what did the admin actually do? Admin access to production goes through a jump server (also called a bastion host), which is the only network path to admin interfaces and records each session's commands or screen to storage the admin cannot edit. A privileged access workstation (PAW) is a hardened device used only for admin work, with no email or web browsing, so a phishing message cannot reach the machine that holds admin sessions.
Service accounts and other non-human identities (API keys, CI pipelines, workload identities) do not appear in the HR roster, so no leaver process removes them. Each needs a named human owner, a stated purpose, only the rights that purpose requires, and credentials that are rotated or, better, short-lived. A dormant service account with admin rights and no owner is a gift to an attacker using ATT&CK T1078 Valid Accounts.
03. Step 1: Encode the JIT rules
Start with the JIT rules, because the review will check against them. jit.py grants an elevation only if the person is eligible, gives a ticket, has a different approver and asks for 60 minutes or less. Each grant records where its session recording lives. It needs only Python 3.12. Create a folder access-review and save the file there.
"""Just-in-time elevation rules: approved, ticketed, short, and logged."""
import json
import re
from datetime import datetime, timedelta
MAX_MINUTES = 60
ELIGIBLE = {"eli": {"aws-prod:admin"}, "hana": {"aws-prod:admin"}} # sre baseline
AUDIT_LOG = []
def request(user, role, ticket, approver, minutes, now):
if role not in ELIGIBLE.get(user, set()):
raise PermissionError(f"{user} is not eligible for {role}")
if not re.fullmatch(r"CHG-\d{4,}", ticket):
raise PermissionError("a change or incident ticket is required")
if approver == user:
raise PermissionError("requester cannot approve their own elevation")
if minutes > MAX_MINUTES:
raise PermissionError(f"{minutes} min requested, maximum is {MAX_MINUTES}")
grant = {"user": user, "role": role, "ticket": ticket, "approver": approver,
"start": now.isoformat(), "end": (now + timedelta(minutes=minutes))
.isoformat(), "session_recording": "jump-01/" + ticket}
AUDIT_LOG.append(grant)
return grant
def active(grant, now):
return datetime.fromisoformat(grant["start"]) <= now < datetime.fromisoformat(
grant["end"])
t0 = datetime(2026, 11, 16, 9, 0)
for args in [("eli", "aws-prod:admin", "CHG-20931", "hana", 45),
("eli", "aws-prod:admin", "CHG-20932", "eli", 30),
("eli", "aws-prod:admin", "", "hana", 30),
("hana", "aws-prod:admin", "CHG-20933", "eli", 480),
("ben", "aws-prod:admin", "CHG-20934", "eli", 30)]:
try:
g = request(*args, now=t0)
print("GRANTED", g["user"], g["role"], "until", g["end"][11:16])
except PermissionError as exc:
print("DENIED ", args[0], "-", exc)
print("active at 09:30:", active(AUDIT_LOG[0], t0 + timedelta(minutes=30)))
print("active at 09:50:", active(AUDIT_LOG[0], t0 + timedelta(minutes=50)))
print("audit record:", json.dumps(AUDIT_LOG[0], indent=1))cd access-review
python3 jit.pyGRANTED eli aws-prod:admin until 09:45
DENIED eli - requester cannot approve their own elevation
DENIED eli - a change or incident ticket is required
DENIED hana - 480 min requested, maximum is 60
DENIED ben - ben is not eligible for aws-prod:admin
active at 09:30: True
active at 09:50: False
audit record: {
"user": "eli",
"role": "aws-prod:admin",
"ticket": "CHG-20931",
"approver": "hana",
"start": "2026-11-16T09:00:00",
"end": "2026-11-16T09:45:00",
"session_recording": "jump-01/CHG-20931"
}Each denial is a control doing its job: no self-approval, no work without a ticket, no long windows, no elevation outside the eligible group. The grant ends by itself at 09:45 without anyone remembering to remove it. The audit record links the person, the approver, the ticket and the session recording, which together answer who, why, approved by whom and what they did.
04. Step 2: Load the review data
Save the five exports in access-review/data/. The HR roster is the source of truth for employment. The review must never use the directory to decide who has left, because the directory is the thing being checked. previous_job tells the script which entitlements a mover brought from their old job. In roles.csv, mode says whether an entitlement may be held permanently (standing) or only through JIT (jit).
employee_id,name,job,previous_job,job_since,status,end_date
E01,ana,support-agent,,2024-03-01,active,
E02,ben,ap-clerk,,2023-06-12,active,
E03,chen,support-agent,ap-clerk,2026-08-01,active,
E04,dana,finance-manager,,2022-01-10,active,
E05,eli,sre,,2021-09-01,active,
E06,farah,developer,,2025-02-03,left,2026-10-31
E07,gus,account-exec,,2024-11-04,left,2026-09-15
E08,hana,sre,,2025-05-19,active,account,employee_id,kind,owner,enabled
ana,E01,human,,yes
ben,E02,human,,yes
chen,E03,human,,yes
dana,E04,human,,yes
eli,E05,human,,yes
farah,E06,human,,yes
gus,E07,human,,no
hana,E08,human,,yes
svc-ci,,service,E05,yes
svc-backup,,service,,yes
bg-admin-1,,break-glass,security-team,yes
bg-admin-2,,break-glass,security-team,yesjob,entitlement,mode
support-agent,crm:read,standing
support-agent,tickets:write,standing
ap-clerk,crm:read,standing
ap-clerk,erp:invoice-create,standing
finance-manager,erp:invoice-approve,standing
finance-manager,erp:reports,standing
sre,aws-prod:read,standing
sre,k8s-prod:deploy,standing
sre,aws-prod:admin,jit
developer,github:write,standing
developer,aws-dev:admin,standing
account-exec,crm:write,standingaccount,entitlement,last_used
ana,crm:read,2026-11-15
ana,tickets:write,2026-11-15
ben,crm:read,2026-11-14
ben,erp:invoice-create,2026-11-14
ben,erp:invoice-approve,2026-11-02
chen,crm:read,2026-11-15
chen,tickets:write,2026-11-15
chen,erp:invoice-create,2026-10-28
dana,erp:invoice-approve,2026-11-13
dana,erp:reports,2026-11-10
eli,aws-prod:read,2026-11-15
eli,k8s-prod:deploy,2026-11-12
eli,aws-prod:admin,2026-11-03
farah,github:write,2026-10-30
farah,aws-dev:admin,2026-11-09
gus,crm:write,2026-09-12
hana,aws-prod:read,2026-11-14
hana,k8s-prod:deploy,2026-04-20
svc-ci,k8s-prod:deploy,2026-11-15
svc-backup,aws-prod:s3-admin,2026-03-02
bg-admin-1,aws-prod:admin,2026-10-01
bg-admin-2,aws-prod:admin,2026-06-20entitlement_a,entitlement_b,reason
erp:invoice-create,erp:invoice-approve,one person could create and pay a fake invoice05. Step 3: Run the review
review.py joins the exports and applies one rule per finding type. The two thresholds are policy choices, not standards: 90 days without use makes standing access excess, and 90 days without a test makes a break-glass account suspect. The review date is fixed so that the output is repeatable.
"""Quarterly access review over HR, directory, role and usage exports."""
import csv
import sys
from collections import defaultdict
from datetime import date
REVIEW_DATE = date(2026, 11, 16) # fixed so the lab output is repeatable
UNUSED_DAYS = 90 # standing access unused this long is excess
TEST_DAYS = 90 # break-glass must be tested at least this often
def rows(name: str) -> list[dict]:
with open(f"data/{name}.csv", newline="") as fh:
return list(csv.DictReader(fh))
def age(day: str) -> int:
return (REVIEW_DATE - date.fromisoformat(day)).days
hr = {r["employee_id"]: r for r in rows("hr")}
baseline = defaultdict(dict) # job -> {entitlement: mode}
for r in rows("roles"):
baseline[r["job"]][r["entitlement"]] = r["mode"]
held = defaultdict(dict) # account -> {entitlement: date}
for r in rows("entitlements"):
held[r["account"]][r["entitlement"]] = r["last_used"]
sod = [(r["entitlement_a"], r["entitlement_b"]) for r in rows("sod")]
findings, checked = [], []
def flag(kind: str, account: str, detail: str) -> None:
findings.append({"id": f"F{len(findings) + 1:02d}", "kind": kind,
"account": account, "detail": detail})
for acct in rows("accounts"):
name, ents = acct["account"], held[acct["account"]]
if acct["kind"] != "human":
last = max(ents.values())
if acct["kind"] == "break-glass": # standing by design, so test it
if age(last) > TEST_DAYS:
flag("BREAK-GLASS", name, f"last tested {last} ({age(last)} days)")
else:
checked.append(f"{name} tested {age(last)} days ago")
elif not acct["owner"] or age(last) > UNUSED_DAYS:
owner = acct["owner"] or "none"
flag("NHI", name, f"owner: {owner}; last used {last} ({age(last)} days)")
continue
person = hr[acct["employee_id"]]
if person["status"] == "left":
if acct["enabled"] == "yes":
late = ", ".join(e for e, d in ents.items() if d > person["end_date"])
flag("LEAVER", name, f"left {person['end_date']}, still enabled; "
f"used after: {late or 'nothing'}")
continue
expected = baseline[person["job"]]
for ent, last in sorted(ents.items()):
if ent not in expected:
old_job = baseline.get(person["previous_job"], {})
kind = "MOVER" if ent in old_job else "EXCESS"
flag(kind, name, f"{ent} not in {person['job']} role, used {last}")
elif expected[ent] == "jit":
flag("STANDING", name, f"{ent} should be JIT, held permanently")
elif age(last) > UNUSED_DAYS:
flag("UNUSED", name, f"{ent} last used {last} ({age(last)} days)")
for a, b in sod:
if a in ents and b in ents:
flag("SOD", name, f"holds {a} + {b}")
print(f"Access review {REVIEW_DATE}: {len(findings)} findings")
for line in checked:
print("checked:", line)
for f in findings:
print(f"{f['id']} {f['kind']:12}{f['account']:11}{f['detail']}")
with open("findings.csv", "w", newline="") as fh:
writer = csv.DictWriter(fh, fieldnames=["id", "kind", "account", "detail"])
writer.writeheader()
writer.writerows(findings)
if len(sys.argv) > 1: # python review.py decisions.csv
decided = {r["id"]: r for r in csv.DictReader(open(sys.argv[1]))}
print("\nRemediation plan")
for f in findings:
d = decided.get(f["id"])
if d is None:
print(f"{f['id']} {f['account']:11}NO DECISION: review is not complete")
else:
print(f"{f['id']} {f['account']:11}{d['decision']:8}{d['action']} "
f"[{d['approver']}]")python3 review.pyAccess review 2026-11-16: 8 findings
checked: bg-admin-1 tested 46 days ago
F01 EXCESS ben erp:invoice-approve not in ap-clerk role, used 2026-11-02
F02 SOD ben holds erp:invoice-create + erp:invoice-approve
F03 MOVER chen erp:invoice-create not in support-agent role, used 2026-10-28
F04 STANDING eli aws-prod:admin should be JIT, held permanently
F05 LEAVER farah left 2026-10-31, still enabled; used after: aws-dev:admin
F06 UNUSED hana k8s-prod:deploy last used 2026-04-20 (210 days)
F07 NHI svc-backup owner: none; last used 2026-03-02 (259 days)
F08 BREAK-GLASS bg-admin-2 last tested 2026-06-20 (149 days)Read each finding as a question for an owner:
- F01 and F02:
ben's approve right is not in his job's role and, with his create right, breaks separation of duties. One removal fixes both. - F03:
chenmoved in August but still creates invoices: privilege creep from a failed mover step. - F04:
eliholds thejit-only admin role permanently. Converting it removes the standing privilege without blocking his work. - F05 is the most urgent.
farahleft on 31 October, her account is still enabled, andaws-dev:adminwas used after that date. Treat it as a possible incident, not only as clean-up. - F06:
hana's deploy right fits her job but has not been used for 210 days. - F07:
svc-backuphas no owner and has been idle for 259 days. - F08: one break-glass account has not been tested for 149 days, while the other passed its check.
06. Step 4: Record a decision for every finding
A review is complete only when every finding has a decision, an action and an approver who is not the account holder. Save the reviewer's decisions as decisions.csv and pass the file to the script. F06 is missing on purpose.
id,decision,action,approver
F01,revoke,remove invoice-approve; holiday cover via JIT,dana
F02,revoke,closed by F01; SoD check added to request form,dana
F03,revoke,remove invoice-create; fix mover workflow,support-lead
F04,convert,aws-prod:admin to JIT: 1 h max with approval,security
F05,disable,disable now; revoke sessions; investigate 11-09,security
F07,disable,disable for 14 days; delete if nothing breaks,platform-lead
F08,test,run drill this week; alert must fire,securitypython3 review.py decisions.csv | tail -9Remediation plan
F01 ben revoke remove invoice-approve; holiday cover via JIT [dana]
F02 ben revoke closed by F01; SoD check added to request form [dana]
F03 chen revoke remove invoice-create; fix mover workflow [support-lead]
F04 eli convert aws-prod:admin to JIT: 1 h max with approval [security]
F05 farah disable disable now; revoke sessions; investigate 11-09 [security]
F06 hana NO DECISION: review is not complete
F07 svc-backup disable disable for 14 days; delete if nothing breaks [platform-lead]
F08 bg-admin-2 test run drill this week; alert must fire [security]The script refuses to call the review complete while F06 has no decision. That check stops the most common review failure: problems found, then never closed. Add the decision for F06 and run the review again.
printf '\n%s\n' 'F06,keep,keep until 2027-02-15 for DR drill; re-review then,sre-lead' \
>> decisions.csv
python3 review.py decisions.csv | tail -9Remediation plan
F01 ben revoke remove invoice-approve; holiday cover via JIT [dana]
F02 ben revoke closed by F01; SoD check added to request form [dana]
F03 chen revoke remove invoice-create; fix mover workflow [support-lead]
F04 eli convert aws-prod:admin to JIT: 1 h max with approval [security]
F05 farah disable disable now; revoke sessions; investigate 11-09 [security]
F06 hana keep keep until 2027-02-15 for DR drill; re-review then [sre-lead]
F07 svc-backup disable disable for 14 days; delete if nothing breaks [platform-lead]
F08 bg-admin-2 test run drill this week; alert must fire [security]Look at the kinds of decision. Revoke and disable remove access. Convert keeps the work possible but removes standing privilege. Disabling svc-backup for 14 days before deleting it is a scream test: if something breaks, its owner appears; if nothing breaks, deletion is safe. Keep is allowed, but only with a reason, an expiry date and a re-review, so that an exception does not become permanent. F05 also starts an investigation of the activity on 9 November.
07. Common mistakes
08. Check your understanding
09. Apply it
For the skill project, add privileged access to the three job functions you defined in lesson 1:
- Mark which entitlement of each job is
jitand write its rule: maximum window, who approves, and what ticket is needed. - Design two break-glass accounts for your lab IdP: where the credentials live, which alert fires on use, and the date of the first test.
- Add one more rule to
review.py, for example "an approver indecisions.csvis the account holder", and add a row that triggers it.
10. Review prompt
Without looking back, explain: what standing privilege is and why JIT reduces it; the conditions that make a JIT request valid; why break-glass accounts keep standing rights and which controls replace JIT for them; what a jump server and a PAW each protect; why service accounts need named owners; the eight finding types in the review and the evidence behind each; and what makes a review complete.
References
Your progress
Reading state
Sign in to save that you finished reading this lesson.
Prove this skill
8 questions · about 6 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.