Security, Governance and PlatformAction authorization and policyPrincipal
How should a refund service bind delegated authority to the correct order, amount and tenant?
By Amit Kumar3 min readWorked answer includedReviewed 28 Sept 2026
The question
Interview question
An agent holds a valid refund-service token with refund:create scope and an approval for order A. Retrieved content supplies order B, and the service checks only token signature, audience and coarse scope. Design object-level authorization and intent binding, including same-tenant orders, amount/currency changes, retries and concurrent partial refunds.
Draft your approach first
Take a few minutes before you read the answer. Name the constraint that matters most, the failure you are designing for and how you would know it worked.
Reveal the worked answerWorked answer
A valid token for the refund service proves that the caller has some delegated authority there. A scope such as refund:create may say what operation is allowed without saying which order, tenant, amount or approval it covers. If the service accepts an order ID from the model and checks only the token's audience and coarse scope, a mistaken or injected ID can target a different customer's order. The signature is valid. The authorization decision is incomplete.
Bind the action to the actual resource and delegation. At the tool boundary, resolve the order under the authoritative customer account, check the initiating user's rights, action limit and approval state, and compare the normalized parameters with the approved intent. Then use a short-lived, purpose-bound grant or a server-side decision record tied to order, tenant, amount ceiling and operation ID where the architecture supports it. RFC 9396 defines authorization_details for fine-grained OAuth requests. RFC 8693 defines token exchange for delegation scenarios. Those standards provide vocabulary and mechanisms, not an automatic replacement for the refund service's resource checks.
I would test an agent that is approved to refund order A while a retrieved document supplies order B's identifier. The service must reject B even if the token is valid and both orders are in the same tenant. Also test a lower amount, an amount above the approved cap, a changed currency, and a token minted for the right service but another run. Log the authorization decision with subject, resource, approval or grant ID, action parameters and policy version without exposing bearer tokens.
An interviewer might say the agent should never invent an order ID. Agreed, but model behavior is not the security boundary. The tool service must enforce what the user delegated. The agent has a valid user token. Why can the second tool reject it? addresses a token rejected by a second tool because of audience. The agent used a valid tool. Why did a retrieved tenant ID expose another customer's data? addresses a retrieved tenant ID crossing a customer boundary. This question assumes the token reaches the right tool and asks whether coarse operation scope still lets the agent choose the wrong resource.
The order’s ownership must come from the authoritative order record, rather than a tenant argument copied from the model. Suppose a hypothetical grant authorizes up to 100 USD for order A. A call for 80 USD on order B still fails even if B belongs to the same tenant. A call for 100 EUR is not equivalent to 100 USD. Normalize the request into the service’s money representation and compare both currency and amount with the approved effect.
A per-call ceiling can also be bypassed by repetition unless the business contract is actually per call. If the grant caps a total refund at 100 USD, two concurrent 60 USD attempts must not each pass an independent remaining-balance read. Reserve or consume grant capacity atomically with the authoritative operation record, then submit the provider request using an idempotent operation identity. Provider timeout and retry must reconcile that same reservation. Releasing capacity immediately after an unknown response can enable another refund while the first later succeeds.
Rich authorization data can express the intended constraints, but the resource server must interpret and enforce them under its own trusted contract. Test object substitution, cumulative consumption and unknown provider outcomes, not only token validation. This adds resource and effect-budget reasoning beyond the tenant-selection read boundary and the separate question about tokens issued to the wrong audience.
Related questions
Keep practising security, governance and platform
Follow another question in this area, or search the complete library.
Get my essays on AI engineering and distributed systems by email. Subscribe to ArchCrux