CSE Roadmap

Core tier · about 4 hours · 13 parts

Part 5 of 13 · 2 min read

Map which capabilities can be reached from the ones already granted

A tool that looks harmless on its own can be one step away from something that isn't, and the step is the part worth drawing.

Think of a master key that does not open the vault directly, but opens the office where the vault's combination is written on a sticky note. Handing out the master key is effectively handing out the vault, just with one extra step in between.

privilege escalation is using one capability to obtain another, so the real measure of what an agent can reach is not its granted capabilities alone but the escalation closure. Every capability reachable by following "can obtain" edges outward from what it already has -- and a capability graph makes those hidden paths visible before an attacker finds them.

A worked example. Starting from just shell access and following the escalation edges, the closure reaches read:secrets, write:files, write:config, grant:admin, cred:db_admin, write:db, and read:db_all -- 9 capabilities total from one starting point. Starting from only read:db_customers, the closure is just that one capability; there is no edge leading anywhere else from it, because nothing in the escalation graph treats read access to customer records as a stepping stone to anything more.

The key lines. From code/mini-privilege/privilege.py:

# from code/mini-privilege/privilege.py
ESCALATION = {
    "read:secrets": {"cred:db_admin"},
    "cred:db_admin": {"write:db", "read:db_all"},
    "shell": {"read:secrets", "write:files", "net:any"},
    "write:config": {"grant:admin"},
    "grant:admin": {"cred:db_admin", "shell"},
    "write:files": {"write:config"},
}


def closure(initial, edges=ESCALATION):
    seen, stack = set(initial), list(initial)
    while stack:
        c = stack.pop()
        for n in edges.get(c, ()):
            if n not in seen:
                seen.add(n); stack.append(n)
    return seen

Read it as: closure is a plain graph traversal. It is a depth-first walk that keeps following edges until nothing new is reachable. The dictionary above it is the actual security-relevant content. Each line is a claim about the real system ("shell access lets you read secrets"). The traversal just makes the consequence of granting any one of them computable. Otherwise a reviewer has to trace it by hand.

Escalation

Escalation is using one capability to obtain another.

Example: grant:admin looping back to shell in the escalation map is the cycle that makes a shell and an admin grant equally dangerous starting points -- either one's closure reaches the other, which is exactly the kind of hidden equivalence a capability graph is meant to surface before it's discovered by an attacker instead.