Let a trusted broker issue only the authority a tool action needs
Keep credentials out of model context and bind short-lived tool access to the authenticated caller, approved resource, action, audience and current policy.
On this page
The question for today
What you’ll understand
- Distinguish a model-proposed tool call from broker authorization.
- Bound credential scope, audience and lifetime under a declared issuer contract.
- Test expiration, wrong resources, revocation and retries without assuming TTL prevents replay.
A model can propose a tool call without possessing the authority to execute it. A trusted broker should resolve that proposal into a narrowly permitted operation under the authenticated caller and service policy. The model needs the permitted result, not a reusable secret in its prompt. Short-lived credentials reduce one exposure window, but they do not decide resource ownership or prevent every replay. Specify who issues the credential, who validates it, which resource it targets, and whether policy is checked again when work begins.
Construct the operation under server-controlled identity and scope
Resolve the tool name, action, target resource and tenant from an allowlisted server-side contract. Treat every model-supplied field as untrusted, including a claimed user identity or destination. The broker intersects the caller’s authority with its own service authority and the approved task scope, then either performs the operation itself or issues a constrained credential to the intended executor. A generic read scope may still be too broad unless the resource server also checks which document or account may be read.
RFC8693 defines token-exchange machinery, and RFC8707 defines resource indicators; using them does not automatically create the application’s intended policy. Configure the issuer and resource server to honor the actual audience, actions and resource restrictions. Keep the broker’s long-lived secrets in the trusted execution path, outside prompts, retrieved text and ordinary logs. Returning a token as a normal tool result would expose it to later model context and potentially to unrelated output handling.
A lifetime bound is not action cancellation or replay prevention
For a credential carrying an expiry, validate the issuer/signature and the expected audience as well as the relevant temporal and permission claims. RFC7519 specifies expiration semantics when that claim is used, with implementation-specific clock-skew leeway that must be stated. A service can adopt a stricter no-leeway fixture for testing. Shortening lifetime reduces accepted future use only if every accepting component actually enforces that bound and cannot obtain a broader replacement credential through another path.
A token accepted just before expiration may start work that finishes later unless the operation contract adds a separate execution deadline or cancellation check. Likewise, a stolen bearer credential may be replayable within its allowed window. Revocation mechanisms and propagation differ; RFC7009 discusses token revocation but does not make every distributed validator instantly aware of it. Use appropriately scoped credentials, operation-specific controls and a verified retry/idempotency policy rather than claiming expiry alone makes an action single-use.
Test the credential boundary at the resource server
Use a harmless controlled resource to test the allowed action, wrong audience, wrong tenant/resource, excessive scope, expiration and revoked credentials under the actual issuer/validator configuration. Repeat a call to establish the declared replay or idempotency behavior, and inspect resource-side effects rather than only the broker’s response. Test queued operations whose permission changes before execution. Log credential identifiers or protected correlation references as appropriate, while excluding the credential value itself.
The modular lab illustrates why a wrapped counter lacks enough information for absolute expiry. Reset, set both m=10,a=3, predict 0,3,6,9,2 through four Steps. Reset and set both m=10,a=1 for comparison. Residue two can represent an unwrapped count of twelve, so the residue alone is not an elapsed-time proof. This is not JWT NumericDate, a real credential clock, cryptography, token issuance or authorization. Credential tests must use the actual clock and validation semantics.
Work it through
Check a conservative credential scheduling budget
A fictional broker has a credential with 120 seconds remaining. Its policy requires an enforced maximum queue wait of 80 s, maximum call duration of 40 s, and 10 s safety margin to fit within the remaining lifetime. These bounds use one compatible elapsed-time mapping.
The required budget is 80+40+10=130 s. It exceeds the 120-second remaining lifetime by ten seconds, so the proposed conservative admission condition fails.
If the enforced queue bound is instead fifty seconds, the required sum is 50+40+10=100 s, leaving twenty seconds of slack under this particular policy.
The broker must still authorize the exact action and resource and verify the intended audience. Meeting the time inequality does not make the credential single-use, prove revocation propagation, or stop already started work at expiry.
The eighty-second queue case fails the stated scheduling contract; the fifty-second case fits it. Credential validity and action authority remain separate checks.
The living notebook
Explore the model
Interactive lab · modular
Keep expiry epochs separate from wrapped counter values
Reset → set both m=10,a=3 predicts 0,3,6,9,2 through four Steps. Reset → set both m=10,a=1 for a fresh comparison. This additive counter has no JWT time, issuer, signature, token, broker, replay defense or resource-server policy.
- Residue r0
- 0
- Orbit period · m/gcd(m,a)
- 12
- Distinct residues visited
- 1 of 12
Addition modulo m starts at zero: rₙ = na mod m. Playback advances two additions per second. The orbit has period m/gcd(m,a), including period one for a = 0. This is not a cryptographic security test or a primality algorithm. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forA short lifetime requires an actual absolute-time and validation contract, not an ambiguous counter value.
Pause & reason
Check your understanding
Your turn
Try it yourself
A no-leeway test credential has expiration time 1,120 s in the validator’s clock domain. Is it valid at time 1,120? If a twenty-second action starts at 1,115 under a valid-at-start-only API, does expiry alone prove it stops by 1,120?
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Use the strict before-expiry predicate, then distinguish credential acceptance from a running operation’s lifecycle.
Compare with the solution
At 1,120 it is expired and must not be accepted in the stated no-leeway fixture. At 1,115 it can satisfy the time check, but a twenty-second operation could finish at 1,135 under the stated start-only contract. Expiry alone does not prove cancellation at 1,120. The service needs its separately enforced deadline/cancellation policy if that stronger behavior is required, along with independent action and resource authorization.
Keep the idea
Take it with you
- Authorize the resolved action before issuing or using scoped tool authority.
- Keep audience, resources, lifetime, revocation and replay semantics explicit.
- Credential expiry does not automatically bound an already running operation.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.