Home / Insights / Architecture and Modernization

Architecture and Modernization

Secrets Management for Growing Teams: Vaults, Rotation and Least Privilege Without Slowing Delivery

A five-person team can get away with secrets in a shared password manager and a few CI variables. At twenty engineers and a dozen services, that approach leaks, breaks and blocks audits. This is a practical path from there to a vault-based model with rotation and least privilege.

TopicsArchitecture and ModernizationWeb and SaaS Development

Key takeaways

  • The goal is not just a vault. It is fewer long-lived secrets: prefer platform identities and short-lived tokens, and vault only what cannot be replaced by identity.
  • Treat every secret as something that will leak eventually. Scanning, redaction and a tested rotation path matter more than the vault product you choose.
  • Rotation only works when applications fetch secrets at runtime and tolerate two valid credentials during the switch. Design for that before scheduling rotation.
  • Scope access per secret and per environment, and log every read. Least privilege is an access model, not a role name.
  • Migrate in stages: inventory, scanning, CI first, then services, then rotation. Each stage pays for itself before the next starts.

Secrets sprawl happens gradually. A database password lands in a .env file that is copied between laptops. A payment API key is pasted into a CI variable. A cloud access key is created for a one-off script and never deleted. None of this feels dangerous at the time. Then a contractor leaves, a repository is made public by mistake or an auditor asks who can read the production database credentials, and nobody can answer.

This article is for CTOs, engineering managers and platform leads at companies that have grown past the point where informal secret handling works, typically somewhere between ten and fifty engineers, with several services across cloud, CI and mobile. It explains the options, how to decide between them, how to introduce a vault and rotation without stalling delivery, and what it costs. It reflects how we approach access control and secrets management when we set up cloud and DevOps foundations for clients: infrastructure as code, pipelines that deploy every change, and security controls that engineers will actually use.

Why secrets sprawl becomes a business problem

Most teams underestimate the blast radius of one leaked credential. The GitHub Actions security hardening guide makes the point bluntly: anyone with write access to a repository can read all of its secrets, so the credentials a workflow uses should have the fewest privileges that still do the job. The same logic applies to every place a secret lives.

The failure modes we see most often

  • Leavers who keep access. Shared credentials are not rotated when someone leaves, so former staff and contractors retain working access for months.
  • Secrets in version control. A key committed once stays in history even after the file is deleted. GitHub’s secret scanning documentation notes that once a credential is exposed the right response is to rotate it immediately; rewriting history is slow and usually unnecessary once the credential is revoked.
  • Secrets in logs. Debug output, crash reports and CI logs capture tokens. GitHub’s guidance is explicit that redaction is not guaranteed and that a secret which reaches a log should be treated as compromised.
  • Over-privileged credentials. One cloud key that can do everything, used by every service, because it was easier to set up.
  • Nobody knows what exists. Without an inventory, you cannot rotate, revoke or audit.

The business consequences are concrete: failed security questionnaires in enterprise sales, slow incident response because nobody knows what to rotate, and outages when a credential expires unexpectedly. If your sales team is already fielding SOC 2 questions, our guide to SOC 2 readiness and security questionnaires explains how secrets management shows up in those assessments.

The options: from environment files to managed vaults

Secrets management sits on a spectrum. Most growing teams need to move two steps to the right, not jump to the far end.

ApproachHow it worksFits whenMain weakness
Local .env files and shared password managerEach engineer copies values; production values pasted into hosting configFewer than five engineers, one or two servicesNo audit trail, no rotation, copies everywhere
CI and platform secret storesSecrets stored in CI variables or the hosting platform’s settingsSmall teams with one deployment targetReadable by anyone with write access; hard to share across services
Cloud-native secret managerAWS Secrets Manager, Google Secret Manager, Azure Key Vault; apps fetch at runtime via cloud identityTeams mostly on one cloudMulti-cloud and on-premises gaps; per-secret pricing
Dedicated vaultHashiCorp Vault or OpenBao, or a hosted equivalent, with dynamic secrets and many auth methodsMulti-cloud, Kubernetes-heavy or regulated environmentsOperational burden if self-hosted; needs ownership
Identity instead of secretsWorkload identity, OIDC federation, IAM roles: no stored credential at allEverywhere it is supportedNot every third-party API supports it

The most important row is the last one

The best secret is one that does not exist. Google’s Secret Manager best practices recommend preferring platform-provided credentials, such as workload identity or workload identity federation, over exported service account keys. GitHub recommends OpenID Connect for cloud deployments from Actions, because it issues short-lived, narrowly scoped tokens per run instead of long-lived credentials stored as secrets. In practice, a growing team can usually eliminate most cloud access keys this way and keep the vault for what remains: third-party API keys, database credentials for legacy systems, signing keys and encryption keys.

How to decide: a short decision framework

Work through four questions before choosing tooling.

  1. Where do your workloads run? Mostly one cloud points to that cloud’s secret manager. Kubernetes across clouds, or significant on-premises systems, points to a dedicated vault.
  2. Which secrets can become identities? List every credential used for service-to-service or CI-to-cloud access and mark the ones replaceable by IAM roles, workload identity or OIDC. Those come out of scope entirely.
  3. Who needs to operate it? A self-hosted vault needs an owner for upgrades, unsealing, backups and availability. If no one on the team wants that job, choose a managed service.
  4. What will auditors ask? If you need to show who accessed which secret and when, make per-access audit logging a hard requirement. Google’s guidance, for example, recommends enabling data access logs so each secret read is recorded.

An illustrative example

For example, a 25-engineer SaaS company running on one cloud with managed Kubernetes, GitHub Actions and a handful of third-party APIs would typically land on: OIDC from CI to the cloud (no stored cloud keys), workload identity for services, and the cloud’s secret manager for third-party API keys and database credentials, with per-secret access policies. That is a reasonable default, not a universal answer; a company with on-premises systems or strict residency requirements would weigh a dedicated vault more heavily.

If your cloud foundations are still informal, it is worth setting up accounts, networking and guardrails first; our article on cloud landing zones for small companies covers that groundwork.

Least privilege in practice: scope, environments and identities

Least privilege is often described as a principle and rarely implemented as one. The NIST Zero Trust Architecture publication (SP 800-207), published in 2020, sets the frame: no implicit trust is granted to an asset or account based on its network location or ownership, and authentication and authorisation happen before each session. For secrets, that translates into a few concrete rules.

Scope access per secret, not per team

Google’s best practices recommend secret-level access bindings or conditions when many services share a project, so each workload can read only the secrets it needs. The same pattern exists in every major secret manager and vault. Avoid a single broad role that reads every secret in an environment.

Separate environments completely

Production secrets should live in a different scope, account or namespace from staging and development, with different identities able to read them. A developer debugging locally should never be able to fetch a production database password by changing a configuration flag.

Give machines identities, not shared passwords

  • CI pipelines authenticate to the cloud with OIDC, scoped to a repository, branch or environment.
  • Services authenticate with workload identity or instance roles, then read the specific secrets they need.
  • Humans use single sign-on with multi-factor authentication and time-limited elevated access for production.

Default CI tokens to read-only

GitHub’s hardening guide recommends setting the default workflow token permission to read-only for repository contents and raising permissions only for the specific jobs that need them, which limits the damage if a token is exposed. Apply the same idea to any automation token.

Log and review access

Every read of a production secret should be logged with the identity that made it. Review access logs for anomalies, and review bindings quarterly to remove identities that no longer need access.

Rotation that does not cause outages

Teams avoid rotation because the last time someone rotated a database password, production went down. The fix is to design applications and schedules so that rotation is routine.

Three preconditions

  1. Applications fetch secrets at runtime from the secret manager or vault, not from a value baked into an image or set once at deploy time. Google’s guidance also warns against relying on environment variables and files, which can leak through application vulnerabilities and logs.
  2. Two credentials can be valid at once. Rotation should create the new credential, roll it out, then revoke the old one, rather than replacing in a single step. For databases this is often done with two alternating users.
  3. Pinned versions with a rollback path. Google recommends referencing a specific secret version rather than the latest alias, so changes go through your normal release process and can be rolled back, and disabling a version before destroying it.

Managed rotation where it exists

Cloud secret managers increasingly rotate common credential types for you. The AWS Secrets Manager rotation documentation describes managed rotation for supported services, managed rotation for partner-held external secrets, and rotation by Lambda function for everything else, where the function updates both the stored secret and the target system so they stay in sync. Use managed rotation where available; write custom rotation only for credentials that genuinely need it.

A workable schedule

Secret typePreferred approachRotation cadence (illustrative)
Cloud access keysEliminate via OIDC or workload identityNot applicable once removed
Database credentialsManaged rotation or dynamic credentialsAutomated, frequent
Third-party API keysVault with runtime fetch; manual or scripted rotationScheduled, plus on any suspected exposure
Signing and encryption keysKey management service with versioningScheduled per policy; never delete old versions still needed to decrypt
Human passwords and SSOIdentity provider with MFAOn leaver, on exposure

Cadences above are a starting pattern to adapt to your risk appetite and compliance obligations, not a standard. The one non-negotiable rule is immediate rotation on any suspected exposure, including a secret appearing in a log.

A staged migration plan

The following sequence lets a team improve its position each stage without a big-bang cutover. Timings are illustrative for a team of fifteen to thirty engineers with a part-time platform owner.

  1. Inventory (1 to 2 weeks). List every secret: what it is, where it is stored, what reads it, who can access it, when it was last changed. Expect surprises.
  2. Turn on scanning and redaction. Enable secret scanning and push protection on repositories, add pre-commit checks, and mask sensitive values in CI output. Our article on layering SAST, DAST, dependency scanning and secrets detection in CI covers how to do this without slowing releases.
  3. Fix CI first. Replace stored cloud credentials in pipelines with OIDC, set default tokens to read-only, and move remaining pipeline secrets into environment-scoped stores with required reviewers for production.
  4. Stand up the secret manager or vault. Define naming, environment separation, per-secret access policies and audit logging. Write the runbook for adding, reading and rotating a secret.
  5. Migrate services one at a time. Start with the service that has the most sensitive credentials. Switch it to runtime fetching, verify it under load, then remove the old copies.
  6. Introduce rotation. Begin with managed rotation for databases, then scripted rotation for API keys, with a rehearsal in staging for each type.
  7. Rotate everything that predates the migration. Any credential that lived in a .env file or chat message should be considered exposed and replaced.
  8. Review quarterly. Re-run the inventory, prune unused secrets and identities, and check that audit logs are being reviewed.

Risks, costs and common mistakes

Costs

Managed secret managers typically charge per secret and per access; for most growing teams this is a small line item compared with engineering time. The larger costs are platform engineering effort for the migration, the operational burden if you self-host a vault, and the application changes needed for runtime fetching and rotation tolerance. Budget for the application work; it is where migrations stall.

Mistakes that undo the benefit

  • Syncing vault secrets into weaker stores without checking their access controls and auditability. Google’s guidance specifically calls for evaluating those properties before syncing secrets to systems such as Kubernetes Secrets.
  • One service account that reads everything. It recreates the shared-password problem with extra steps.
  • Bundling several values in one secret. GitHub notes that redaction depends on exact matches, so a JSON blob stored as one secret may leak its parts to logs unredacted.
  • Never rehearsing rotation. The first rotation should happen in staging on a quiet afternoon, not in production during an incident.
  • Forgetting mobile and desktop apps. Keys embedded in client applications are public. Move the calls that need them behind your own API.
  • Treating the vault as finished. Without ownership and review, sprawl returns inside the vault.

If you are weighing whether to run this platform work in-house or with external help, our comparison of what to outsource and what to keep in DevOps may be useful.

Secrets management checklist

  • A current inventory of secrets exists, with owner, location, readers and last rotation date.
  • Secret scanning and push protection are enabled on all repositories; CI output masks sensitive values.
  • CI authenticates to the cloud with OIDC; no long-lived cloud keys are stored in pipelines.
  • Default automation tokens are read-only, with permissions raised per job.
  • Services use workload identity or instance roles rather than stored cloud credentials.
  • Remaining secrets live in a secret manager or vault with per-secret access policies and environment separation.
  • Every production secret read is logged, and logs are reviewed.
  • Applications fetch secrets at runtime and tolerate two valid credentials during rotation.
  • Managed rotation is enabled where available; custom rotation is rehearsed in staging.
  • Any secret that has ever appeared in a log, chat or repository has been rotated.
  • A named owner reviews bindings and unused secrets quarterly.

Frequently asked questions

Do we need a dedicated vault, or is the cloud’s secret manager enough?

If your workloads run mostly on one cloud, that cloud’s secret manager with per-secret access policies and audit logging is usually enough. Dedicated vaults earn their place in multi-cloud, Kubernetes-heavy or on-premises environments, or where you need dynamic secrets and many authentication methods.

What is the single highest-value change?

Removing long-lived cloud credentials from CI and services by using OIDC federation and workload identity. It eliminates a class of secrets rather than storing them better.

How often should we rotate secrets?

Immediately on any suspected exposure, and otherwise on a schedule that matches the sensitivity of the secret and your compliance obligations. Automate database rotation with managed features where available, and make sure applications fetch secrets at runtime before scheduling anything.

A key was committed to a repository. Should we rewrite Git history?

Rotate the key first; that is what removes the risk. Rewriting history is slow, disruptive and does not help if the secret was already cloned or scanned. Enable push protection so it does not happen again.

How do we handle secrets in mobile apps?

Assume anything shipped in a client binary is public. Keep third-party keys on your backend, expose only the operations the app needs through your own API, and use the platforms’ attestation and app integrity features where they fit.

Sources and methodology

Guidance reflects PoliteTech delivery experience. The external references below informed specific points in this article.

  1. GitHub Docs: Security hardening for GitHub Actions — accessed 10 November 2026. Secrets readable by anyone with write access, redaction limits, OIDC instead of long-lived credentials, read-only default token permissions.
  2. GitHub Docs: About secret scanning — accessed 10 November 2026. Partner pattern detection and the advice to rotate exposed credentials rather than rewrite history.
  3. Google Cloud: Secret Manager best practices — accessed 10 November 2026. Least privilege and per-secret access, preferring platform identities over exported keys, version pinning, runtime access and audit logging.
  4. AWS Docs: Rotate AWS Secrets Manager secrets — accessed 10 November 2026. Managed rotation, managed external secrets rotation and Lambda-based rotation keeping the secret and target system in sync.
  5. NIST SP 800-207: Zero Trust Architecture (August 2020) — accessed 10 November 2026. No implicit trust based on network location or ownership; authentication and authorisation before each session.

Ready to get credentials out of .env files and CI variables?

We can inventory your secrets, replace stored cloud keys with identity, and set up a vault with rotation and least-privilege access that your team will keep using.