AGENT SECURITY · PRACTICAL FIELD GUIDE

How an AI agent proves who it is: a practical guide to mTLS

Follow a bank dispute request from the mTLS handshake to the permission check that decides whether an AI agent can read a case for its user.

AIConnector editorial · · 5 minute read

← All field guides

The problem: a trusted agent can still make an unauthorised request

Priya, a bank analyst, asks an AI agent to summarise dispute D42. The agent picks the right tool, but Priya doesn’t have access to that case. The worker running the agent has its own account for scheduled jobs. If the API accepts that account alone, Priya could see a case she would be blocked from opening herself.

The Disputes API needs two answers before it returns anything:

  1. Authentication: Who is calling? Did this request come from the registered dispute worker?
  2. Authorization: What is this caller allowed to do? May that worker read this specific case for Priya, in the right bank and environment?

This guide follows a fictional dispute agent from deployment to the API’s decision to allow or deny the read. Mutual TLS helps the worker prove its identity without sending its private key. A scoped token and a case-level permission check decide whether the read can go ahead.

Two engineers discussing a system diagram in a corporate conference room.

1. Give the running software an identity

The model proposes the action. A worker, the running application that hosts or executes the agent, makes the actual network call. The worker is what authenticates. A model name, a prompt, and an entry in an agent registry are not credentials.

In this design, the platform team registers a workload called dispute-worker with the token issuer. It configures the expected certificate identity and which certificate authority to trust. If the issuer assigns an OAuth client ID, the ID is a name, not a password. With certificate-based client authentication, this flow doesn’t need a separate OAuth client secret. The private key is still sensitive.

Registration tells the issuer what to recognise. It doesn’t grant access to any dispute, and it doesn’t require knowing a pod’s private key.

2. Issue the certificate when the worker starts

In our example, a trusted component generates a key pair at startup. It keeps the private key on the workload side and sends a signed certificate signing request containing the public key. The certificate authority verifies which workload is asking, then signs and returns a certificate that binds the public key to that workload identity. The authority signs with its own private key; it never needs the worker’s.

New replicas can receive their own short-lived credentials under the same registered workload identity. Automate renewal, and keep key material out of images, prompts and logs. In a SPIFFE deployment, a SPIFFE ID names the workload and an X.509 SVID is a certificate that lets the workload prove that identity. Exactly where the keys are generated and held depends on the implementation.

3. Prove possession during the same connection

TLS handshake: the worker and issuer each verify their peer. The worker sends the client certificate and signs the handshake. Private keys stay local.
The certificate and proof of possession are checked on the same TLS connection.

With ordinary HTTPS, the worker already verifies the server’s identity. Mutual TLS (mTLS) adds the reverse check: the server also authenticates the worker. Both checks happen within the same TLS connection.

  1. The worker verifies that it’s talking to the expected token issuer.
  2. The issuer requests a client certificate. The worker sends its certificate and a signature made with its private key over the handshake transcript, the messages exchanged so far.
  3. The issuer validates the certificate chain, validity and registered workload identity. It uses the certificate’s public key to verify the handshake signature.

The certificate says whose public key it is. The signature proves the worker can use the matching private key. There’s no callback to the worker, and neither side transmits its private key. In TLS 1.3, the handshake message that carries this proof is called CertificateVerify.

4. Turn identity into a narrowly scoped API call

Now the worker is authenticated to the issuer. It still can’t read D42. It requests a short-lived access token, and the issuer checks the workload’s grant. In this example, the token is valid for the Disputes API, allows only disputes:read, and is restricted to Bank A’s sandbox.

The gateway verifies the signed token, including who issued it, who it’s intended for, whether it’s expired and whether it has the scope for that route. Then the Disputes API makes the record-level decision. It looks up D42 within the tenant and sandbox from the verified authorization context, not from an agent-supplied header or tool argument. An otherwise valid Bank A token must not unlock Bank B’s records. RFC 9068 describes validation for JWT access tokens; tenant and sandbox are application-specific constraints in this example.

One subtle point: using mTLS to get a token doesn’t automatically bind the token to the certificate. A bearer token can still be used by another holder while it is valid, subject to the resource’s other controls. If you need a copied token alone to be unusable, issue a certificate-bound token and ensure the protected resource’s enforcement point checks that binding on the API connection. RFC 8705 specifies that separate mechanism.

5. Keep “on behalf of” separate from “on its own”

A scheduled worker may act under its own narrowly scoped grant. If analyst Priya asks the agent to read D42 on her behalf, carry her identity and the agent’s identity separately. In one OAuth token exchange design, Priya is the subject and the agent is the actor. The issuer must allow that delegation, and the API still checks Priya’s permission for D42.

If Priya can’t read it, don’t retry under the worker’s broader grant or show a summary from memory. A cached copy doesn’t change who is allowed to see the data. The response can be simple: “I can’t access that dispute on your behalf.”

6. Test the denials before launch

TestExpected result
Trusted issuer, but the certificate identifies a different workerDo not authenticate it as the dispute worker.
Valid certificate, but no dispute-read grantDo not issue a token with that scope.
Valid Bank A sandbox token, Bank B or production caseReturn no record or cross-tenant details.
Agent has access; the delegated analyst doesn’tDeny the read; do not fall back to the agent’s own grant or memory.
Grant revoked while a token is still validStop access within the promised window. Test a gateway that misses the revocation event.

For that last test, token expiry and grant revocation are different clocks. If you promise revocation faster than token expiry, use a bounded freshness check for the grant. Push invalidation can make revocation faster; it isn’t sufficient on its own if a gateway misses the notice. Once the freshness limit passes, require a fresh decision or deny the read.

The rule I’d take into a design review: the certificate proves who is calling; the token limits what they can ask for; the API decides whether they can see this record.

Related: Your AI agent can call tools. But can you trust it?

Join the discussion

Share a question, correction, or something you learned. Sign in with GitHub to comment.

Comments powered by Giscus. You can also browse the discussions on GitHub.