Skip to content

The harness acts for a user against an external system #372

Closed

Description

@jhrozek

The broker holds the key at its own uid; a model-spawned shell cannot reach it.

mecatl, with deployment work. Blocked — see "Blocked on" below.

Hazards

Facts that were expensive to find and that nobody re-derives on the way to implementing. Each is verified against code.

  • The credential read is the thing worth attacking, and the sibling project currently forwards
    upstream credential tokens in tool result bodies unchanged (toolhive#5293). A tool result body
    reaches the model.
  • The per-spawn narrowing call is not cached in the design as written. Calls 1 and 3 carry caching
    notes; the call that narrows per spawn does not, so every subagent spawn would pay a synchronous
    round trip to the authorization server before the child can act, including a child that only reads
    files and never makes an outbound call. Default child concurrency is 8, and an unreachable AS fails
    spawning closed but fails it. Decided: cache it, keyed on (parent definition, child definition,
    requested scope) — its result does not depend on which spawn asked, so it caches with the same shape
    call 1 already uses. Rejected: moving narrowing to an internal issuer, which would put a mecatl
    signature back on the outbound path that the two-leg shape exists to keep off it.
  • Sender-constrained binding is deferred, and the reason is worth knowing before someone adds it back.
    A cnf binding only stops an attacker who holds the token but not the connection. If the agent loop
    makes the gateway call, an injected in-pod model has both, so binding stops nothing against the
    attacker this epic is actually about. Its value is contingent on the token broker becoming a data-path
    proxy for every outbound call, while its deployment cost is paid always: the gateway must terminate TLS
    itself and require client certificates, so no TLS-terminating ingress can sit in front of it. The floor
    instead is what the design already has — a narrow aud (call 1's audience is the AS and opens nothing
    at the gateway; call 3's is the gateway) plus a short exp, which per the JWT-SVID spec is the replay
    defence for a keyless bearer token rather than a supplement to one. Revisit if the broker becomes a
    proxy for some other reason, or if a leak makes off-pod replay demonstrated rather than modelled. If a
    cnf claim is ever emitted, a claim the verifier cannot check must be a refusal, never a pass; while
    none is emitted there is nothing to fail to verify. If binding is built, the method is mTLS (RFC 8705,
    a thumbprint comparison against a certificate the gateway already terminated) rather than DPoP, whose
    per-request proof JWT, jti replay cache and skew tolerance are all new code on both sides.
  • Who makes the gateway call is unstated in the design. Hop 4 presents mTLS with the same pod
    certificate the cnf thumbprint names, and the broker holds the only copy of that key at its own uid
    so the loop cannot reach it. The design says calls 1, 2 and 3 are made by the broker; it does not say
    who makes hop 4. Either the broker proxies every outbound call, which makes it a data-path proxy rather
    than a token minter, or the loop holds the key and the broker's isolation is gone. Deferring binding
    defuses this rather than answering it — the question returns the moment binding does.
  • The authorization question here is answerable without mecatl signing anything: every IETF draft
    that scopes consent puts a signed artifact keyed on the agent definition, and two-leg already supplies
    that key in act.sub. The consent record's design is a separate, unsettled question and is spike
    work on Run scheduled tasks with bounded, revocable user authority #373. Do not read "the gate can be built now" as "the consent model is decided."

Acceptance criteria

  • The key is held by a process the model's shells cannot reach, demonstrated adversarially rather
    than argued from configuration.
  • One credential read per authorized call, keyed on the end user, counted so the count is
    reviewable.
  • No credential value enters a tool result, a prompt, an event or a log, at any verbosity.
  • The cache survives a restart without re-consenting the user, and an expiry never falls back to a
    broader or service identity.
  • The gateway fetches the authorization server's signing keys from its JWKS endpoint, so a key
    rotation needs no gateway redeploy. ToolHive already has this shape in MultiIssuerTokenValidator
    with a 5-minute cache. A day-one item, not a later refinement: choosing an offline-verified JWT is
    what creates it.
  • The per-spawn narrowing call is cached on (parent definition, child definition, requested scope),
    so spawning a subagent does not depend on the authorization server being reachable.
  • Replay resistance comes from a narrow aud and a short exp, and the exp bound is named in
    the implementation rather than left to whoever writes the token cache. Sender-constrained binding is
    deliberately deferred (see hazards), so the token's lifetime is the whole of its replay defence — a
    long-lived cached token is what would make that deferral wrong in hindsight.
  • The credential read is gated on whether this agent definition may reach this integration for
    this user. The definition is the unit for the authorization question, which is what this epic owes.
    The consent record behind it — who holds it, who signs it, what it is keyed on — is spike work and
    is deliberately left open on Run scheduled tasks with bounded, revocable user authority #373; this epic must not freeze it.

Proof

The same properties, adversarially, with an actor and an ordering. A property-level criterion can go green while being false; these are what stop that.

  • A model-spawned shell under the loosest posture cannot read the key. Written from the attacker's
    side.
  • The read counter shows exactly one read per authorized call, and zero on a refused one.
  • The broker restarts; the user is not asked to consent again.
  • A definition with no grant for the integration is refused the credential read, and the
    operator's own definition still succeeds. Both halves, so "refuse everything" cannot pass.
  • Spawning a child that makes no outbound call does not depend on the authorization server being
    reachable.

Blocked on

Gated on the key-reachability spike (#375), and on three pieces of ToolHive enforcement that
are not filed — scope intersection, sender-constrained binding, and an unforgeable resolved
target.

Slices

Decomposition is the implementer's job; these are the natural seams, not a mandate.

  • The broker at its own uid with its attestation selectors.
  • Mecatl's broker client and token cache.

Reasoning

The design this comes from, both on main:

Every hazard above is stated in full here rather than linked, so this issue stands on its own.

Activity

  1. added
    enhancement
    on Aug 4, 2026
  2. changed the title [-]EP6: the harness acts for a user against an external system[/-] [+]The harness acts for a user against an external system[/+] on Aug 4, 2026
  3. JAORMX commented on Aug 5, 2026

    @JAORMX
    Contributor

    (mecatl comment, posted on Juan's behalf — the #377 answers that land on this issue.)

    Three of the #377 answers shape this epic directly, recording them here so the implementer doesn't have to re-derive them from the parent thread:

    Client-auth (Q1): JWT-SVID assertion first. Chosen for familiarity and least new machinery (vMCP already handles JWTs there). The dependency to keep visible: the token holder binding is a separate choice on a separate connection — cnf binds the access token to the broker's key, checked against the mTLS connection to the gateway, not the AS. JWT-SVID-assertion at the AS is fine as long as mTLS-to-the-gateway stays; if that leg ever loses mTLS, holder binding falls back to DPoP. Don't let "we picked JWT-SVID assertion" get read as answering both questions.

    Access token (Q4): profiled JWT, offline-verified. The gateway verifies against AS keys it holds (JWKS endpoint or static key file — that key-distribution row is now a day-one checklist item, not a later refinement). What's locked in is the claims contract (sub/act/scope/aud/cnf), not the carrier: introspection stays available as an additive liveness/policy check later without changing the token format, so "profiled JWT" should not be read as "introspection forever rejected."

    Consent (Q5): per-agent consent is a requirement. For this epic that means the credential read's gating question — "may this agent reach this integration for this user" — eventually needs a consent record behind it, not just operator policy. The authorization half (definition-keyed gating at hop 5/6) is buildable now on the AS-mediated shape; the integrity half (signed proof of who consented) is part of what pulls the minimal-issuer spike forward (see the #377 deferral amendment). When the record gets built, the leading candidate for who holds it is wherever the schedule grant lives (#373), since that's the one consent artifact the design already makes forgery-resistant.

    And one pre-existing hazard restated with emphasis, because the answer to Q4 sharpens it: the "one credential read per authorized call" criterion is what makes a profiled-JWT scope claim mean anything at the provider — the doc's own sentence: "If the gateway loads every credential the user has and sends the provider a full-scope token, that limit changed nothing about what the provider was asked to do."

  4. jhrozek commented on Aug 5, 2026

    @jhrozek
    ContributorAuthor

    Read through the agent-consent drafts to settle who holds the record, and the answer changes the sequencing rather than just filling in a blank.

    Per-agent consent does not need mecatl to sign anything. Every IETF draft that scopes consent at all puts an AS-signed artifact keyed on the agent definition. Liu et al. (draft-liu-ai-agent-authorization-integration-00) has the most developed version: an authorization_evidence object inside RFC 9396 authorization_details, carrying displayed_content, user_action and a timestamp, signed by the AS. McGuinness (draft-mcguinness-oauth-ai-agent-instance) rules the question out of scope on purpose, since "her consent covers the client as a whole." The expired WSO2 draft names a requested_actor at authorization time, which is still a definition. Nothing ties consent to a running instance.

    So the authorization half is buildable now on the two-leg shape, and the integrity half does not pull the issuer forward the way we assumed. What does pull it forward is the FS grant service, which needs local minting for latency and because the holder requesting attenuation is a goroutine no external attestor can see.

    Two smaller things.

    JWT-SVID assertion settles client auth at the AS. It does not settle holder binding, which lives on a different connection: tokens are cnf-bound to the broker's key, checked against the mTLS leg to the gateway. Fine while that leg keeps mTLS. If it ever doesn't, holder binding falls back to DPoP. Keeping them as separate rows so "we picked JWT-SVID assertion" doesn't get read as answering both.

    Profiled JWT accepted. The claims contract is the sticky part and the carrier is reversible, so introspection stays available later as an additive liveness check. The answer does add a day-one item that wasn't there before: the gateway needs the AS's signing keys, either a JWKS endpoint or a static key file.

    And one thing nobody has raised. Calls 1 and 3 are cached per the doc, but call 2, the per-spawn narrowing, carries no caching note. So every subagent spawn pays a synchronous round trip to the AS before the child can act, including an explorer child that only reads files and never touches vMCP. Default child concurrency is 8. If the AS is unreachable, spawning fails closed but fails. Worth deciding whether to cache call 2, move per-spawn narrowing to the internal issuer, or accept it.

  5. self-assigned this
    on Aug 19, 2026
  6. jhrozek commented on Sep 8, 2026

    @jhrozek
    ContributorAuthor

    This was fixed in #1072

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions