claudio.cool
CCDV-PLessons

CCDV-P · Runtime Guardrails and Production Security

Agent identity, secrets without static keys and audit

⏱ 3 min readDraft

A company has fifteen agents in production. All use the same Anthropic API key, stored as an environment variable in each service and also in two repositories, and all connect to the database with the account of an employee who left. When a key leaks, nobody knows which agent it came from, what it did or how many systems need updating to rotate it.

Agent identity

An agent is a workload with permissions. Its identity must be its own, not a person’s or a shared account:

  • one identity per agent and per environment (production, test), to attribute and revoke individually;
  • permissions attached to that identity and not inherited from whoever launched it;
  • when the agent acts on behalf of a user, distinguish what the agent itself may do from what that user may do, and apply the intersection.

That way, during an incident, you can revoke one agent without stopping the others, and the record says who did it.

Replacing static keys

A long-lived static key is a secret that gets copied, leaked and never expires. Workload identity federation changes the model: the workload identifies itself with a credential its platform gives it (a signed token from the orchestrator, the cloud or the CI system) and exchanges it for a short-lived, narrowly scoped credential. There’s no long-lived secret stored to steal. Examples: on a cloud, service roles assigned to the workload; in CI, per-run OIDC tokens. When a static key is unavoidable (for instance, a provider API key from a vendor that doesn’t federate), treat it as your most carefully guarded secret: see below. Check Anthropic’s and your cloud’s documentation for which federation mechanisms are available for your deployment shape.

Secrets management

  • Secrets live in a secrets manager and are injected at runtime; they don’t go in code, the prompt, the model’s context, logs or the repository.
  • Rotation on a schedule and on suspicion, automated, so rotating isn’t an incident.
  • One key per environment and per application, with spend limits where the provider allows.
  • The model never needs to see a secret: the tool uses it server-side and returns only the result. A secret in context can end up in an output, a log or an exfiltration.
  • Secret scanning in the repository and in logs.

Least privilege per tool

Each tool gets the smallest permission that lets it do its job: a read-only query filtered by account, a write limited to one table, a token scoped to one resource. Permissions are evaluated per call, in the tool’s server, and you don’t trust what the agent says it will do. Higher-risk actions add approval.

Audit

An agent’s audit logging stores the security-relevant actions: agent and user identity, tool and relevant arguments, result, approvals, denials, permission changes, time and an ID linking it to the trace. Requirements:

  • Immutable or integrity-checked, with defined access and retention (per applicable regulations);
  • no secrets or unnecessary personal data in the recorded content;
  • record refusals too, which reveal attempts;
  • review and alert on patterns: an agent accessing what it never accessed, at odd hours, or unusual volumes.

The usual traps

  • One key shared by all agents and environments.
  • Keys in the repository, in long-lived environment variables or in the prompt.
  • Agents using someone’s personal account.
  • Auditing only the successes.
  • Logging full content (with secrets or personal data) into audit logs.

On the exam

For a leaked or hard-to-rotate key, look for per-agent identity and short-lived credentials via federation. For “who did what”, an audit log with individual identity. Discard solutions that leave the secret in the model’s context or in the prompt.

Quick question

A practice exam question on this domain. It counts towards your progress.

A company runs Claude-powered review agents from its CI system across 60 repositories. All pipelines use the same long-lived API key stored as a repository secret, and the key has been copied into several local developer environments for debugging. Last month a contractor left the company and nobody was sure whether the key had been exposed, so the team had to rotate it everywhere during a weekend.

Security wants to remove the static credential and make it possible to know which workload made each request.

Which approach best fits enterprise identity practice?

Practise this domain in a practice exam →