CCDV-P Study Guide

7. Domain 7: Runtime Guardrails and Production Security

7.3. 7.3 Identity, secrets and audit at scale: one identity per agent, no static keys

CCDV-P · Domain 7 · Lesson 7.3 · 22 min read

One identity per agent, workload identity federation instead of static keys, secrets kept out of the agent, scoped tools, and audit of who acted for whom.

Why "svc_agents did it" is not an answer

Granite Federal Credit Union serves 410,000 members, and over two years its platform team has put 30 internal agents into production. One drafts replies for member-services staff, one extracts figures from loan documents, one triages fraud alerts, one prepares collections letters, and so on. All 30 call Claude with one of four static API keys, named prod-a, prod-b, batch and dev. All 30 reach the core banking database through one account, svc_agents, which can read and write every member table.

In November the internal auditors sampled 40 member-record changes made by agents in October. For 31 of them nobody could say which agent made the change, for which staff member, or who approved it. The database log says svc_agents; the Claude usage report says prod-b. The same week, Adaeze, who runs the agent infrastructure, found the batch key pasted on a shared wiki page. Revoking it would stop eleven agents at once, so it stayed live for two days.

None of this is a model problem. Claude decided nothing unusual; the system around it could not tell its agents apart. A shared key hides who called, a shared database account hides who wrote, and a long-lived secret turns one leak into a standing risk.

The fix is enterprise identity practice applied to agents. Every agent gets its own identity and proves it with short-lived credentials instead of stored keys. It holds only the permissions its job needs, and it leaves an audit record that names who acted, for whom and with whose approval.

One identity per agent, and whose authority it carries

Here is the question that trips people up: when the member-services agent changes an address, who is acting? It is tempting to answer "the agent" and stop. There are always two parties. The actor is the workload that made the call. The principal is the person or system whose authority the call uses. An identity design must record both, and must decide which one the downstream system checks.

Agent identity means each agent is a distinct, named, non-human identity everywhere it authenticates: at Anthropic, at the database, at each internal API. On the Claude side the container is a service account, a named identity in your Anthropic organization with no email, password or Console login. A service account starts as a member of the default workspace; you add it to any other workspace it needs. Granite creates 30 of them, gfcu-member-letters through gfcu-fraud-triage, so attribution and revocation now apply to one agent at a time. Rate limits and spend still apply per workspace, so the agents' workspace layout is the second lever.

Granite's identity model, before and after

Today

4 static API keysshared by 30 agents
svc_agentsone database account, read-write on all member tables
Logskey name and account name only

revoking batch stops 11 agents

Target

30 service accountsone per agent, federated, no stored key
Per-agent database roleonly the procedures that agent's tools call
Audit recordagent, member or staff principal, approver

revoking one agent stops one agent

Shared credentials hide which agent acted; one identity per agent makes every call attributable and every revocation small.

The second decision is whose authority each call carries. Acting as a service fits work no single person requested: the overnight fraud triage scans every alert, so it uses its own identity and its own narrow permissions. Acting on behalf of a user fits work a person started. When a member-services officer asks the drafting agent to update an address, the update should carry that officer's identity, typically as a delegated OAuth token. The core system then applies the officer's entitlements, and the record names the officer.

Mode When it wins What it costs
As a service (agent's own identity) Scheduled or system-initiated work with no requesting user; scans and batch jobs Must be scoped tightly by hand; a service with broad rights becomes a confused deputy that acts for anyone who can reach it
On behalf of a user (delegated token) A person asked for this action; the target system already enforces per-user entitlements Token handling per user; consent and expiry flows; the agent can never exceed what that user may do
Both recorded Always, in the audit record One more field per event: actor and principal are logged separately

Memorise the confused deputy: an agent with service-wide rights that acts on a user's request lets that user reach data the user could never reach directly. Delegation removes it, because the downstream check uses the requester's rights.

Workload identity federation: credentials that expire in minutes

Once every agent has its own service account, why not give each one its own API key? Because 30 keys are 30 secrets to store, rotate and leak. Workload Identity Federation (WIF) removes the stored secret. The workload already gets a signed identity token, a JWT, from a platform it runs on: a Kubernetes projected service-account token, AWS, Google Cloud, Microsoft Entra ID, GitHub Actions, SPIFFE or Okta. The SDK trades that JWT for a short-lived Anthropic access token bound to a service account.

An organization admin configures three resources. A federation issuer registers the identity provider and where its public signing keys come from. A federation rule says which JWTs qualify, matching on the subject, audience, exact claims or a CEL expression, and names the target service account, the workspace, the OAuth scope and the token lifetime. The service account is the identity the token acts as. Granite runs its agents in an on-premise Kubernetes cluster whose issuer is not reachable from the internet, so it uploads the cluster's key set inline. The docs warn that inline keys are not refreshed automatically: when the cluster rotates its signing keys, Granite must update the issuer.

How one Granite agent gets a Claude token

CLUSTERprojects a signed JWT for the agent's pod
EXCHANGESDK posts it to /v1/oauth/token
VERIFYAnthropic checks signature, issuer and this agent's rule
TOKENshort-lived, one service account, one workspace, one scope
REFRESHSDK re-exchanges before expiry
The agent never holds an Anthropic secret; it presents the cluster's signed identity and receives a token that expires on its own.

The minted token lives for the lesser of the rule's token_lifetime_seconds (60 to 86,400, default 3,600; the Console wizard suggests 600) and twice the remaining life of the JWT presented. By default, a JWT carrying a jti claim can be exchanged only once, so a replayed token is refused. The rule's scope is a ceiling: workspace:inference allows only the inference endpoints (Messages with token counting, Models, and the OpenAI-compatible chat endpoint), while workspace:developer matches a workspace key and adds Files, Skills and Managed Agents. A call outside the scope returns 403. Granite's letter-drafting agent only calls Messages, so its rule gets workspace:inference.

The migration has one trap the docs call out in a warning. Look at the guard at the top of this start-up code: ANTHROPIC_API_KEY and ANTHROPIC_AUTH_TOKEN sit above the federation variables in the SDK's credential precedence, so a forgotten key silently wins.

import os
from anthropic import Anthropic

# GUARD: a leftover key or token outranks federation and would win silently
for var in ("ANTHROPIC_API_KEY", "ANTHROPIC_AUTH_TOKEN"):
    if var in os.environ:
        raise SystemExit(f"refusing to start: unset {var}")

# Injected per agent by the deployment; none of these values is a secret:
#   ANTHROPIC_FEDERATION_RULE_ID   fdrl_... (this agent's rule only)
#   ANTHROPIC_ORGANIZATION_ID      organization UUID
#   ANTHROPIC_WORKSPACE_ID         wrkspc_... (back-office workspace)
#   ANTHROPIC_IDENTITY_TOKEN_FILE  /var/run/secrets/anthropic.com/token
client = Anthropic()  # EXCHANGES the pod's JWT and refreshes before expiry

The documented migration runs in parallel: configure federation, confirm the rule matches, unset the key everywhere it is injected, confirm with ant auth status that federation now wins, then delete the key. On a cloud platform, that provider's own identity system does this job. Claude in Amazon Bedrock recommends a Bedrock service role or IAM roles that issue temporary STS credentials, with a policy that allows inference only on approved model ARNs. Bedrock API keys, which are bearer tokens, are the least preferred path. Claude Models on Google Cloud use Google Cloud credentials, including Application Default Credentials, with access granted through IAM roles.

Secrets, rotation and the keys that remain

Federation covers Claude. The agents still need credentials for the database, the document store and the card processor. Where do those live? The wrong answer is in the agent's environment, where any tool that can read files or run commands can read them too, and where an injected instruction can ask for them.

Anthropic's secure-deployment guidance recommends the proxy pattern: run a proxy or tool server outside the agent's security boundary that injects credentials into outgoing requests. The agent calls a tool; the authenticated request happens outside. The agent never sees the secret, the proxy enforces an allowlist of endpoints, and it logs every request. Behind the proxy, a secrets manager holds the credentials and, ideally, issues short-lived credentials per agent: a database login that exists for an hour and can run only that agent's procedures. Rotation then happens by expiry instead of by a quarterly ticket. Granite retires svc_agents this way.

Some keys remain, because some tools only accept a key and some hosts have no identity provider. For those, the choice of key matters as much as where it is stored.

Credential What it reaches How Granite uses it
Federated token (sk-ant-oat01-...) One workspace, one scope, minutes to hours Default for all 30 agents
Service account key, scoped to one workspace That workspace only; created by org admins; stops when the account is archived Two vendor tools that only accept a key; 30-day expiry, held in the secrets manager
Key scoped to the organization Several workspaces; each request names one in anthropic-workspace-id Not used; a leak would reach every workspace
Legacy workspace key One workspace, acts as no one, outlives its creator Being replaced, as the docs recommend
Console Admin API key (sk-ant-admin01-...) The whole organization: members, workspaces, keys, usage, the Activity Feed; cannot call Claude One audit-export job only
Token with org:admin scope Admin API, short-lived; the only credential that manages service accounts and federation, but it cannot read the Activity Feed Infrastructure-as-code pipeline, itself federated

Memorise the split between the two families. Developer credentials call Claude and should be scoped to one workspace. Admin credentials manage the organization, carry no per-workspace limit, and belong in as few places as possible. A federation rule that grants org:admin can only be created by a person in the Console, so automation cannot grant itself admin rights. Recognise the supporting controls. Key expiry is chosen at creation (3 hours to 30 days, a custom date, or Never) and cannot be changed later. An organization can set a maximum expiry policy that removes Never, and admins can turn off key creation altogether. IP allowlisting, in beta, limits where a leaked key works.

Least privilege, tool by tool

Identity says who the agent is. Least-privilege tool permissioning says what it may do, and it is enforced in three places that do not depend on the model's good behaviour.

First, the agent's tool list. In the Agent SDK, allowed_tools pre-approves the tools you list. Adding permission_mode="dontAsk" turns every other call that would need approval into a denial, which suits a headless agent with no human to ask. Calls that need no approval at all, such as file reads inside the working directory, still run, so disallowed_tools with a bare tool name removes each built-in tool the agent does not need from the request entirely. What not to use for a production agent is bypassPermissions: the docs reserve it for controlled environments, and because allowed_tools does not constrain it, it approves calls to tools you never listed. Deny rules and hooks still apply in that mode, but least privilege means the agent should never need it.

Second, the tool's own authorization. The address-change tool calls a stored procedure that can update the address columns of one member, with the requesting officer's delegated token, and nothing else. The database role behind Granite's member-letters agent can execute that procedure and read three views; it cannot touch loan limits however the request is phrased.

Third, delegated tokens to MCP servers. The MCP authorization spec requires a server to accept only tokens issued for it as the audience, and forbids passing tokens through to other services. Clients request the minimal scopes and step up when a server answers insufficient_scope.

Three places a tool call is narrowed

AGENT CONFIGallowed tools only; dontAsk denies the rest
TOOL SERVERchecks the principal's entitlements; injects the secret
DATA SYSTEMper-agent role: named procedures, named views
Each layer is enforced by code or configuration, so a fooled model still meets the same limits.

Scope at the Claude side too: the drafting agent's federation rule grants workspace:inference, and the workspace it runs in has its own spend and rate limits, so a runaway loop hits that workspace's ceiling, not the whole organization's.

Audit records that answer who, for whom, approved by whom

The auditors' question was simple: for this change, which agent, for whom, approved by whom, and what happened? Granite has two kinds of log, and neither answered it. Platform logs describe credentials. Debug logs describe code paths, rotate after 14 days, and live where the agents can write.

There are two audit layers, and the exam expects you to know which records which. The control plane is your Anthropic organization. With the Compliance API enabled, its Activity Feed records administrative and platform events, such as keys created and workspace members added, each with an actor; activities are queryable within about a minute and retained for 6 years. Recording starts when you enable it, with no backfill, and it does not include prompt text or model responses from API workloads authenticated with a key. So from the day Granite enables it, the feed can show who creates or deletes a key such as batch; it cannot say who created batch two years ago. It also cannot tell you what an agent did with a member record.

The data plane is yours. Your tool server writes one record per security-relevant action, at the boundary where the action executes. No Anthropic product defines this record, so the fields below are this lesson's own design for Granite, not a platform schema. Look at the three identity fields and the approval field; they are what the October sample lacked.

{
  "event_id": "evt_7Q2M9",
  "time": "2026-10-14T15:02:11Z",
  "actor": "gfcu-member-letters (svac_...)",
  "principal": "staff:m.alvarez (delegated token)",
  "approved_by": "staff:j.chen, approval_id apr_5531",
  "action": "update_member_address",
  "target": "member:4471",
  "decision": "allowed by policy addr-change-v3",
  "outcome": "committed",
  "trace_id": "4bf92f35...",
  "claude_request_id": "req_011C..."
}

Security-relevant means anything that changes data, moves money, grants access, sends outside the organization, or was denied by a control: denials are evidence too. Write records append-only to a store the agents cannot alter, keep arguments as references or hashes rather than raw member data, and correlate them with traces through the trace id and the request id. Set retention from your obligations, not from log-storage defaults. If your horizon exceeds the Activity Feed's 6 years, the docs advise exporting it to your own archive as you ingest it; on Amazon Bedrock, Anthropic recommends retaining activity logs on at least a 30-day rolling basis.

Which record answers the auditor

Database logsvc_agents updated member 4471
Usage reportkey prod-b sent 2,140 requests
Debug logrotated after 14 days, writable by the agent
Tool-boundary audit recordagent, principal, approver, action, outcome, retained to policy
Only a record written at the tool boundary names the agent, the person it acted for and the approver.

The exam traps

  • ✗ One key per environment, shared by every agent. ✓ One service account per agent, federated where an identity provider exists, so attribution and revocation are per agent.
  • ✗ Rotating static keys more often as the answer to a leak. ✓ Remove the stored secret with workload identity federation; rotation and expiry are for the few keys that must remain.
  • ✗ Putting a database password or API key where the agent can read it, then telling the model not to reveal it. ✓ Inject credentials from a proxy or tool server outside the agent's boundary.
  • ✗ One powerful service account for all agents, narrowed by instructions in the system prompt. ✓ Per-agent roles and tool-side authorization with the principal's delegated identity.
  • ✗ An Admin API key in every agent "for usage reporting". ✓ Admin credentials confined to one reporting job; agents get workspace-scoped inference access.
  • ✗ Running a headless production agent in bypassPermissions and trusting allowed_tools to limit it. ✓ allowed_tools with dontAsk, unneeded tools removed with disallowed_tools, and the real limit enforced at the tool server and data role.
  • ✗ Treating the Activity Feed or debug logs as the agent's audit trail. ✓ Your own append-only records at the tool boundary with actor, principal and approver, kept for the required period.

Put it together: move one agent off a shared key

You now have every piece: an identity per agent, federated credentials, secrets held outside the agent, least privilege in three layers, and an audit record that answers the auditor. The exercise moves one job from a stored key to federation, then breaks it the way real migrations break.

The rest of the domain stands on this. Runtime guardrails (7.1) decide whether an action may run, and approval gates supply the approved_by field this lesson records. Threat defense (7.2) assumes the model can be fooled, which is why every control here sits outside it. Organization-wide coding-agent configuration (8.4) applies the same identity, allowlist and telemetry thinking to Claude Code across hundreds of engineers.

Key takeaways

  • ✓ Every agent gets its own non-human identity, and every action records both the actor and the principal it acted for.
  • ✓ Agents act as themselves for system-initiated work and with a user's delegated credentials for user-initiated work, which removes the confused deputy.
  • ✓ Workload identity federation swaps a platform-issued JWT for a short-lived token bound to one service account, workspace and scope; unset ANTHROPIC_API_KEY because it outranks federation.
  • ✓ Credentials the agent needs are injected by a proxy or tool server outside its boundary, issued short-lived by a secrets manager.
  • ✓ Remaining keys are workspace-scoped service account keys with an expiry; Admin API keys reach the whole organization and live in one job only.
  • ✓ Least privilege is enforced in the agent's tool list, the tool server's authorization and a per-agent data role, never by the prompt alone.
  • ✓ The Activity Feed audits organization changes; your append-only tool-boundary records audit agent actions, retained for your regulatory horizon.

Practise this

Practice questions for CCDV-P are being written and are not in this course yet. Read this lesson on the web to answer its check questions, with every option explained: https://claude.termidy.com/learn/ccdv-p/runtime-guardrails-security/identity-secrets-audit/.

Sources