Manage secrets as short-lived, narrowly scoped credentials delivered to authenticated workloads through an approved secret system. Keep them out of source code, images, chat, and ordinary logs. Inventory ownership, restrict access by environment, rotate safely, monitor use, protect backups, and prepare an escalation path for suspected exposure.
Who this is for: Software developers, platform engineers, and technical leads managing credentials for applications and delivery systems they own.
- Prefer workload identity and temporary credentials over copied long-lived values whenever the platform supports them.
- Separate development, test, and production secrets, then grant people and services only the entries they require.
- Treat rotation and revocation as tested operational workflows with overlap, rollback, monitoring, and incident ownership.
Inventory secrets and owners
List API credentials, database passwords, signing keys, certificates, webhook verifiers, deployment tokens, and recovery material. For each item, record system, environment, owner, consumer, privilege, creation method, storage location, rotation expectation, and revocation path. Do not copy secret values into the inventory itself.
Search authorized repositories, build settings, deployment configuration, documentation, and logs for likely exposures using approved tools. Coordinate scans with repository and security owners because results can themselves be sensitive. If a live credential appears, stop distributing it, preserve necessary evidence, rotate or revoke it, and follow incident escalation rather than merely deleting the file.
Store and deliver through identity
Use a managed secret store or platform mechanism that encrypts values, authenticates requesters, records access, and supports versioning. Applications should obtain secrets at runtime through a workload identity with least privilege. Avoid embedding them in source, container images, mobile applications, build output, issue trackers, or shared environment files.
Separate environments and tenants so a development identity cannot read production material. Restrict administrators and emergency access. Mask secret-shaped values before logs leave the process, while recognizing that automatic masking is not perfect. Protect secret-store backups, replicas, and export features under the same or stronger access model.
Rotate without breaking services
Define whether the provider supports overlapping versions, dual verification, automatic issuance, and explicit revocation. A safe rotation usually creates a new credential, deploys consumers, verifies healthy use, removes the old credential, and confirms rejection. The exact order depends on whether the secret signs, encrypts, authenticates, or verifies data.
Test rotation in a non-production environment with synthetic dependencies. Include partial deployment, stale workers, rollback, unavailable secret service, and restored backups. Do not leave old credentials active indefinitely as a comfort measure. Assign an expiration and alert when consumers continue using a version scheduled for retirement.
Monitor and respond to exposure
Monitor unusual reads, broad enumeration, failed access, use from unexpected workloads, and changes to policy or versions. Keep logs protected from both secret content and unauthorized editing. Regularly compare actual access with declared consumers and remove stale grants, former staff, unused service identities, and obsolete integrations.
An exposure plan should identify revocation authority, dependent services, customer impact review, evidence handling, communication, and recovery. Rotate according to consequence, not only a calendar. Review inventories, access, expiration, backup controls, drill evidence, and current OWASP guidance quarterly, with immediate action after suspected disclosure or a material platform change.
Move a database credential out of a repository
An authorized team discovers that an application credential was committed to a private repository and copied into its deployment configuration.
- Notify the security owner, limit further access, and identify the credential's systems, privileges, history, and consumers.
- Create a narrowly scoped replacement in the approved secret manager and grant only the production workload identity access.
- Deploy the application to read the new version, verify health and database audit evidence, then revoke the old credential.
- Review repository and platform access, protected logs, backups, forks, and build artifacts under the incident plan.
- Add authorized secret scanning, document ownership and rotation, and test the next replacement in staging.
Secret lifecycle record
Maintain this metadata without recording the secret value itself.
- Identity: secret purpose, system, environment, owner, consumers, privilege, and data consequence.
- Storage and delivery: approved manager, workload identity, access policy, encryption, backup, and logging exclusions.
- Rotation: issue method, overlap support, deployment order, health evidence, revocation check, and rollback.
- Monitoring: expected readers, use locations, alerts, access review, expiry, and stale-version detection.
- Incident plan: revocation authority, dependency map, evidence, communication, recovery, and escalation contact.
Common mistakes
- Moving a credential from source code into an unprotected shared environment file and calling the issue resolved.
- Giving every developer and workload read access to the full production secret namespace.
- Rotating a value without finding old consumers, testing overlap, confirming revocation, or protecting backups.
Try one
A build token appears in a chat transcript shared with a vendor. What actions should the authorized team take and why?
A strong answer treats the token as exposed, not merely hidden. It escalates to the owner, preserves necessary evidence, revokes or rotates the token, checks its least-privilege scope and access logs, identifies dependent builds, and verifies replacements. It reviews transcript access and retention, protects backups, scans authorized systems for copies, and adds a tested secret-delivery path without accusing the vendor or guaranteeing no misuse occurred.
Sources
- OWASP Secrets Management Cheat SheetOWASP guidance for secret creation, storage, access, rotation, and retirement.
- CISA Cyber EssentialsCISA baseline actions for leaders and small organizations managing cyber risk.