Skip to content

Build1 publisher3 min readPublished

Handing an agent the user's session token gives it every permission the user has

An engineer writing on dev.to traces the tenant-and-user token that scopes every query in multi-tenant SaaS, and what breaks when the caller is a process choosing its own API calls on a user's behalf.

The Engineer · Build desk

Illustration accompanying Handing an agent the user's session token gives it every permission the user has

What happened

  • The standard multi-tenant shape is a token carrying tenant_id and user_id with roles attached, validated at a gateway, after which every downstream service scopes its queries to those two claims.
  • The dev.to post argues that model stopped being complete once the caller became a process that decides its own API calls, sometimes across a dozen steps, with no human confirming each one.
  • Three breakages the author says predate agents: tenant_id accepted as a request parameter, admin roles absorbing permissions nobody modelled, and the permission check reimplemented per service.

Compiled by The EngineerSomething wrong?How this is made

Why it matters

  • exposure With one token doing both jobs, a bad payment retry cannot be attributed in review, because the record shows the user's id whether the human or the agent chose the call.
  • constraint A third claim binds only where it is enforced, so the work lands in the services that today trust tenant_id and user_id, not in the gateway that issues the token.
  • cost Scoping an agent below the user's role means paying the migration-plus-support-ticket price that made admin coarse in the first place, on a role model already carrying that debt.
  • precedent If vendors do ship agent identity this year, platform teams get a buy-or-build choice: adopt the vendor primitive, or write the actor axis into every service themselves.

Look at the scoping boundary. Once a gateway validates the token, every service downstream runs its queries against the tenant_id and user_id it resolved from the claims [2]. Two identity axes exist in that token, and separating an agent from the person it acts for needs a third [2]. Hand the agent the user's session token and it holds everything the user holds, for as long as the token is valid. Afterwards there is no way to tell whether the user did it or the agent decided to [12].

"It stopped being complete the day an AI agent became a caller," the post's author wrote of the two-axis model [4]. The worked example is a support-automation agent told, in natural language, to find the three invoices that bounced last month and retry them [11]. One search call plus a retry-payment call per invoice: four API calls minimum out of one instruction, more if a first attempt fails [1]. The post names the first consequence "blast radius stops matching task scope" [13].

The three failure modes it lists are older than agents [6]. A reporting job or a migration script starts accepting tenant_id as a request parameter instead of deriving it from the token, because that was faster to build. Then something calls it cross-tenant by accident [7]. Admin absorbs every permission nobody wanted to model separately, since a new fine-grained role is a migration and a support ticket while checking role == "admin" is one line [8]. Twelve services end up with twelve slightly different answers to "does this user have permission X in this tenant", and an audit is what finds out [9]. An agent inheriting that coarse admin role, or calling through that loose parameter, can trigger the same bug a hundred times a minute without a human noticing the pattern, according to the author [10].

The roadmap line deserves more care than the token-and-enforcement account does. The post asserts that Auth0, Okta and every other identity vendor spent a chunk of their 2026 roadmaps on this problem [14], and it does not link or cite a roadmap document [16]. Everything else here is one engineer's account of several iterations of one multi-tenant platform [15]. There are no incident counts and no measured population of services. The failure modes transfer only to platforms that share the conditions: internal endpoints that take tenant_id as a parameter, a role model where new roles cost a migration, and a permission check written once per team.

Adding a third claim to the token is the cheap half. Enforcement lives in the services that today trust tenant_id and user_id as the boundary for every query [2]. Each of them has to read the new claim and narrow what it will do on the agent's behalf. In my view the sequencing runs opposite to the way vendor roadmaps will present it. The services that still take tenant_id as a request parameter are the same services that will ignore an actor claim. The cleanup the post describes as pre-AI hygiene has to come first.

What to watch

  • Whether Auth0 or Okta publish an actor or agent-identity claim with documented per-service enforcement, since the post asserts 2026 roadmap work without citing it.
  • Whether agent frameworks start writing an actor field into audit logs so a payment retry can be attributed to the agent instead of the user id.
  • Whether internal endpoints that accept tenant_id as a request parameter get closed before an actor claim is added on top of them.
Loading claim ledger
Loading source directory links
Loading share composer
Loading topic controls
Loading related stories