Skip to content

Independent marketplace for verified cloud accounts

Secrets Management: Keys, Tokens and Rotation

Machine credentials leak differently from human passwords. This guide covers where secrets accumulate, how to store them, replacing keys with workload identity, and rotating without an outage.

A secret is any value that grants access and cannot be published: an API key, a database password, a signing certificate, a service token, a webhook signature. The defining property is that software reads it rather than a person typing it, which changes almost everything about how it should be handled.

Human credentials get a second factor and a login prompt. Machine credentials get read from a file by a process at three in the morning with nobody watching. There is no factor to present, no prompt to intercept, and no user to notice something unusual. That is why a leaked machine credential is often the quietest serious problem an infrastructure team can have.

Why machine credentials are a separate discipline

Three differences drive everything else.

They are copied, not remembered. A password lives in a person’s head or a vault. A service key gets copied into a configuration file, a container image, a CI variable, a developer laptop and a backup, and every copy is an independent chance of exposure.

They rarely expire on their own. Most static keys work until revoked, so the clock never forces a review. A key issued for a weekend migration two years ago is probably still valid.

Their use looks normal. An attacker using a stolen service key makes exactly the calls that key was issued to make. Nothing in the pattern stands out unless you are watching volume and source, which is a different detection problem from a human login and is covered in detecting and responding to unexpected cloud activity.

Where secrets end up without anyone deciding

Secrets do not usually leak through a dramatic breach. They accumulate in ordinary places.

  • Version control. The most common route, and the worst, because history preserves the value even after a later commit removes it. Rewriting history does not help once a repository has been cloned.
  • Container images. A value baked in at build time is present in a layer that anyone who can pull the image can read.
  • CI system variables. Reasonable storage, but often readable by any job in the project, including one added by a pull request from outside.
  • Chat and ticket systems. Pasted during an incident, searchable forever afterwards.
  • Logs. A debug line that prints a request header, a stack trace that includes a connection string.
  • Infrastructure state files. State written by provisioning tools frequently contains generated passwords in clear text.
  • Developer laptops. Credential files in home directories, synchronised to a backup service nobody audited.

Scan for these rather than trusting policy. Repository scanning for credential patterns at commit time catches the largest category before it lands, and a periodic scan of existing history finds the backlog.

Choosing where secrets live

Options form a rough ladder, and most teams should be somewhere above the bottom rung.

Environment variables set at deploy time are better than files in a repository but are visible in process listings and often captured in crash reports. Encrypted files committed alongside code work for small teams, keep the secret out of plain view, and have the significant drawback that revocation means a deploy. A managed secret service from your provider gives you access control, an audit record of every retrieval, versioning and often automatic rotation. A dedicated secrets platform adds dynamic credentials and cross-provider reach at the cost of running one more piece of infrastructure.

What matters more than which rung you pick is that retrieval is auditable and revocation is immediate. If you cannot answer “which systems read this secret in the last week” and “how fast can I make this value worthless”, the mechanism is not adequate regardless of how it encrypts.

Give workloads an identity instead of a key

The strongest move available is to stop distributing static credentials at all. Most providers let a compute resource carry an identity, so code running on it requests short-lived credentials from a local endpoint rather than reading a key from disk.

The benefits compound. There is no value to leak, because nothing durable is stored. Credentials expire within hours on their own. Permissions attach to the workload rather than to a copied string, so revoking access is a policy change rather than a hunt for every copy. The identity model that makes this work is described in IAM fundamentals covering users, roles and least privilege.

The same thinking extends to federation. Rather than storing a long-lived provider key in your CI system, many platforms accept a signed token from the CI provider and exchange it for temporary credentials. Set this up once and an entire category of leaked deployment keys disappears. Where it fits, apply it before investing in better storage for keys you could eliminate.

Rotation as routine rather than emergency

Rotation is only painful for teams that do it rarely. The pain is not the rotation; it is that nobody knows what will break, and nobody knows because it has been three years.

Build for rotation from the start by supporting two valid credentials at once. The sequence is then dull in a good way: create the new credential, distribute it, confirm every consumer is using it, then revoke the old one. Nothing is ever without a working credential, so a rotation causes no downtime and needs no maintenance window.

Rotate on a schedule matched to blast radius. A credential with broad write access to production deserves a tighter cycle than a read-only key for a public dataset. Rotate immediately, outside the schedule, whenever someone with access leaves, whenever a laptop is lost, and whenever a secret appears anywhere it should not.

Keep a register. Every secret should have a recorded owner, a purpose, a list of consumers and a last-rotated date. Without the register, rotation stalls at the first question nobody can answer, which is usually “what else uses this”.

Scoping, so a leak costs less

Assume every secret will eventually be exposed and design for the consequence to be small.

Issue one credential per consumer rather than sharing one across five services. Shared credentials cannot be rotated without coordinating five teams, and they destroy attribution in the audit log. Scope each credential to the narrowest set of actions and resources it needs. Where the provider supports it, restrict a key to a source network range so that a copy used from elsewhere simply fails. Set an expiry at issuance if the platform allows one, since an expiring credential is self-cleaning.

Separate credentials by environment without exception. A key that works in both staging and production turns a low-trust environment into a path to a high-trust one, which is the structural argument made in separate cloud accounts per environment.

Responding to an exposed secret

Speed beats thoroughness in the first few minutes. Work in this order.

  1. Revoke or rotate the value. Do this before investigating. A key that no longer works cannot be used while you read logs.
  2. Check the audit record for use of that credential, paying attention to source addresses and actions outside its normal pattern.
  3. Look for persistence. An attacker who used a key often creates a second way in, so review new identities, new keys and new access policies created since the exposure.
  4. Work out the exposure window, from when the value was first exposed to when it was revoked, and scope the investigation to it.
  5. Fix the path that leaked it, and record the incident so the same path is closed for everyone.

Do not skip step three. Rotating the leaked key while leaving a newly created administrative identity in place is a very common and very expensive mistake.

Secrets in an account that changed hands

An account you did not create may carry credentials you cannot see the consumers of. Treat every pre-existing secret as compromised, because you have no way to establish otherwise.

List every access key, token and service credential on the account. Record which you can account for, then disable the rest rather than deleting them, so a surprise is reversible. Watch for failures over the following days, since a disabled key that breaks something tells you what that key was for. Rotate everything you decide to keep, including values that look like infrastructure defaults.

Do the same for anything stored in the provider’s own secret service by a previous holder, and for application-level credentials inside running instances. The broader sequence is laid out in the post-handover security checklist, and what you own when you buy a cloud account explains why the credential inventory is the part that most often gets overlooked.

What the provider gives you, and what you build

Platform support varies. Larger providers ship a managed secret store with versioning, fine-grained access policies, an audit trail on every read, and integration with their compute identity system so that rotation can be automated end to end. Leaner providers may offer object storage and nothing else, which means running your own secret store or using a third-party service.

Neither is wrong, but the second option means the operational burden lands on you, and that burden should be counted in the cost comparison rather than discovered later. The AWS vs Vultr comparison frames that difference in managed service depth. A Buy AWS Account listing gives you the full managed tooling, while a Buy UpCloud Account suits teams that prefer to run a lean stack and manage secrets with their own tools.

Related comparisons

Google Cloud vs Linode
vs

Google Cloud vs Linode

Linode under Akamai sits closer to the edge than it used to. Google Cloud answers the same global delivery problem…

Azure vs Vultr
vs

Azure vs Vultr

Vultr sells raw capacity in many locations with almost no ceremony. Azure sells governance, policy and scale. Here is how…

Scaleway vs OVH
vs

Scaleway vs OVH

Two French providers with genuinely different product philosophies. Scaleway builds a modern developer platform; OVHcloud operates infrastructure at scale across…

Azure vs IBM Cloud
vs

Azure vs IBM Cloud

Azure sells a platform, IBM Cloud sells a platform plus an engagement. This comparison looks at workload lineage, governance, support…

Keep reading

IAM Fundamentals: Users, Roles and Least Privilege
IAM Fundamentals: Users, Roles and Least Privilege
Security and IAM 7 min read

IAM Fundamentals: Users, Roles and Least Privilege

Identity and access management decides who can do what in your cloud account. This guide covers users versus roles, how permission decisions…

Root Email, MFA and API Keys: Securing an Inherited Account
Security and IAM 7 min read

Root Email, MFA and API Keys: Securing an Inherited Account

Credential hygiene for an account someone else created. Covers the root mailbox, replacing authentication factors, closing recovery paths and rotating keys without…

Need the account, not just the theory?

Browse documented configurations across every provider in the catalog, or ask us which one fits your workload.

Telegram