Secrets, Identity, and Access Management
CoreManage identity, secrets, and API keys correctly · Difficulty 1/5
Explanation
Securing a Claude application includes the ordinary identity and credential hygiene any production system needs -- the model does not change these requirements.
API Keys and Secrets
Store keys and secrets in environment variables or a secrets manager. They must never be hard-coded in source, committed to version control, or pasted into prompts or logs -- each of those is a durable, hard-to-revoke leak. Use separate keys per environment (dev/staging/prod) so a compromise in one environment doesn't expose another, rotate keys on a schedule, and revoke immediately on exposure.
Identity, Authentication, and Authorization
- Identity & authentication -- validate the caller's identity; authenticate every request rather than assuming a request is legitimate because it reached the system.
- Authorization / access-level verification -- verify the caller is approved for the specific action and data, at the right access level (least privilege), *before* the agent acts on their behalf. An agent acting with the caller's identity should never have broader access than the caller itself would have.
- Access monitoring -- log and monitor authorized (and attempted) access so misuse is detectable, not just theoretically preventable.
Worked Example
Which is a safe way to handle an API key? Store it in an environment variable or secrets manager, scoped per environment and rotated -- not hard-coded in source, not committed to the repo "for the team," and not pasted into the system prompt. Secrets belong in env/secret stores, never in code, version control, or prompts.
Common exam traps
- Hard-coding or committing an API key is the classic leak pattern this domain tests for -- exam items reliably reward env/secret-store storage, environment scoping, and rotation over any form of embedding a key directly in code, prompts, or logs.
- Assuming authentication alone is sufficient. Authenticating *who* the caller is does not verify *what* they're authorized to do -- authorization/access-level verification is a distinct, additional check before the agent acts.
Key Takeaways
- API keys/secrets belong in environment variables or a secrets manager -- never hard-coded, committed, or pasted into prompts/logs
- Use separate keys per environment (dev/staging/prod); rotate on a schedule and revoke immediately on exposure
- Authenticate every request (identity) and separately verify authorization/access level (least privilege) before the agent acts on a caller's behalf
- Log and monitor authorized and attempted access so misuse is detectable
- Exam trap: hard-coding or committing a key is the classic wrong answer to flag; env/secret-store storage with scoping and rotation is the safe pattern
Glossary Terms
A security risk pattern in which an agent acting with broad service credentials on behalf of a low-privilege user can leak or change data the user should not be able to touch. The fix is to scope tool permissions to the calling user's entitlements rather than the service account's broader credentials, so the agent can never do more on the user's behalf than the user could do directly.
A security principle applied to agent tool design: give each agent and subagent only the minimum tools required to complete its specific task. Reduces blast radius if an agent is compromised or makes an error. Implemented via AgentDefinition tool lists and skill allowed-tools.
Related Concepts