Security

Workload identity

View as Markdown

Workload identity lets a machine prove who it is with a short-lived, signed OIDC token in place of a stored secret. The verifier checks the token's signature, issuer, subject, and audience, then grants access for a limited time. Your workload doesn't store a long-lived Grok Build key, but your identity provider still uses its own signing key.

Grok Build supports workload identity in two directions:

DirectionWho presents the tokenWho verifies itUse it to
Grok Build to your systemsA Cloud AgentYour cloud or serviceGive agents access to AWS, GCP, Azure, Vault, or an internal API without storing cloud keys in Secrets.
Your systems to Grok BuildYour workloadGrok BuildRun a self-hosted pool controller without a service account API key.

Cloud Agents to your systems

A Cloud Agent can mint an OIDC token from the machine it runs on. Grok Build signs the token with claims about the agent's owner, team, and run. Your cloud verifies it against Grok Build's OIDC discovery document and exchanges it for a temporary role or credential.

This is the same model as OIDC federation in CI systems. If your policy is meant for a running Cloud Agent, require the cloud_agent_id claim. To limit repositories, match the full repo_urls set rather than repo_url alone. See OIDC tokens for every claim, when it's present, verification steps, and setup for each cloud.

Your systems to Grok Build

With Pools, a pool of self-hosted machines runs a controller that claims work and starts workers. By default, the controller authenticates with a service account API key. With a trusted identity, it authenticates with an OIDC token from your own platform, such as a Kubernetes service account token or a cloud workload identity.

A trusted identity belongs to the team that adds it. It lets one pool controller run one named pool of that team, acting as one of that team's agent service accounts, for the repositories you list. It can use only that team's pools and that team's active agent service accounts. The token it gets works only for that pool's controller requests, not for Grok Build's other APIs.

A trusted identity is not a trusted issuer. A trusted identity lets one pool controller sign in to Grok Build as a service account. A trusted issuer lets a server you run get tokens that act for members of your team or organization.

Trust an identity

Admins with permission to manage team Cloud Agent settings add trusted identities from a signed-in browser session in the self-hosted pool settings of the Grok Dashboard.

Before you start, run a worker in the named pool and create an agent service account. The pool must be bound to repositories.

Add the identity

Under Trusted identities, select Add trusted identity.

Name the issuer and subject

Enter the exact issuer and subject of the tokens your workload presents. Grok Build matches both exactly. Wildcards aren't supported.

The issuer must be an https URL on a public DNS name, with a lowercase host and no port, credentials, query, or fragment. Cursor Tunnel and Cursor corporate hosts are refused. Grok Build reads the issuer's signing keys through its OpenID discovery document at /.well-known/openid-configuration. That document must name the same issuer, and its jwks_uri must be an https URL on the issuer's host. Grok Build must be able to reach both from the internet, without redirects.

Choose the pool and service account

Pick the named pool the identity can run and the agent service account the controller acts as. The default pool can't be used.

List the repositories

Enter the repositories the identity admits, one URL per line. A new identity admits none until you list them.

To change a trusted identity, edit it. Tokens issued before the change stop working.

Changes to trusted identities don't appear in audit logs yet.

Token requirements

The identity token your workload presents must meet these rules:

PropertyRequirement
FormatA JWT signed with RS256 by the issuer named in the trusted identity.
iss and subExactly match a trusted identity for the pool.
audhttps://cursor.com/private-workers, as the only audience.
Lifetimeexp minus iat is 1 hour at most. Both claims are required.
ReuseEach token is exchanged once. Mint a new one for each exchange.

Operational notes

  • Use a dedicated issuer or subject for each pool. Anyone who controls the issuer's signing key can mint a token for any subject.
  • A pool-controller token expires at the earlier of the identity token's exp and 1 hour.
  • Archiving or suspending the service account revokes access.

Run the controller

Point the controller at a file that holds the identity token. It exchanges the token for a pool-controller token, renews before expiry, and reads the file again each time.

Bash

cursor-agent worker controller \
  --spawn ./spawn.sh \
  --identity-token-file /var/run/secrets/tokens/cursor \
  --team-id YOUR_TEAM_ID \
  --pool my-pool \
  --repository https://github.com/your-org/your-repo

--identity-token-file needs --team-id and exactly one named --pool. Pass --repository with a repository the identity admits. It can't be combined with --api-key, --all-pools, or --warm-idle. Workers that the controller starts get their own token for each claim, so no API key reaches them.

Your platform must write a new token to the file before each renewal. On Kubernetes, a projected service account token with the https://cursor.com/private-workers audience and an expiry of 1 hour or less does this for you.

Exchange a token yourself

A custom controller can call the exchange endpoint directly:

Bash

curl -X POST https://api.cursor.com/v0/private-workers/federated-token \
  -H "Content-Type: application/json" \
  -d '{
    "identityToken": "YOUR_OIDC_TOKEN",
    "teamId": 12345,
    "poolName": "my-pool"
  }'

JSON

{
  "token": "POOL_CONTROLLER_TOKEN",
  "expiresAt": "2026-06-01T12:00:00.000Z"
}

The returned token works only for that pool. It expires at the time in expiresAt. The endpoint is rate limited. A 429 response carries a Retry-After header.

A refused identity token returns 401 with the same message for every cause, so check the token against the requirements above.

Revoke an identity

To revoke, delete the identity under Trusted identities. Grok Build refuses further exchanges for it, and tokens already issued to it stop working.

Require trusted identities

To stop pool workers and controllers from signing in with a stored key, turn on Require trusted identities under Pool credentials.

Once it's on, Grok Build refuses pool workers and controllers that sign in with a service account API key, or with a token made from one. Scripts that call the /v0/private-workers endpoints with a service account key are refused too. My Machines workers aren't affected unless they sign in with a token made from a team service account key.

Move every controller to a trusted identity first. Controllers that use --warm-idle or --all-pools can't use a trusted identity, so with a service account key they're refused too.

Choose the right credential

You needUse
A script or service to call Grok Build's APIsAn API key with only the permissions it needs
Shared automation that isn't tied to a personA service account
Your application to act for users who approve it, including users outside your teamAn OAuth application
A server you run to act for members of your own team or organizationA trusted issuer
Agents to reach your cloudOIDC tokens
A pool controller with no stored keyA trusted identity

Last updated: December 1, 2026