Lesson 12 · Developers

Scoping and grants: sites, actions, duration and revocation

about 12 minutes

This lesson treats a grant to an agent as a data structure with a precise meaning, and works through each dimension with the standards and mechanisms that implement it: OAuth scopes and Rich Authorization Requests for actions, resource indicators and exact-origin matching for destinations, token lifetimes and sender constraints for duration, and revocation and introspection for withdrawal. It includes an evaluable grant model with tests, and the threat model for “use without reveal” credential handling.

A grant is a tuple

Define a grant as an authorisation decision with at least these fields:

grant = (issuer, approver, subject_agent, principal,
         resources, actions, constraints,
         not_before, not_after, max_uses,
         revocation_handle)
  • subject_agent: the specific agent identity (an OAuth client_id, a workload identity), never “any client”.
  • principal: whose authority is being delegated.
  • resources: where the grant applies (origins, APIs, folders, record IDs).
  • actions: what may be done there.
  • constraints: conditions such as amount ceilings, recipient domains, time-of-day.
  • lifetime and budget: not_after, max_uses, or binding to a task ID.
  • revocation_handle: something the issuer can invalidate centrally.

Saltzer and Schroeder’s principles still frame the design. Least privilege: operate with “the least set of privileges necessary to complete the job”. Fail-safe defaults: base decisions on permission rather than exclusion, so the default is no access. Complete mediation: “every access to every object must be checked for authority” [1]. OWASP’s LLM06 restates them for LLM systems as minimising extensions, functionality and permissions, and enforcing authorisation in downstream systems rather than in the model [2].

Ambient authority and the confused deputy

Hardy’s confused deputy was a compiler that had been given licence to write files in its own system directory so it could record usage statistics. A user supplied the name of the billing file in that same directory as the destination for debugging output, and the operating system, seeing the compiler’s licence, let it overwrite the billing records [3]. The compiler could not distinguish authority it held for itself from authority it was exercising for the caller. An agent with a broad OAuth token is in the same position: it holds ambient authority, and any instruction that reaches its context (including indirect prompt injection) can direct that authority.

The capability tradition’s answer is to pass authority together with the designation of the resource, so that the agent can only act on what it was explicitly handed. Miller, Yee and Shapiro argue that capability systems can enforce least privilege and avoid confused deputies in ways ACL-based systems structurally cannot [4]. You do not need a capability operating system to apply the lesson. Issue grants that name specific resources and actions, carry them with the request, and check them at the resource, rather than giving the agent a general-purpose identity and checking intent in a prompt.

Actions: from scope strings to structured authorisation

OAuth 2.0 expresses access as a scope parameter: a space-delimited list of strings whose meaning is defined by the authorisation server [5]. Scopes are coarse by design. invoices.write cannot say “only invoices for client 4471” or “only drafts”.

Rich Authorization Requests (RFC 9396) add an authorization_details parameter carrying typed JSON objects with common fields type, locations, actions, datatypes, identifier and privileges, plus type-specific fields [6]. That is expressive enough for agent grants:

{
  "authorization_details": [
    {
      "type": "credential_use",
      "locations": ["https://portal.tenancy.example"],
      "actions": ["fill"],
      "identifier": "vault-item-8842",
      "privileges": ["no_reveal"]
    },
    {
      "type": "document_access",
      "locations": ["https://files.northside.example/landlords/"],
      "actions": ["create"],
      "datatypes": ["application/pdf"]
    }
  ]
}

The type values and their semantics here are illustrative; RFC 9396 leaves type definitions to the deployment. The value is that the authorisation server can render precise consent (“fill the tenancy portal login, without revealing it”) and the resource server can enforce precisely what was approved.

Split actions along the lines that change risk:

Split Why
read / write Writes change state; reads can still exfiltrate, so pair reads with egress limits
draft / commit (send, publish, merge, pay) Commit is irreversible; put it behind Ask
use / reveal (credentials) Use can be mediated; revealed secrets are copyable
act / delegate Agents should not mint or widen grants for themselves or others
single / bulk export_all is a different risk from read_one

MCP lets servers return only the tools a caller’s scopes permit from tools/list [7], and its security guidance recommends a minimal initial scope with step-up challenges for privileged operations [8]. Design scopes so that step-up corresponds to a real change in risk.

Resources and destinations

Audience binding for tokens

A token valid at every service is a token that can be replayed anywhere it leaks. Resource Indicators (RFC 8707) let a client name the target resource when requesting a token so the authorisation server can audience-restrict it [9]. RFC 9700 recommends that access tokens be audience-restricted to a specific resource server or a small set, with every resource server obliged to check [10]. MCP makes audience validation mandatory and forbids token passthrough [11].

Origin binding for credentials

When the grant is to use a stored credential in a browser, the “resource” is a web origin, and the matching rule is the whole security property. Rules that hold up:

  • Exact origin match (scheme://host:port), https only, no wildcards by default. portal.tenancy.example.evil.test must not match portal.tenancy.example.
  • Normalise before comparing. Convert internationalised hostnames to their ASCII (punycode) form so that a homograph such as a Cyrillic “а” produces a different string, not a visually identical one.
  • Re-check after redirects. The origin that receives the credential is the one that matters, not the one the agent was originally sent to.
  • Treat subdomain or registrable-domain matching as an explicit, recorded exception for sites that genuinely need it.

The limits of use-without-reveal

“Use without reveal” means the agent can cause a credential to be filled into the correct page but never receives the plaintext. It defends against an agent that is manipulated into printing or forwarding the secret, and against secrets entering model context and provider logs. It does not defend against software that can read the page after filling. One password manager states this boundary plainly in its privacy policy: once a login is filled, “it sits in the web page like a login you typed yourself”, so software that can read or control that page, including an AI agent given browser-automation or “computer use” access, may be able to read it [12]. Your threat model should therefore separate:

Agent capability Use-without-reveal protects the secret?
Calls APIs or tools only; no page access Yes, if the fill happens outside the agent’s process
Reads page text or accessibility tree Partially; depends on whether filled fields are exposed
Full browser control (DOM, scripting, screenshots of revealed fields) No; treat as reveal

Pair use-without-reveal with exact-origin binding, short grants and, where possible, credentials that are useless off-origin (passkeys, sender-constrained tokens).

Duration

Lifetime is the dimension that converts a leak into a bounded incident.

  • Short access tokens. The access token lifetime is the upper bound on how long a revoked or stolen token keeps working at resource servers that validate locally.
  • Refresh tokens. RFC 9700 requires refresh tokens for public clients to be sender-constrained or rotated [10]. With rotation, reuse of an old refresh token is a detectable signal of theft.
  • Sender-constrained tokens. RFC 9700 describes sender-constraining, where the holder must prove knowledge of a secret for the token to be accepted, and points to two mechanisms in use: mutual TLS (RFC 8705) and DPoP (RFC 9449) [10]. A stolen sender-constrained token is not usable by itself.
  • Task-bound grants. Bind the grant to a task or run ID and end it when the task completes. This matches the grant to the brief better than any fixed time.
  • Use budgets. max_uses caps damage from a runaway loop or an injected instruction to repeat an action.

Zero trust architecture applies the same idea at the session level: access to each resource is granted per session with least privilege, and authentication to one resource “will not automatically grant access to a different resource” [13].

The counter-pressure is human attention. Very short grants that each need approval produce approval fatigue (lesson 10). A workable pattern is a standing grant for low-risk, high-frequency reads; task-bound grants for routine work; and one-use approvals for commits and reveals.

Delegation and attenuation

Agents increasingly call sub-agents and tools that call other services. Two mechanisms keep authority from growing as it passes along:

  • Token exchange (RFC 8693) lets a service exchange a token for another, and defines an act (actor) claim that expresses “that delegation has occurred” and identifies the acting party [14]. Use it so downstream services can see both the principal and the agent, and so the downstream token can be narrower than the upstream one.
  • Attenuation. Macaroons embed caveats that “attenuate and contextually confine when, where, by who, and for what purpose” a target service should authorise requests [15]. Whether or not you use macaroons, the rule generalises: a delegated grant may only be equal to or narrower than its parent.

Revocation

Revocation has three parts: the decision, propagation and verification.

Decision. OAuth token revocation (RFC 7009) lets a client tell the authorisation server a token is no longer needed; revoking a refresh token should also invalidate access tokens based on the same grant where the server supports it [16].

Propagation. Resource servers that validate self-contained tokens locally will not see revocation until expiry unless they ask. Token introspection (RFC 7662) lets a resource server query whether a token is active [17]. Effective revocation latency is therefore:

latency ≈ min(access_token_remaining_lifetime, introspection_cache_ttl)  for introspecting resource servers
latency ≈ access_token_remaining_lifetime                                for local-validation-only resource servers

Verification. After revoking, attempt a harmless call with the revoked grant and confirm denial. Record the observed latency. If secrets were visible to the agent, rotate them; revocation does not un-copy a secret.

Revoke at the issuer. Removing a connector from an agent host stops that host from using the grant but may leave the grant valid for anyone else holding it.

An evaluable grant model

The model below implements who, where, what and how long, with exact-origin matching and IDNA normalisation. It is illustrative, not any product’s API. Tested with Python 3.13.

"""Illustrative grant evaluation: who, where, what, how long. Not a product API."""
from dataclasses import dataclass, field
from datetime import datetime, timezone
from urllib.parse import urlsplit


@dataclass
class Grant:
    grant_id: str
    agent_id: str
    origins: frozenset[str]          # exact scheme://host[:port], no wildcards
    actions: frozenset[str]          # e.g. {"credential.use"}; never implies "credential.reveal"
    not_after: datetime
    max_uses: int | None = None
    uses: int = 0
    revoked: bool = False
    constraints: dict = field(default_factory=dict)


def origin_of(url: str) -> str:
    parts = urlsplit(url)
    if parts.scheme != "https" or not parts.hostname:
        raise ValueError("only https URLs with a host are acceptable")
    host = parts.hostname.encode("idna").decode("ascii")   # compare in punycode form
    port = f":{parts.port}" if parts.port and parts.port != 443 else ""
    return f"https://{host}{port}"


def decide(grant: Grant, agent_id: str, action: str, url: str, now: datetime | None = None) -> tuple[bool, str]:
    now = now or datetime.now(timezone.utc)
    if grant.revoked:
        return False, "revoked"
    if agent_id != grant.agent_id:
        return False, "wrong agent"
    if now >= grant.not_after:
        return False, "expired"
    if grant.max_uses is not None and grant.uses >= grant.max_uses:
        return False, "use budget exhausted"
    if action not in grant.actions:
        return False, f"action {action!r} not granted"
    try:
        origin = origin_of(url)
    except ValueError as exc:
        return False, str(exc)
    if origin not in grant.origins:
        return False, f"origin {origin} not in grant"
    return True, "allowed"

Test cases and results (evaluation time 2026-12-01 01:00 UTC, grant valid until 08:00 UTC, origin https://portal.tenancy.example, actions credential.use and statement.download):

Agent Action URL Decision
statements-agent credential.use https://portal.tenancy.example/login allowed
statements-agent credential.reveal https://portal.tenancy.example/login denied: action not granted
statements-agent credential.use https://portal.tenancy.example.evil.test/login denied: origin not in grant
statements-agent credential.use http://portal.tenancy.example/login denied: https only
statements-agent credential.use https://portal.tenаncy.example/login (Cyrillic “а”) denied: https://portal.xn--tenncy-5nf.example not in grant
other-agent credential.use https://portal.tenancy.example/login denied: wrong agent
statements-agent credential.use same, at 09:00 UTC denied: expired
statements-agent credential.use same, after revocation denied: revoked

Two caveats. Python’s built-in idna codec implements the older IDNA 2003 rules; production code should use a maintained IDNA 2008/UTS 46 library and also apply a confusables policy. And this check belongs at the component that performs the fill or call, not in the agent: the agent should never be the one deciding whether its own request matches.

Worked example: Northside Property’s statements agent

Northside Property’s office manager wants an agent to download monthly rent statements from a tenancy portal and file them per landlord. The developer, Tom, designs the grants:

  1. Identity. A dedicated agent identity, statements-agent, registered as its own OAuth client with the file store and as a named agent in the credential tool.
  2. Credential grant. credential.use on the vault item for the portal, origin https://portal.tenancy.example exactly, no reveal, 8 hours on the first business day of each month, budget of 20 uses. The agent runs headless with no general browser control, so use-without-reveal is meaningful in this configuration.
  3. File grant. create on /landlords/ only, PDF only, via a token audience-restricted to the file store, 1-hour lifetime with rotation.
  4. No egress. The agent has no email, messaging or general HTTP tool, so it cannot send what it downloads anywhere else.
  5. Revocation runbook. Revoke the OAuth client at the file store, revoke the credential grant in the credential tool, rotate the portal password if any doubt. Measured latency: under 2 minutes for the file store (introspection), immediate for credential use.

When the portal moved to a new domain, the first run failed closed with “origin not in grant”. That is the intended behaviour: a human confirmed the new domain was legitimate and updated the grant, rather than the agent following a redirect to a site no one had approved.

Pitfalls

  • Wildcard scopes (files:*, admin) granted up front “to save time”; MCP’s guidance calls out this pattern as expanding blast radius and making revocation disruptive [8].
  • Approvals that silently become standing grants (“don’t ask again” with no expiry).
  • Revoking in the client only.
  • Matching on registrable domain or substring instead of exact origin.
  • Long-lived refresh tokens without rotation or sender constraint.
  • Delegated tokens broader than the parent.
  • Grants that name an agent “type” rather than an agent instance, so revoking one revokes all or none.

Key takeaways

Model every grant as an explicit tuple of agent, principal, resources, actions, constraints, lifetime and revocation handle, defaulting to no access and checked at the resource on every call. Use structured authorisation (RFC 9396) where scope strings are too coarse, audience-restrict tokens with resource indicators, and bind credential use to exact, normalised https origins re-checked after redirects. Treat use-without-reveal as protection against agents without page access, not against agents with browser control. Keep tokens short-lived, rotate or sender-constrain refresh tokens, bind grants to tasks and budgets, and make delegated grants strictly narrower than their parents. Revoke at the issuer, know your revocation latency, verify denial afterwards, and rotate any secret the agent could see.

How primitive approaches this. pass’s Chrome Web Store listing describes per-agent Allowed, Ask or Never choices with access that can be limited and revoked [18]. Its privacy policy states that it keeps “the purpose you or the agent gives, approval and expiry times, and an audit receipt of each use”, and describes an optional Rebirth Lock that “checks whether a website’s domain appears to have changed hands before it fills a saved login”, sending “the website’s registered domain only” to its server [12]. These are primitive’s own statements; this lesson’s model is a vendor-neutral way to evaluate any such system.

Sources and further reading

  1. Saltzer, J. H., & Schroeder, M. D. (1975). The protection of information in computer systems. Proceedings of the IEEE, 63(9), 1278–1308. https://doi.org/10.1109/PROC.1975.9939 (open copy: https://www.cs.virginia.edu/~evans/cs551/saltzer/)
  2. OWASP Gen AI Security Project. (2025). LLM06:2025 Excessive Agency (OWASP Top 10 for LLM Applications 2025). OWASP Foundation. https://genai.owasp.org/llmrisk/llm062025-excessive-agency/
  3. Hardy, N. (1988). The Confused Deputy (or why capabilities might have been invented). ACM SIGOPS Operating Systems Review, 22(4), 36–38. https://doi.org/10.1145/54289.871709 (archived open copy: https://web.archive.org/web/2023/http://cap-lore.com/CapTheory/ConfusedDeputy.html)
  4. Miller, M. S., Yee, K.-P., & Shapiro, J. (2003). Capability Myths Demolished (Technical Report SRL2003-02). Systems Research Laboratory, Johns Hopkins University. https://papers.agoric.com/assets/pdf/papers/capability-myths-demolished.pdf
  5. Hardt, D. (Ed.). (2012). The OAuth 2.0 Authorization Framework (RFC 6749), Section 3.3. IETF. https://www.rfc-editor.org/rfc/rfc6749
  6. Lodderstedt, T., Richer, J., & Campbell, B. (2023). OAuth 2.0 Rich Authorization Requests (RFC 9396). IETF. https://www.rfc-editor.org/rfc/rfc9396
  7. Model Context Protocol. (2026). Tools (Specification, revision 2026-07-28). https://modelcontextprotocol.io/specification/2026-07-28/server/tools
  8. Model Context Protocol. (2026). Security Best Practices (documentation for protocol revision 2026-07-28). https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/security_best_practices
  9. Campbell, B., Bradley, J., & Tschofenig, H. (2020). Resource Indicators for OAuth 2.0 (RFC 8707). IETF. https://www.rfc-editor.org/rfc/rfc8707
  10. Lodderstedt, T., Bradley, J., Labunets, A., & Fett, D. (2025). Best Current Practice for OAuth 2.0 Security (RFC 9700). IETF. https://www.rfc-editor.org/rfc/rfc9700
  11. Model Context Protocol. (2026). Authorization (Specification, revision 2026-07-28). https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization
  12. Primitive AI (PRIMITIVE AI LABS PTY LIMITED). (2026, 25 October). Primitive Pass Privacy Policy, section 03 (“AI agent access” and “Rebirth Lock”). https://pass.primitiveai.com.au/privacy.html (primitive’s own statements; effective 25 October 2026)
  13. Rose, S., Borchert, O., Mitchell, S., & Connelly, S. (2020). Zero Trust Architecture (NIST SP 800-207). National Institute of Standards and Technology. https://csrc.nist.gov/pubs/sp/800/207/final
  14. Jones, M., Nadalin, A., Campbell, B. (Ed.), Bradley, J., & Mortimore, C. (2020). OAuth 2.0 Token Exchange (RFC 8693). IETF. https://www.rfc-editor.org/rfc/rfc8693
  15. Birgisson, A., Politz, J. G., Erlingsson, Ú., Taly, A., Vrable, M., & Lentczner, M. (2014). Macaroons: Cookies with Contextual Caveats for Decentralized Authorization in the Cloud. Network and Distributed System Security Symposium (NDSS). Internet Society. https://research.google/pubs/macaroons-cookies-with-contextual-caveats-for-decentralized-authorization-in-the-cloud/
  16. Lodderstedt, T. (Ed.), Dronia, S., & Scurtescu, M. (2013). OAuth 2.0 Token Revocation (RFC 7009). IETF. https://www.rfc-editor.org/rfc/rfc7009
  17. Richer, J. (Ed.). (2015). OAuth 2.0 Token Introspection (RFC 7662). IETF. https://www.rfc-editor.org/rfc/rfc7662
  18. Primitive AI. (n.d.). primitive pass, Chrome Web Store listing. https://chromewebstore.google.com/detail/primitive-pass/kfbmepahbbjlhkgcapldmdmdbaodmgfl