CSE Roadmap

Core tier · about 9 hours · 17 parts

Part 15 of 17 · 5 min read

The question token passthrough ducks

The question token passthrough ducks: whose identity is this, really?

Think of a hotel concierge who runs an errand for a guest. A badge that just says "guest" tells the shop nothing about who actually walked in. A badge that says "the concierge, running an errand for room 412, authorised for this one purchase only" tells the shop exactly who is standing there and on whose authority.

In plain words: part 2 forbade passthrough, a server accepting a token issued for somewhere else and forwarding it as-is. But forwarding nothing at all is not an option either -- a tool-calling agent legitimately needs to act using a person's authority, several hops deep (user, to agent, to a sub-agent, to an MCP tool), without any hop holding a token broad enough to impersonate the person outright. OAuth 2.0 Token Exchange (RFC 8693) is the standard answer: a server exchanges one token for a new one, scoped to the exact next audience, carrying an explicit record of which agent is acting and on whose behalf, instead of either re-showing the original token (passthrough) or minting a token that just says "trust me".

A worked example. Picture the flow this module's authorisation server already runs, extended by one hop: a person approves a request, the client gets a token audienced for the orchestrating agent. That agent now needs to call a downstream MCP tool server -- not with its own token (wrong audience, part 2's check fails on purpose), and not by handing the tool server the person's original token (passthrough, forbidden either way). Instead it calls the authorisation server's token endpoint with grant_type=urn:ietf:params:oauth:grant-type:token-exchange, presenting the person's token as the subject token and its own credential as the actor token. What comes back is a new token: audienced for the tool server, scoped down to only what this call needs, and carrying an act claim that names the orchestrating agent as the one actually presenting it. The tool server's audience check from part 2 still runs unchanged; it now also has a truthful answer to "who is this really, and on whose authority" baked into the token it is checking.

About this example About this part

RFC 8693 (OAuth 2.0 Token Exchange) was published by the IETF in January 2020, for service-to-service delegation generally; its use as the specific baseline for agent identity is recent and still settling; sources describing it that way are dated from 2026. This module's mini-auth code has no token-exchange endpoint (its authorisation server issues one token per flow, not a chain of them); the claims shape below is illustrative of the standard, not a key line from this repo. Last checked: 15 November 2026.

# illustrative only -- the shape RFC 8693 defines, not code from this repo
# the orchestrating agent calls the token endpoint, exchanging the user's token for a scoped one
response = post("/token", {
    "grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
    "subject_token": users_token,          # whose authority this ultimately rests on
    "subject_token_type": "urn:ietf:params:oauth:token-type:access_token",
    "actor_token": agents_own_credential,   # who is actually presenting this request
    "actor_token_type": "urn:ietf:params:oauth:token-type:access_token",
    "audience": "tool-server",              # scoped to exactly the next hop, nothing wider
    "scope": "notes:read",                  # narrowed to what this one call needs
})
# the returned token's claims now carry both: {"sub": "user-412", "act": {"sub": "orchestrator-agent"}}

Agent identity, on-behalf-of, token exchange, actor claim

Agent identity is the requirement that a system be able to say which specific agent took an action, not just which user it was acting for. On-behalf-of describes a request made with a user's authority but under an agent's own identity, rather than the agent pretending to simply be the user. Token exchange (RFC 8693) is the mechanism: a server presents an existing token and gets back a new one, scoped to a new audience, rather than reusing the old one. The actor claim (act) is where the new token records who is actually presenting it, distinct from sub, which still names whose authority it rests on.

Example: a chain "person, to orchestrating agent, to a sub-agent, to a tool server" produces, at the last hop, a token whose sub is still the person and whose act names the sub-agent -- so an audit log answers both "on whose authority" and "which agent actually made this call" from the token alone, without trusting a log line anyone could have mis-written.

For the curious Why this is not just part 2 with extra steps

Part 2's audience check and token exchange solve different halves of the same problem. The audience check is what a server does with a token it is handed: refuse it if the audience is wrong. Token exchange is what happens before that, at the hop before: minting a new, correctly-audienced, correctly-scoped token in the first place, so the server on the receiving end has something legitimate to check. A design with perfect audience checks and no token exchange still has nothing better than passthrough to offer an agent that needs to act across multiple hops.

Quick notes: what you must be able to say

  • A token means nothing until the server checks signature, issuer, audience, expiry and scope -- five independent checks, not one bundled test.
  • Audience is what makes a token single-purpose; passthrough (forwarding a client's token to an upstream API) and the confused deputy attack are both shaped by skipping it.
  • PKCE stops a stolen authorization code from being redeemed; it does not stop a mix-up attack, which needs a separate iss comparison against the issuer recorded before redirecting.
  • SSRF guards resolve a URL to one canonical address with a real parser, then pin the connection to the address they just checked, because the same address has many disguised spellings and a rebinding attack can swap it mid-flight.
  • Approval tied to data flow (what's been read, where it could go) survives a paraphrase that defeats any control built on recognising specific wording.