Cloudanix Achieves AWS Security Competency Status for Its CNAPP+ Platform and Just-in-Time Access Engine

What is Secret Rotation and Revocation? Why Deleting a Leaked Secret Is Not Enough

Rotation replaces a secret with a new one. Revocation kills the old one. Learn the difference, why deleting a leaked secret fails, and how to rotate without downtime.

A secret is any value that proves identity or grants access: a password, an API key, a cloud access key, a database credential, a token, or a certificate’s private key. Secret rotation is the practice of replacing a secret with a new one on a schedule or in response to an event. Secret revocation is the act of making an existing secret stop working immediately.

They sound similar, and they are often confused, but they answer different questions. Rotation asks “how do we make sure no secret stays valid forever?” Revocation asks “this secret is exposed, how do we make it useless right now?” A mature security practice needs both.

This guide is about what happens to a secret after it exists. It assumes you already know that secrets can leak. If you want the background on how and why they spread across code, chat, and pipelines, read what is secrets sprawl first. Here we focus on the lifecycle: how to replace secrets safely, how to kill leaked ones, and why the instinct to “just delete it” fails.

The core problem: a secret does not stop working when you stop looking at it

A secret is valid because the system that checks it says so. It is not valid because of where it is stored. This sounds obvious, but it explains almost every mistake teams make after a leak.

Imagine a developer commits an access key to a repository by accident, notices a few minutes later, and deletes the file in a new commit. The repository now looks clean. But:

  • The key is still in the history. Version control keeps every past commit. Anyone who can read the history can read the key.
  • Copies exist elsewhere. Forks, local clones, CI caches, pull request diffs, and archive services may all hold the old version.
  • Automated scanners are fast. Bots watch public repositories for new secrets and may collect one within minutes of publication.
  • The key still works. Nothing about deleting a file told the cloud provider to stop accepting the key.

So the secret is exposed, copied, and valid, and deleting it removed none of the risk. The only action that ends the risk is making the secret itself invalid. That is revocation. Deleting from the place it leaked is tidying, not remediation.

Key terms

  • Secret rotation. Replacing a secret with a new value, then retiring the old one. Can be scheduled (every 90 days) or event-driven (after a leak or when an employee leaves).
  • Secret revocation. Invalidating a secret so it can no longer be used. Takes effect at the system that validates it.
  • Expiration. A secret that is built to stop working on its own after a set time. This is rotation by design.
  • Regeneration. Generating a new value for the same secret slot. Often used as a synonym for rotation, but it may not retire the old value automatically.
  • Exposure window. The time between when a secret becomes exposed and when it stops working. Shrinking this window is the goal of everything in this guide.
  • Consumer. Any application, script, or person that uses a secret. You must know all of them before you can change the secret safely.

Why rotation matters even when nothing has leaked

Rotation is not only a reaction. It is a standing control, for several reasons.

  • It limits the value of a quiet leak. Many leaks are never noticed. A secret taken from a backup, a log, or a compromised laptop may be used months later. If it has been rotated since, the stolen copy no longer works.
  • It limits long-lived access. The longer a secret lives, the more places it has been copied to and the more people have seen it. Rotation resets that.
  • It handles people leaving. Anyone who knew a shared secret takes that knowledge with them. Rotating on departure closes it.
  • It is expected by auditors. Frameworks and customers ask for evidence that credentials are rotated and that access is revoked when no longer needed. See SOC 2 and PCI DSS.
  • It builds the muscle. A team that rotates a secret every quarter can rotate it in an hour during an incident. A team that has never rotated it discovers, mid-crisis, that nobody knows where it is used.

That last point is the most valuable. Practised rotation is what makes emergency revocation fast. Many organizations delay revoking a leaked secret because they fear breaking something. Routine rotation removes that fear.

Rotation versus revocation: when each applies

SituationWhat you doWhy
Secret has reached its scheduled ageRotateRoutine hygiene, no known exposure
Employee or contractor with knowledge of a secret leavesRotateRemove their access
Secret was committed to code, pasted in chat, or printed in a logRevoke first, then replaceThe exposure window is open now
A vendor that stored your secret was breachedRevoke first, then replaceYou cannot know who has it
Suspicious activity using a secretRevoke, then investigateStop the abuse before analysing it

In an active incident, the order is revoke, replace, then investigate. People often reverse this because they want to understand what happened first. Each hour spent investigating with the secret still valid is an hour the attacker can keep using it.

How rotation works without causing an outage

The fear of downtime is the main reason secrets never get rotated. There are well-established patterns that avoid it.

Pattern 1: Swap in place (simplest, has a gap)

You generate a new secret, update every consumer, and invalidate the old one. If a consumer is missed, or updates later than the swap, it fails during the gap. This is acceptable for secrets with one or two well-known consumers and a maintenance window. It is risky for anything widely shared.

Pattern 2: Overlap (two valid secrets at once)

Many systems allow two active secrets for the same identity. The process is:

  1. Create the new secret while the old one still works.
  2. Roll the new secret out to all consumers at your own pace.
  3. Confirm that nothing is using the old secret any more, using usage logs.
  4. Revoke the old secret.

There is no moment when a legitimate consumer has no valid secret. This is the safest pattern for access keys and API keys, and it is the one to prefer.

Pattern 3: Alternating users (for databases)

For database credentials, a secrets manager can maintain two database users and alternate between them. While one is in use, the other’s password is changed. Then consumers switch. AWS Secrets Manager describes this approach in its guide to rotating secrets. Azure Key Vault has a comparable rotation tutorial.

Pattern 4: Dynamic, short-lived credentials (best)

Instead of rotating a long-lived secret, issue a new one every time it is needed and let it expire in minutes or hours. The consumer asks for a credential, receives one that is valid briefly, and uses it. There is nothing long-lived to leak, and nothing to rotate on a schedule because rotation is built in. This is how cloud identities such as service principals with managed identities, and instance role credentials, work.

This pattern is the direction to move in. It converts rotation from a recurring chore into a property of the system.

A safe rotation procedure

Whether it is a scheduled rotation or an emergency, follow the same steps. The difference is speed.

  1. Find every consumer. Search code, configuration, pipelines, secret stores, documentation and chat. If you cannot find them all, use the provider’s usage logs to see who is still using the secret after you change it.
  2. Create the new secret. Give it the same or narrower permissions as the old one. A rotation is a good moment to reduce scope.
  3. Store it correctly. In a secrets manager, never in code or a config file.
  4. Deploy it to consumers. Roll it out and verify each consumer works.
  5. Revoke the old secret. Do not skip this. A new secret next to a still-valid old one is a second key to the same door.
  6. Verify. Check that the old secret is rejected and that nothing is failing.
  7. Record it. Note who rotated what and when, for audit.

Example: rotating and revoking an AWS access key

For an IAM user access key, the overlap pattern looks like this with the AWS CLI:

# 1. Create a second key while the first still works
aws iam create-access-key --user-name build-bot

# 2. Deploy the new key to every consumer, then check last-used time of the old key
aws iam get-access-key-last-used --access-key-id AKIAOLDKEYEXAMPLE

# 3. Make the old key inactive (reversible) to confirm nothing breaks
aws iam update-access-key --user-name build-bot \
  --access-key-id AKIAOLDKEYEXAMPLE --status Inactive

# 4. After a safe period, delete it permanently
aws iam delete-access-key --user-name build-bot \
  --access-key-id AKIAOLDKEYEXAMPLE

Setting a key to Inactive before deleting it is a useful safety step. If something breaks, you can set it back to Active in seconds. In a real emergency where the key is known to be exposed, skip straight to making it inactive, then work out the consumers.

What to do the moment a secret leaks

This is the incident runbook version. Keep it short enough to follow under stress.

  1. Revoke or deactivate the secret now. Do not wait to find out whether anyone used it.
  2. Issue a replacement and deploy it, using the overlap pattern if you can.
  3. Check usage back to the earliest possible date. Look at the provider’s logs from the time the secret was created, or at least from when it was first exposed. The question is whether it was used by anyone other than your systems.
  4. Look for persistence. Attackers who used a credential often create new credentials, roles, or users so access outlasts the revocation. Review recent identity and permission changes made by the compromised identity.
  5. Assess the scope. What could that secret reach? That is the blast radius, and it decides how far the investigation needs to go.
  6. Find the root cause. How did it leak? Fix that, or the next secret will leak the same way.
  7. Clean up copies. Remove it from code and history where practical, but remember this step is housekeeping. Step 1 was the fix.

See also what is incident response for how this fits a wider process.

Common mistakes

  • Deleting instead of revoking. Covered above. The most common and most costly.
  • Rotating only the secret that leaked. If the same secret is reused elsewhere, such as the same password across environments, all copies need rotating.
  • Forgetting the old one. Creating a new secret and leaving the old one active.
  • Rotating without knowing the consumers. This causes outages, which then teach the team never to rotate.
  • Rotating on a calendar and ignoring events. A 90-day schedule does not help if a secret leaked on day 2.
  • Storing the new secret in the same unsafe place. If the cause was a hardcoded key, a new hardcoded key has the same flaw.
  • Never testing it. A rotation process you have not practised will fail during an incident.

The best rotation is removing the secret

Rotation reduces the risk of a long-lived secret. Removing the secret removes the risk. Wherever possible, replace stored secrets with identities that issue short-lived credentials automatically:

  • Use managed identities and attached roles for workloads in the cloud.
  • Use federated authentication for CI/CD pipelines so they do not hold cloud keys.
  • Use just-in-time access for humans, so privileged access exists only for the minutes it is needed. See what is JIT access and what is zero standing privilege.

Each secret removed is one fewer to rotate, one fewer to leak, and one fewer to revoke in a crisis. This ties directly to defending against credential theft: a stolen credential that expires in an hour is a far smaller problem than one that works forever. It also applies to newer secret types such as AI provider keys, where fast revocation limits the cost of LLMjacking.

How Cloudanix helps

Cloudanix does not store or rotate your secrets, and it does not replace a secrets manager. It helps you find secrets that need attention, reduces how many long-lived secrets you depend on, and shortens how long a leak stays open.

  • Find exposed secrets. Code Security scans repositories and commit history using 2,000+ secret patterns (with support for your own), so you can see what needs revoking, including secrets buried in old commits.
  • Block new leaks. Scanning in pull requests and the Coding Agent Firewall stop secrets before they are committed or sent out of a developer’s machine by an AI coding agent.
  • Remove standing credentials. Cloud JIT, Agentic JIT and Coding Agent JIT issue scoped, time-limited access to people, pipelines and AI agents, so there is no long-lived key to rotate.
  • Know the blast radius. Attack path analysis and CIEM show what a leaked credential could reach, so you can prioritize revocation and scope the investigation.
  • Spot misuse during the window. Cloud UEBA and cloud detection and response flag an identity being used from somewhere or in a way it never has been.

What this does not do: revoking a secret happens at the system that issued it, such as your cloud provider or the AI vendor, and you or your automation must do that. Cloudanix finds what to act on and shows what is at stake.

Frequently asked questions

What is the difference between secret rotation and revocation?

Rotation replaces a secret with a new one, usually on a schedule or after an event. Revocation makes an existing secret stop working immediately. After a leak you revoke first, then replace. Routine rotation is the habit that makes fast revocation safe.

Is deleting a leaked secret from my repository enough?

No. The secret remains in version history, forks, caches and any copies already taken, and it still works until it is revoked at the system that issued it. Deleting it from the repository does not end the exposure.

How often should secrets be rotated?

It depends on the secret and your requirements. Many teams use 30 to 90 days for high-risk secrets and rotate any secret immediately after a suspected exposure or when someone with knowledge of it leaves. The more sensitive the secret, the shorter the life it should have. Where possible, use short-lived credentials so rotation is automatic.

How do I rotate a secret without downtime?

Use the overlap pattern: create the new secret while the old one still works, roll it out to all consumers, confirm the old one is no longer used, then revoke it. For databases, a secrets manager can alternate between two users.

What should I do first when a secret leaks?

Revoke or deactivate it immediately, before investigating. Then issue a replacement, review the logs back to the earliest possible date of exposure, and check for persistence such as newly created credentials or roles.

Can rotation stop an attacker who already got in?

Not always. If an attacker used the leaked secret to create their own credentials or roles, rotating the original does not remove those. After revoking and replacing, review what the compromised identity created or changed.

Why not just use a vault and forget about it?

A vault stores secrets securely and can automate rotation, which is a good practice. But a vault does not know about secrets that were never put in it, or copies already leaked, and it cannot revoke a secret at the provider unless integrated to do so. Vault plus scanning plus short-lived credentials is stronger than any one alone.

People Also Read

What Our Users Are Saying

Customer Reviews

Cloudanix is trusted by security leaders worldwide to deliver proactive, reliable, and cutting-edge cloud security.

One day, I changed the password of a root account, and my CTO called me within less than a minute to confirm if I did so. I was not expecting a reaction this quick. He told me Cloudanix alerted him of this password change and that he wanted to confirm as it was a critical security notification. I couldn't believe it!

Ritesh Agarwal
Ritesh Agarwal
CEO, Airgap Networks

Compliance is one way of staying secure, but what I want is the ability to go deeper and attain 'true security.' Cloudanix provides us the capability to do so.

Vishal Madan
Vishal Madan
Head of Engineering, iMocha

Cloudanix is building for the future of the cloud, which makes the product all the more desirable.

Ritesh Agarwal
Ritesh Agarwal
CEO, Airgap Networks

Cloudanix gave us the visibility we were missing. Being able to move from permanent access to a robust Just-In-Time (JIT) workflow has fundamentally changed our security posture without slowing down our engineering velocity.

Pavan Kumar Lekkala
Pavan Kumar Lekkala
SRE Lead, HugoHub

We are excited to leverage Cloudanix's comprehensive multi-cloud DevSecOps solution to secure our production workloads on AWS. Cloudanix has demonstrated that it can solve many challenges that DevSecOps teams face while continually adding new features such as SOC2 compliance and drift detection.

Satish Mohan
Satish Mohan
Co-founder & CTO, Airgap Networks

Managing third-party partner access was once a major concern for our security posture. With Cloudanix JIT Cloud, we've effectively achieved zero third-party risk. We can now grant access confidently, knowing that it is temporary, audited, and automatically revoked, resulting in a 100% reduction in our privileged access exposure.

Okesh Badhiye
Okesh Badhiye
Head of Technical Engineering, Finfinity

The snooze feature and responsible alerts have helped us save time and prioritize what to tackle first.

Satish Mohan
Satish Mohan
Co-founder & CTO, Airgap Networks

Implementing Cloudanix JIT internally allowed us to practice what we preach. By eliminating permanent access to our own clouds and databases, we've neutralized the risk of standing privileges, ensuring our own 'keys to the kingdom' are never left exposed.

Girish Manghnani
Girish Manghnani
Managing Partner, Tech Inspira

The problem with permissions is a lot of times, the gaps are left open due to oversights from inside the organization itself. With Cloudanix's CIEM, we get a complete view of user permissions and access. This enables us to update the permissions, reducing the attack surface.

Nilesh Pethani
Nilesh Pethani
Application Architect, iMocha

In the world of Fintech, trust is our currency. Cloudanix provided the frictionless visibility we needed to secure our EKS workloads across AWS, ensuring we stay audit-ready for SOC2 and GDPR without slowing down our engineering velocity.

Amol Naik
Amol Naik
Head of Security & Infrastructure, HugoHub

Cloudanix delivered value within 5 minutes of onboarding. Continuous monitoring, timely detection, and excellent documentation helped us attain a great cloud security posture.

Divyanshu Shukla
Senior DevSecOps, Meesho

Technology strategies and business strategies are in a state of constant change which includes centralization and decentralization of responsibilities. Regardless of strategic shift, we still have intellectual property to protect. Cloudanix are critical partners for us in our public cloud security posture across our three cloud providers.

Jerry Locke
Jerry Locke
Senior Director Global Solutions Engineering, Eversana

Cloudanix has been amazing. They opened up a common Slack channel with us — and it feels like we are talking to our own team and getting things done with Cloud security. The support team is always available, friendly, helpful, and ready to go out of their way.

Satish Mohan
Satish Mohan
CTO, Airgap Networks

Beyond just access management, Cloudanix CSPM has given us a unified view of our AWS environment. The real-time alerting and anomaly detection allow us to prevent any untoward activity before it happens, which is critical for a marketplace connecting 50+ financial institutions.

Okesh Badhiye
Okesh Badhiye
Head of Technical Engineering, Finfinity

For a Fintech company, data is our most valuable — and most sensitive — asset. Cloudanix DAM hasn't just improved our visibility; it has given us control. The ability to mask data and prevent unauthorized queries in real-time is a game-changer for our compliance and customer trust.

Jiten Gala
Jiten Gala
President Engineering and Product, Kapittx

Our clients, especially in the Middle East financial sector, demand absolute accountability. Cloudanix JIT Cloud has been a competitive differentiator for us, allowing us to provide secure, governed access to customer accounts that meet their strictest audit and compliance requirements.

Girish Manghnani
Girish Manghnani
Managing Partner, Tech Inspira

Cloudanix is always on my team's lips because of its exceptional support. Be it a small or big query, Cloudanix has gone above and beyond to resolve them. This one's a keeper for us.

Sujit Karpe
Sujit Karpe
CTO, iMocha

For a long-lasting partnership, great support goes a long way. Cloudanix has delivered exceptional support whenever required. Their edge is their team is always ready to go beyond to solve any issues that we have. This speaks volumes about the culture at Cloudanix.

Akash Maheshwari
Akash Maheshwari
Co-founder, MoveInSync

Beyond the technology, Cloudanix feels like an extension of our own team. Their willingness to stand up a dedicated Middle East tenant for us and provide exceptional support at a sensible price makes them a long-term partner for Hugosave.

Surya Tamada
Surya Tamada
CTO, HugoHub

The real-time notifications that Cloudanix provides are a real lifesaver. Their adaptive notifications ensure that my team stays productive and doesn't get interrupted all the time.

Digvijay Singh
Staff Security Engineer, Meesho

The whole point in technological evolution is to help improve the world we live in. We must protect that and to do so requires an effective and efficient security strategy. The Cloudanix team helped make our public cloud security posture management strategy a reality. The symbiotic relationship we have allows for a continuous feedback loop which is how business should operate.

Larry Wheat
Larry Wheat
Staff Solutions Engineer, Eversana

Ready to see your graph?

Connect a cloud account in under 30 minutes. See every finding rooted in identity, asset, and blast radius — with a fix path attached.

Book a Demo