Part 5 of 12 · 2 min read
The world between approval and action is not the world you approved
Time passes between a human clicking approve and the action actually running, and in that gap the thing being approved can change underneath the approval.
Think of approving a wire transfer to a specific bank account. Then someone swaps the account number on the form after you signed but before it is mailed. Your signature is still on a real form, just not the one you thought you approved.
TOCTOU (time-of-check to time-of-use) is the risk that state changes between the check and the action. Separation of duties means the requester cannot approve their own request, with high-risk actions requiring two distinct approvers so one compromised or careless approval is never enough on its own.
A worked example. A token is issued binding state_version=3. If the order has since moved to state_version=4 by the time the executor runs, the call is denied with "state changed since approval" -- even though the token's signature, action, arguments and session are all still perfectly valid. Separately, an agent that both requests and approves its own refund (requester == approver == "alice") is denied with "self-approval", and a high-risk action approved by only one person (even a completely legitimate one) is denied with "not enough distinct approvers" until a second, different approver's token is added.
The key lines. From code/mini-approvals/approvals.py:
# from code/mini-approvals/approvals.py
need = 2 if action in self.high_risk else 1
good, approvers, nonces = [], set(), []
for t in tokens:
Read it as: approvers is a set, not a list. Two tokens from the same approver collapse into one entry. So len(approvers) < need genuinely counts distinct people, not just the count of tokens presented. Submitting the same approver's token twice does not fake a second approver.
TOCTOU, separation of duties
TOCTOU is the state changing between the check and the action. Separation of duties means the requester cannot approve their own request; high risk needs two approvers.
Example: the test that issues two tokens from the same approver (alice twice) for a high-risk action and still gets "not enough distinct approvers" is separation of duties checked at the data-structure level -- the rule isn't "two tokens," it's "two different people," and the set is what enforces the difference.