Part 8 of 12 · 2 min read
Answering approval questions in an interview
How do you make sure a human approval cannot be abused by a compromised agent?
"The approval is a signed token bound to the action name, a hash of the exact arguments, the session, the approver, an expiry and a one-time nonce. The executor verifies all of it, so changing the amount, replaying it, using it elsewhere or approving your own request all fail. In the example's tests ten attacks failed on the token scheme while all four I tried succeeded against a boolean flag." Follow-up: "What can still go wrong?" A stolen key, a compromised approval screen, or a human approving something harmful that is correctly described.
What should the approval prompt show?
"A description built from the arguments by trusted code: the action, the amount and recipient, whether it is reversible, and warnings for anything unusual (new recipient, extra field, lookalike domain). Not a model-written summary, because a manipulated model can write a reassuring one. I also escape control characters so a value cannot forge extra lines." Follow-up: "What about long argument lists?" Show a diff or the risky fields first and the rest on demand, and cap the batch size so approvers do not rubber-stamp.
Why single-use, short-lived approvals?
"A long-lived or reusable approval becomes a standing permission an attacker can replay. Short expiry and single use keep the approval tied to the moment and the action. The cost is re-approval for retries." Follow-up: "What about retries after a timeout?" Use idempotency keys (Level 8 module 6) so a retried call is the same action, and reissue approval only if the arguments change.
How do you handle state changing after approval?
"Bind the approval to a version of the relevant state, such as an order's version or etag, and have the executor compare it at execution. If it changed, deny and ask again. Otherwise the human approved a different situation from the one executed." Follow-up: "Is that enough for concurrency?" The check and the action must be atomic, for example in one transaction, or two executions can both pass.