ILLUSTRATIVE USE CASE — NOT A CUSTOMER CASE STUDY
Walkthrough: Cleaning Up CI Token Sprawl and Unowned Service Accounts
An illustrative walkthrough of how a SaaS company could replace long-lived CI cloud keys with OIDC federation, assign owners to service accounts and govern AI agents.
- Scenario
- A 150-person SaaS company has years of long-lived cloud access keys stored as CI secrets, dozens of service accounts nobody can name an owner for, and a growing number of internal AI agents with API tokens. A customer security questionnaire asks how machine credentials are governed, and nobody can answer with confidence.
- Industry
- Mid-size SaaS company on AWS and GCP
- Problem
- We have long-lived cloud keys in CI and service accounts with no known owner, and we cannot say what any of them can access.
- Related product
- TrustIvan
This walkthrough describes a realistic, composite situation to explain an approach. It is not an account of a real customer, and it reports no achieved results.
On this page
This is an illustrative use case. The company, its systems and its circumstances are invented to show how a team like this could approach the problem. It does not describe a real customer, and it reports no achieved results.
Background
The company in this scenario sells a B2B SaaS product built over eight years. It runs production on AWS, analytics on GCP, source code on GitHub, and identity for employees through a single sign-on provider. Around forty engineers ship through GitHub Actions, with a few legacy pipelines still on a self-hosted CI server.
Over those years, every new integration added a machine credential: an AWS access key for deployments, a GCP service account key for the data pipeline, a GitHub personal access token for a release bot, API tokens for monitoring and ticketing. Recently, product and support teams started building internal AI agents that call internal APIs and third-party tools, each with its own token.
Business challenge
An enterprise prospect's security questionnaire asks three direct questions: how are machine credentials inventoried, who owns them, and how often are they rotated? The honest answer is "partially, often unknown, and rarely".
That answer slows the deal, but the deeper problem is exposure. Long-lived keys copied into CI secrets, developer laptops and old wiki pages are exactly what attackers look for. The OWASP Non-Human Identities Top 10 lists issues such as secret leakage, long-lived secrets, overprivileged identities and improper offboarding, and this company has some of each.
Existing situation
A quick review by the security lead finds:
- Long-lived cloud keys in CI. Several AWS access keys and GCP service account JSON keys are stored as repository and organisation secrets. Some are years old. At least one has administrator-level permissions because "the deploy kept failing".
- Unowned service accounts. The cloud consoles show dozens of IAM users, roles and service accounts. Many were created by engineers who have since left. Nobody knows which are still used.
- Tokens in git history. A few repositories contain credentials committed and later "removed" in a follow-up commit, which leaves them in history.
- AI agents with broad tokens. Internal agents use API keys scoped to whatever the builder had at hand, and there is no list of which agents exist or which tools they can call.
- No rotation process. Rotation happens only after a suspected leak.
Why a change was needed
Three risks made this a priority rather than a backlog item. First, any leaked long-lived key stays valid until someone notices, which may be never. Second, without owners, nobody can safely revoke an unused credential, so the attack surface only grows. Third, AI agents add identities faster than human processes can review them, and each agent with a broad token can act well beyond its purpose.
The cheapest credential to protect is the one that does not exist. The goal is to remove long-lived secrets where federation can replace them, give every remaining identity an accountable owner, and make agent permissions explicit.
Approach and implementation
The approach below is vendor-neutral. It relies on native cloud and CI features plus an inventory, whether that inventory lives in a spreadsheet, a script or a dedicated platform.
A short implementation plan for a team like this:
- Inventory every non-human identity. Pull IAM users, roles, access keys and their last-used dates from each cloud, service accounts and keys from GCP, GitHub Apps, deploy keys and tokens, and secrets-manager entries. Add AI agents and the tools or MCP servers they use.
- Scan for exposed secrets. Run secret detection across full git history, not only the current tree, and on new commits going forward. Treat any found credential as compromised: rotate first, clean history second.
- Assign an owner to each identity. Map each identity to a team using creation records, repository ownership and last-used activity. Identities nobody claims after a fixed notice period are disabled, then deleted.
- Replace CI keys with OIDC federation. Configure GitHub Actions to request an OIDC token (the workflow needs
id-token: write). In AWS, register GitHub's OIDC provider and create a role whose trust policy restricts the token'ssubclaim to a specific repository and branch or environment. In GCP, use Workload Identity Federation with an attribute condition on the repository. Then delete the stored keys. - Right-size permissions. Use last-accessed data to shrink each remaining role to what it actually uses.
- Rotate what remains. For credentials that cannot be federated, such as some third-party API tokens, set a rotation schedule, store them in a secrets manager, and record the owner and expiry.
- Register AI agents and their entitlements. For each agent, record the owner, purpose, and which tools it may call. Where the agent's runtime supports it, put a policy check in front of sensitive actions.
- Review access periodically. Owners confirm quarterly that each identity is still needed and correctly scoped.
Solution architecture
The target state separates identities that should never hold a secret from those that still must:
GitHub Actions workflow (id-token: write)
│ short-lived OIDC token (sub = repo:org/app:environment:prod)
▼
Cloud trust policy ── AWS IAM role / GCP workload identity pool
│ checks issuer, audience, sub claim
▼
Short-lived cloud credentials (minutes) ── no stored keys in CI
Remaining secrets (third-party API tokens)
└─▶ Secrets manager ── owner, expiry, rotation schedule
Non-human identity inventory
├─ Sources: cloud IAM, SSO directory, GitHub Apps, secrets manager
├─ Owner + last-used + effective access per identity
├─ Secret scanning: git history + new commits
└─ AI agent registry: owner, allowed tools, MCP servers
└─▶ Policy check where the agent runtime asks before acting
The inventory is the control plane for everything else. It answers which identities exist, who owns each one, what each can actually reach, and which are stale. Federation removes the most dangerous category of secret outright. The agent registry makes agent permissions something a reviewer can read, rather than something buried in a token.
Teams can build the inventory from cloud APIs and scripts, but keeping it current across clouds, code and agents is ongoing work. A platform can carry that load:
TrustIvan provides a non-human identity inventory covering keys, tokens and AI agents, with owners, access reviews and effective access, fed by connectors from cloud IAM and Okta through to GitHub Apps and Vault. It detects secrets across git history and staged lines, and keeps an agent registry with tool entitlements plus an MCP server and tool inventory; its runtime gate can allow, challenge or deny agent actions where the agent's runtime asks. It does not replace the federation work itself: the trust policies and workflow changes above are configured in your cloud and CI.
What to measure
This walkthrough is hypothetical, so it reports no outcomes. These are the measures a team like this would track, and how to gather them.
- Long-lived cloud keys in CI. Count stored cloud access keys and service account keys across repository and organisation secrets. The target trend is towards zero for anything that can federate. Recount from the CI provider's secrets API each month.
- Identities with a named owner. The proportion of non-human identities in the inventory with an accountable owning team. Track it weekly during the ownership drive.
- Stale identities. Identities with no use in a set period (for example 90 days), from cloud last-used data. Track how many are disabled and deleted.
- Credential age. For secrets that remain, the age distribution and how many are past their rotation date.
- Open secret-scanning findings by age, and the time from detection to rotation for each finding.
- AI agents with documented entitlements. The share of known agents with an owner and an explicit tool list, and the number of agents discovered outside the registry.
- Access review completion. The share of owners who completed each periodic review on time.
Record the starting values before any cleanup so progress is measured against a real baseline.
Lessons learned
These lessons reflect common patterns in non-human identity cleanups, not a specific engagement.
- Ownership is the hard part. Technical fixes are quick once someone owns the identity. Budget most of the effort for finding owners and agreeing on a disable-then-delete policy.
- Disable before deleting. Disabling an unclaimed key for a few weeks surfaces hidden dependencies without permanent breakage.
- Scope OIDC trust tightly. A trust policy that accepts any repository in the organisation recreates the problem. Pin the
subclaim to repository and environment. - Removing a secret from the latest commit is not removal. If it ever reached git history, rotate it.
- Treat agents as identities from day one. Registering agents as they are built is far easier than auditing them later.
For the wider context, read the non-human identity security guide and securing AI agents in the enterprise. The identity security assessment checklist helps structure the inventory step.
Sources and references
Related resources
Keep reading
AI Agents Are Identities, Not Features
Why enterprises should govern AI agents as non-human identities with named owners, scoped entitlements and runtime checks, rather than shipping them as product features.
· 6 min read
How to Secure AI Agents in Enterprise Environments
A practical control set for AI agents: per-agent identities, scoped tool entitlements, audience-bound tokens for MCP servers, action gates and logs you can attribute.
· 6 min read
Non-Human Identity Security: Research Brief
Desk research on non-human identity security: secrets sprawl, credential abuse in breaches, workload federation, AI agents, MCP and what security leaders should do next.
· 10 min read
What Is Non-Human Identity Security? A Practical Guide
What non-human identities are, why service accounts, tokens and AI agents need their own security program, and a six-step plan to inventory, scope and rotate them.
· 9 min read
Stay Ahead of What Matters.
Practical guides on cybersecurity & identity and more, delivered to your inbox.