Write an action authorization contract
An authorization decision needs more than a user ID. Identify the principal, the tenant, the target resource, the requested operation and the relevant conditions. The conditions might include a monetary limit, resource version, approval requirement or time window. Define where each value comes from and which service is authoritative.
OWASP recommends server-side authorization, checks on requests and default denial. In an agent system, model-generated tool arguments are another untrusted request input; they do not replace the identity established by the application.[1]
| Input | Trusted source | Common mistake |
|---|---|---|
| Principal | Validated session or workload identity. | Accepting a user ID supplied in tool arguments. |
| Tenant | Authenticated membership or explicit service scope. | Using the model’s tenant field as authority. |
| Resource | Authoritative lookup and ownership relationship. | Checking only that an ID has the right format. |
| Action | Versioned domain operation. | Treating read access as permission to update. |
| Conditions | Current policy and relevant state. | Reusing an old approval after the action changes. |
Worked scenario: a support credit
A synthetic support operator may read an account and propose a service credit. Policy allows the operator to approve credits up to a defined limit for accounts in the operator’s tenant. Larger credits require another authorized approver. The model produces an account ID, amount and reason.
The application derives the operator and tenant from authenticated context, fetches the account within that scope and validates the amount. It checks the permitted action and any approval requirement. The model cannot expand the limit by describing the request as urgent, and a retrieved support note cannot grant permission to issue the credit.
At execution, the service validates the current resource version and policy again. If the operator has lost access or the proposal has changed, execution stops. An earlier successful read is not a standing grant to write later.
Preserve authority through delegation
A background worker often runs under a service identity. That does not mean every task should inherit all of the service’s technical privileges. Preserve the initiating authority and the allowed task scope, or use an explicit tenant-scoped service policy when the task is not acting for a person.
- Distinguish the identity running the process from the authority for the business action.
- Carry an authenticated task reference rather than trusting identity fields written by the model.
- Limit tools and credentials to the action class the task needs.
- Recheck current resource policy when the action executes.
- Record the relevant delegation and decision without storing unnecessary secrets or personal data.
If the intended behavior is to continue after the initiating user leaves, define that as a deliberate service-owned workflow with its own policy. Do not let an implementation accident decide whether a departed user’s tasks retain authority.
Use several layers for different purposes
| Control | Purpose | Limit |
|---|---|---|
| Tool discovery filtering | Reduce irrelevant or unavailable choices. | A hidden tool still needs server-side enforcement. |
| Schema validation | Reject malformed arguments. | Well-formed arguments can request an unauthorized action. |
| Domain authorization | Check the caller, resource and operation. | Needs current policy and correct identity propagation. |
| Human approval | Authorize a specific proposal where policy requires review. | Cannot grant privileges the approver does not have. |
| Data-layer constraints | Protect tenant or record invariants in storage. | Do not replace the entire application policy. |
Defense in depth is useful when the layers have explicit jobs. Duplicating inconsistent policy logic across a gateway, tool wrapper and domain service can create gaps. Prefer one authoritative decision contract with enforcement at the points where access or mutation actually occurs.
Test denials as product behavior
An authorization suite should vary the principal, resource, tenant, operation and timing. Test the same valid request under an invalid authority. Include permission changes between proposal and execution, and attempts to reuse an approval for a different payload.
| Variation | Expected result |
|---|---|
| Correct resource, wrong tenant | Deny without disclosing the resource contents. |
| Read-only principal requests a write | Deny the mutation. |
| Valid schema, amount over limit | Require the appropriate approval or reject. |
| Access revoked after proposal | Deny execution under current policy. |
| Approved payload changes | Invalidate the old approval. |
| Background task has no valid authority | Stop or route through the defined service policy. |
Track attempted and blocked violations separately from successful unauthorized actions. The former can demonstrate a working boundary; the latter is a critical failure. Both can inform investigation, but they should not be collapsed into one ordinary error rate.
What to ask during a vendor review
Ask the vendor to walk through one allowed action and the same action denied by tenant, role, resource and timing. Inspect the code or contract where the decision is enforced. Ask how delegation works and what happens to a pending task when permissions change.
The credible answer identifies the trusted inputs, enforcement service, policy version and recorded outcome. A prompt that says “only access authorized data” can guide behavior, but it is not that enforcement mechanism.
Questions this guide answers
Is permission to use a tool the same as permission to change a record?
No. A caller may be allowed to discover or invoke a tool while lacking access to a particular record or mutation. Enforce the resource, tenant and operation policy at execution. Narrow tool contracts reduce the available surface, but they do not replace the application's business authorization rules.
What happens if access changes while an agent task is running?
Recheck current authority before the consequential operation. A long-running task or cached result must not preserve access that the caller has lost. Define whether the task stops, requests new approval or discards restricted context, and retain enough evidence to explain the decision without exposing the protected data.
How should approval be tied to an agent action?
Bind approval to the intended operation, target and material parameters, with an expiry and the required approver identity. Verify that the action still matches the approved state before committing it. An approval to discuss an action or a broad approval of a conversation does not authorize every later mutation.
Sources and scope
Technical references inform the cited statements. The decision frameworks and synthetic examples are TeqEngine’s editorial guidance.
- OWASP: Authorization Cheat Sheethttps://cheatsheetseries.owasp.org/cheatsheets/Authorization_Cheat_Sheet.html