CertPrep
Domain 7 · Lesson 7.3 · 7 min read

Identity, Secrets and Audit

Exam skillIdentity, Secrets, and Audit at Scale

Applying enterprise identity and secrets practice to production Claude deployments, including agent identity, workload identity federation replacing static API keys, credential and secrets management, least-privilege tool permissioning, and audit logging of security-relevant agent actions.

Give each agent its own identity and least-privilege credentials, replace static API keys with workload identity federation, keep secrets out of the model's context, authorize per user, and write audit events from the systems that execute actions.

What you need to know

Agents act on real systems, so they need the same identity discipline as any other workload, and a little more, because a manipulated agent will use whatever access it holds. The principles are familiar: distinct identities, short-lived credentials, least privilege, secrets out of reach, and an audit trail written by the system that did the work.

Agent identity

PracticeWhy
Each agent gets its own identity, distinct from humans and other agentsActions are attributable to a specific agent
Credentials are per agent, short-lived and rotated automaticallyA leak is contained in time and scope
Permissions follow the agent's roleCompromise of one agent does not expose everything
Agents never grant themselves permissionsSelf-escalation defeats least privilege

A shared service account for all agents makes attribution impossible and turns one leak into an organization-wide exposure.

Workload identity federation

Static API keys in pipelines are long-lived secrets copied into many places; when one leaks, rotation means coordinating every copy. Workload identity federation lets a workload (a CI job, a service) exchange its own platform identity for short-lived credentials, so there is no stored key to leak or rotate, and access is scoped and revocable per workload. Rotating a static key weekly shortens exposure but keeps a leakable secret.

Secrets stay out of the context

A secret in a system prompt can leak through outputs, logs and traces, whatever the prompt says about keeping it. Keep secrets in a secrets manager, used by tool code on the server side: the model receives the capability (the tool), never the credential. Encoding a secret is not protecting it, and letting the agent fetch the secret itself still puts it in the context.

Least-privilege tool permissioning

  • Scope data to the user and task, enforced by the backend: a CRM tool that serves the authenticated customer's records only.
  • Grant the operations the job needs: read-only when the agent only answers questions.
  • Scope credentials to the resources used: a GitHub token for the three repositories the agent works on, not the whole organization.
  • Authorize per user on MCP servers that act for users: authenticate each user and authorize each tool call against that user's permissions, while the server's own downstream credentials stay narrow.

Central configuration for coding agents

For Claude Code across an organization, configure authentication centrally in managed settings (the organization's account, or an LLM gateway that holds the credentials), so engineers never handle provider keys. Managed settings can restrict permission rules and hooks to those the organization deploys and block local overrides, so policies cannot be bypassed with launch flags.

Audit logging of agent actions

An audit event answers: who (agent and the user it acted for), did what (action and parameters), to which target, under which approval, when, and with what outcome. Three rules:

  1. Write it from the system that executes the action (the tool or backend), not from the agent describing it. An agent can skip a logging call or write a misleading entry.
  2. Link approvals: the action's audit event references the approval system's record, so "which manager approved this refund?" is provable.
  3. Log successful actions too. Auditors review what happened, not only what failed.

Full conversation transcripts are not an audit record: hard to query, and full of content that may not belong in long-term storage.

In the exam

Identity items describe how agents authenticate, what they can reach and what is logged, then a leak, an over-broad grant or an audit gap. Choose the change that removes the long-lived secret, narrows the grant, moves authorization to the backend, or makes the audit record authoritative. Distractors rotate, encrypt, share accounts, put secrets or user lists in prompts, or rely on agreements and reviews.

Check your understanding

Question 1

140 repositories hold the same static API key, and rotating it after a leak took two days. What addresses the underlying risk?

Show answer

Answer: A. With no long-lived secret, there is nothing to leak or rotate.

Question 2

Expense approvals are logged by the agent through a logging tool it calls after each approval. What is wrong?

Show answer

Answer: C. Audit records must come from the system that executes the action, not from the actor's own account.

Question 3

A CRM tool's service account can read and modify every customer, but the agent only answers questions about the caller's account. What fits least privilege?

Show answer

Answer: D. The credential should allow only what the job needs, and the backend, not the prompt, enforces the scope.

Apply it: Identity and audit for Riverbend's CI agents

Exercise · about 25 minCase: Riverbend Software

Riverbend's CI first-response job and its scheduled jobs use one static Anthropic API key stored in every repository's CI secrets, and a GitHub token with write access to all repositories. Security wants static keys gone by next quarter, no agent able to deploy to production without a change ticket, and an audit trail of every release action.

  1. Replace the static API key.
  2. Scope the GitHub access for the CI first-response job.
  3. Define the audit event for release actions, and where it is written.
  4. Explain how production releases stay gated for agents.
Check your work
Show model answer

1. API key. Use workload identity federation: each CI job authenticates with its CI platform's identity and receives short-lived credentials; the stored key is removed from all repositories, and federation rules allow only Riverbend's CI identities.

2. GitHub access. The first-response job gets a token through the GitHub app with read access to code and CI logs and write access only to create pull requests and comments, scoped to the repositories its channel covers. It cannot push to main or approve pull requests.

3. Audit event. Written by the deploy MCP servers (not by the agent) for every release and rollback call: agent identity, the engineer or pipeline it acted for, environment, version, change ticket, approval record, timestamp and outcome. Events go to the security team's log store with the retention the auditors require.

4. Production gate. The production deploy server accepts a release only with a change ticket whose approval matches the version, checked by the server itself; a PreToolUse hook in managed settings denies production releases without a ticket before the call is even made. The agent has no credentials for the production server outside that path.

Key termsAudit logLeast privilegeWorkload identity federation

Sources