Projects 9-10: A Cloud Posture Review and an AD Hardening Plan
Many breaches in organisations don't start with a clever exploit. They start with a configuration, or are made far worse by one: a storage bucket that was public, a policy that allowed everything, an administrator who logged on to a workstation that was already compromised. The two projects here are configuration reviews of the two places where that matters most today, a cloud account and an Active Directory domain. Both end not in a list of findings but in a plan: what to change, in which order, and how to prove that the change closed the problem.
Project 9: a cloud posture review of a synthetic account
Goal. Review the security posture of a cloud account built for the purpose (a free-tier or sandbox account of your own with deliberately weak settings, or a synthetic configuration export), produce prioritised findings with fixes, apply the fixes and show the improvement.
Builds on. Cloud & Container Security: shared responsibility, the policy evaluator, over-broad policies, least privilege, network exposure, object storage exposure, cloud audit logs, posture management, IaC scanning.
Scope. Only an account you own and created for this project, with no production data and a billing alert set before you start; or a synthetic export. Never an employer's or a client's account, even read-only, without written permission. The cloud provider's own infrastructure is never in scope; read its penetration-testing policy before you run any active test in your account.
A posture review is a set of checks over configuration, each one with a severity and a fix. Here are eight such checks over a synthetic export with AWS-style names:
import json
# A synthetic account export with AWS-style names (fictional, lab data only)
ACCOUNT = json.loads("""{
"root": {"mfa": false, "access_keys": 1},
"trail": {"enabled": true, "multi_region": false, "log_file_validation": false},
"buckets": [
{"name": "lab-web-assets", "public_read": true, "encrypted": true, "purpose": "static website"},
{"name": "lab-backups", "public_read": true, "encrypted": false, "purpose": "database dumps"},
{"name": "lab-logs", "public_read": false, "encrypted": true, "purpose": "audit logs"}
],
"policies": [
{"name": "DevFullAccess", "attached_to": "group/developers",
"statements": [{"Effect": "Allow", "Action": "*", "Resource": "*"}]},
{"name": "CiDeploy", "attached_to": "role/ci",
"statements": [{"Effect": "Allow", "Action": ["s3:PutObject"], "Resource": "arn:aws:s3:::lab-web-assets/*"}]}
],
"security_groups": [
{"name": "web", "ingress": [{"port": 443, "cidr": "0.0.0.0/0"}, {"port": 22, "cidr": "0.0.0.0/0"}]},
{"name": "db", "ingress": [{"port": 5432, "cidr": "10.10.0.0/24"}]}
]
}""")
findings = []
def add(severity, what, fix):
findings.append((severity, what, fix))
if not ACCOUNT["root"]["mfa"]:
add("critical", "root user without MFA", "enable MFA on root, store it offline")
if ACCOUNT["root"]["access_keys"]:
add("high", "root user has access keys", "delete them; use roles")
t = ACCOUNT["trail"]
if not t["enabled"] or not t["multi_region"]:
add("medium", "audit trail not multi-region", "one multi-region trail to a locked bucket")
if not t["log_file_validation"]:
add("low", "trail log file validation off", "turn on log file integrity validation")
for b in ACCOUNT["buckets"]:
if b["public_read"] and b["purpose"] != "static website":
add("critical", f"bucket {b['name']} ({b['purpose']}) is public", "block public access")
if not b["encrypted"]:
add("medium", f"bucket {b['name']} not encrypted at rest", "default encryption with a KMS key")
for p in ACCOUNT["policies"]:
for s in p["statements"]:
actions = s["Action"] if isinstance(s["Action"], list) else [s["Action"]]
if s["Effect"] == "Allow" and "*" in actions and s["Resource"] == "*":
add("high", f"policy {p['name']} on {p['attached_to']} allows *:*", "least-privilege actions and resources")
for g in ACCOUNT["security_groups"]:
for rule in g["ingress"]:
if rule["cidr"] == "0.0.0.0/0" and rule["port"] not in (80, 443):
add("high", f"security group {g['name']} opens port {rule['port']} to the Internet", "restrict to a bastion or VPN range")
ORDER = {"critical": 0, "high": 1, "medium": 2, "low": 3}
for sev, what, fix in sorted(findings, key=lambda f: ORDER[f[0]]):
print(f"{sev:8} {what}\n fix: {fix}")
print(f"{len(findings)} findings")critical root user without MFA
fix: enable MFA on root, store it offline
critical bucket lab-backups (database dumps) is public
fix: block public access
high root user has access keys
fix: delete them; use roles
high policy DevFullAccess on group/developers allows *:*
fix: least-privilege actions and resources
high security group web opens port 22 to the Internet
fix: restrict to a bastion or VPN range
medium audit trail not multi-region
fix: one multi-region trail to a locked bucket
medium bucket lab-backups not encrypted at rest
fix: default encryption with a KMS key
low trail log file validation off
fix: turn on log file integrity validation
8 findings
Two findings are critical: a root user without MFA (the one account that can do everything) and a bucket of database dumps open to the world. Note what the review does not flag: the website bucket is public on purpose, and the CI role's policy is narrow. A posture tool that flags every public bucket trains people to ignore it; checks need context (here, the bucket's declared purpose) to be useful. In a real account you would run the same checks with an open-source posture scanner or the provider's own service, and compare its output with your manual review.
Deliverables. The account's architecture (what exists); the findings, prioritised, each with evidence (the configuration excerpt), fix and the control that detects a regression (a posture rule, an alert on the audit trail); the fixes applied as infrastructure-as-code where possible; the before/after comparison.
Rubric specifics. Scope and safety 3: own account, billing alert, no real data, nothing left public at the end. Detection: for each critical finding, an alert or posture rule that would catch it coming back.
Stretch goal. Write the fixes as Terraform, scan them with an IaC scanner in CI, and show that reintroducing the public bucket fails the pipeline (policy as code).
Project 10: an AD lab hardening plan
Goal. Take an Active Directory lab domain, map its attack paths (how an ordinary account becomes Domain Admin), and write a hardening plan that removes them, ordered by how many paths each action closes. Apply it in the lab and show the paths gone.
Builds on. Windows & AD Security: ACL attack paths, stale privileged accounts, tiering and PAWs, LAPS and gMSA, protected users, ACL and AD CS audit, event IDs.
Scope. Your lab domain lab.test (domain controller 10.10.0.20, clients 10.10.0.21–29), synthetic users. Graph collection tools run only there.
Attack-path analysis is a graph problem. The script below holds a small synthetic domain as a directed graph where an edge means "control of A gives control of B": membership, local admin rights, a logged-on session whose credentials can be taken, a right to reset a password. It finds the paths from three ordinary accounts to Domain Admins, then applies a three-step plan and recomputes:
import networkx as nx
EDGES = [ # (from, to, relation): "from" controlling or compromised gives control of "to"
("alice", "Helpdesk", "MemberOf"), ("Helpdesk", "carol", "ForceChangePassword"),
("carol", "Domain Admins", "MemberOf"), ("alice", "WS01", "AdminTo"), ("bob", "WS01", "AdminTo"),
("WS01", "dave", "HasSession"), ("dave", "IT-Admins", "MemberOf"),
("IT-Admins", "Domain Admins", "GenericAll"), ("svc_sql", "SRV01", "AdminTo"),
("SRV01", "carol", "HasSession"),
]
TARGET = "Domain Admins"
STARTS = ["alice", "bob", "svc_sql"] # ordinary accounts: any one could be phished
PLAN = { # hardening action: the edges it removes
"LAPS: unique local admin passwords": [("alice", "WS01"), ("bob", "WS01")],
"tiering: admins log on only to tier-0 hosts": [("WS01", "dave"), ("SRV01", "carol")],
"helpdesk may not reset admin passwords": [("Helpdesk", "carol")],
}
def report(g, label):
paths = {s: nx.shortest_path(g, s, TARGET) for s in STARTS if nx.has_path(g, s, TARGET)}
print(f"{label}: {len(paths)} of {len(STARTS)} ordinary accounts reach {TARGET}")
for s, p in paths.items():
print(f" {len(p) - 1} steps: {' -> '.join(p)}")
g = nx.DiGraph()
for a, b, rel in EDGES:
g.add_edge(a, b, rel=rel)
report(g, "before")
cut = nx.minimum_edge_cut(g, "alice", TARGET)
print(f"smallest cut between alice and {TARGET}: {sorted(cut)}")
h = g.copy()
for action, edges in PLAN.items():
h.remove_edges_from(edges)
report(h, f"after '{action}'")before: 3 of 3 ordinary accounts reach Domain Admins
3 steps: alice -> Helpdesk -> carol -> Domain Admins
4 steps: bob -> WS01 -> dave -> IT-Admins -> Domain Admins
3 steps: svc_sql -> SRV01 -> carol -> Domain Admins
smallest cut between alice and Domain Admins: [('IT-Admins', 'Domain Admins'), ('carol', 'Domain Admins')]
after 'LAPS: unique local admin passwords': 2 of 3 ordinary accounts reach Domain Admins
3 steps: alice -> Helpdesk -> carol -> Domain Admins
3 steps: svc_sql -> SRV01 -> carol -> Domain Admins
after 'tiering: admins log on only to tier-0 hosts': 1 of 3 ordinary accounts reach Domain Admins
3 steps: alice -> Helpdesk -> carol -> Domain Admins
after 'helpdesk may not reset admin passwords': 0 of 3 ordinary accounts reach Domain Admins
Before the plan every ordinary account has a path. The steps close them one family at a time: unique local administrator passwords (LAPS) cut the shared-admin route through WS01; tiering, which keeps administrators off ordinary machines, removes the sessions that leak their credentials; and taking the helpdesk's right to reset an administrator's password closes the last path. The order matters for the plan: an action that closes the most paths for the least effort goes first. The smallest cut adds a warning. For alice it has two edges, and NetworkX returns the two edges into Domain Admins: carol's membership and IT-Admins' GenericAll right (alice's own two outgoing edges would be another two-edge cut). Those are the administrators' own relationships, which a plan cannot simply delete; what it can do is recognise that IT-Admins, with GenericAll on Domain Admins, is effectively a tier-0 group and protect it as one, and cut the routes that lead ordinary accounts to the administrators, which is what the three actions do.
The attack-path lab shows the same analysis on three directories, including a tiered one with no path at all:
Deliverables. The lab domain's description; the collected graph (from your lab only) and the attack paths found; the hardening plan as a table (action, paths closed, effort, risk of breaking something, detection that confirms it stays closed); evidence after each step; the final graph with no path from ordinary accounts.
Rubric specifics. Technical work 3: paths found by tooling and explained edge by edge. Detection: for each remaining legitimate admin path, the events that show its use (logons of tier-0 accounts outside tier-0 hosts, password resets of admin accounts).
Stretch goal. Add an AD CS certificate template with a dangerous setting to the lab, find it with an audit tool, fix it, and add the detection (AD CS).
Pitfalls
- Context-free checks. A finding list where everything is critical gets ignored; give each check the context it needs.
- Fixing one path at a time. Prioritise by how many paths an action closes; tiering usually closes many at once.
- No regression detection. Configuration drifts back; every fix needs a check or alert that notices.
Practice
1. In the cloud export, the developers group really does need to deploy to the website bucket and read the logs bucket. Write the replacement for DevFullAccess.
Two statements: {"Effect": "Allow", "Action": ["s3:PutObject", "s3:GetObject"], "Resource": "arn:aws:s3:::lab-web-assets/*"} and {"Effect": "Allow", "Action": ["s3:GetObject", "s3:ListBucket"], "Resource": ["arn:aws:s3:::lab-logs", "arn:aws:s3:::lab-logs/*"]}. The *:* finding disappears from the review.
2. In the AD graph, why is dave not in the list of starting accounts, and what does the review say about him?
dave is a member of IT-Admins, which has GenericAll on Domain Admins, so he is effectively a domain administrator. He is a tier-0 account and should be treated (and protected, monitored and limited to tier-0 hosts) as one; the finding is that his group's power is hidden behind an ACL instead of a visible membership.
Test yourself
Why does the posture review not flag the lab-web-assets bucket as public?
- It is encrypted
- Its declared purpose is a static website, so public read is intended
- It is too small
- It has no objects
In the AD graph, what does an edge WS01 -> dave (HasSession) mean?
- dave owns WS01
- dave is logged on to WS01, so whoever controls WS01 can take his credentials
- WS01 is in dave's group
- dave can reset WS01's password
How should the actions of a hardening plan be ordered?
- Alphabetically
- By how many attack paths each closes for its effort and risk
- Cheapest first, whatever it closes
- Randomly