Insights / Keys and machine identities
Vendor offboarding: retire the cloud keys you handed out
Konstantins Feofantovs, Founder, rebuildstack ·
A key you gave a vendor for one project has no owner, no expiry and no baseline. How to find those keys in AWS and Google Cloud and retire them.
Key points
- Retire vendor keys when the project ends: Barracuda's intruder came in through a cloud key given to an AI vendor and never revoked.
- AWS access keys never expire and Google Cloud key expiry is not retroactive, so every old vendor key needs an owner and an end date.
- Replace keys with roles the vendor assumes, then alert on the first use of a quiet key from a new place in GuardDuty or Security Command Center.
Why is a vendor's old cloud key a problem?
Because it is access that nobody is watching, held in a place you cannot see.
Barracuda's own account of its November intrusion is the clearest recent example. As part of an earlier project, the company gave a cloud access key to a third party vendor, a company working in AI. When the project ended, the key was not retired. Barracuda's CISO wrote it plainly: "That is on us." [1]
In October the vendor's development environment was compromised. The key was stored in a configuration file in the vendor's GitHub repository, and that is where the attacker appears to have found it. The same file held other credentials too, but those had already expired or have since been revoked. [2] The ones that had expired were useless to the attacker. The one with no end date was the way in.
From there the timeline is short. The attacker made its first call with the key at 04:33 UTC on 1 November and was mapping what the key could reach within minutes. It read stored secrets, including AWS access keys and Azure service principal secrets, and used each one to reach the next system: cloud accounts, a data analytics system, a source code access token, Kubernetes clusters. It touched about ten cloud accounts in roughly 44 hours, tried to create a new administrative cloud identity (the attempt was blocked), and its last recorded activity was at 23:31 UTC on 2 November. [1]
Barracuda found out on 4 November, when an engineer noticed unusual activity on their own account. The same day the vendor got in touch about its own incident. By then the activity had already stopped. [1] Barracuda has linked the tooling to ARTEX, an open source AI driven penetration testing framework, and says that because many groups use it, the match shows how the attacker operated, not who it was. [1] Its 24 November update says the incident was limited to the internal environment behind Managed XDR, that affected customers were notified and asked to revoke and recreate their Managed XDR integration credentials and review activity since 1 November, and that it found no evidence that other Barracuda products or services, or the infrastructure behind them, were affected. [2]
Barracuda has not named the vendor, which cloud the key belonged to, or exactly what the key was allowed to do. Those details are not public, and nothing in this guide depends on them. The mechanism is what matters, and it is common: a key handed to a vendor for a project tends to have no owner on your side once the project ends, no expiry, and no baseline that says what normal use of it looks like. Each of those three gaps is fixable, and each one alone would have changed this story.
Why AI vendors in particular? They are a new kind of vendor that asks for broad read access to do its job (your data, your logs, your code), and their development environments now hold keys from many customers at once. Railway's investigation of its October incident suggests the attackers' primary target was AI provider keys, with unauthorized spend on the stolen keys estimated to reach about $740,000. [3] A vendor's repository full of customer keys is worth more to an attacker than any single customer.
Do AWS access keys expire?
No. An IAM user access key in AWS stays valid until someone deactivates or deletes it. There is no expiry field to set. Google Cloud is slightly better: a user managed service account key can be given an expiry, but only through an organization policy, and that policy is not retroactive. It applies to keys created after it takes effect and does nothing for the key you handed out last year. [7] Organizations created on or after 3 May 2024 enforce iam.disableServiceAccountKeyCreation by default, so a vendor key in one of those means someone made an exception, and that exception is what to look for. [7]
So the defaults on both clouds produce exactly the situation Barracuda described. Three more defaults make it worse:
- The vendor project ends in a contract, not in IAM. Offboarding checklists usually cover laptops, accounts in your SaaS tools and the shared drive. A key created in a console and pasted into a ticket is not on any list.
- Last used data is not an alarm. Both clouds record when a key was last used, but nobody looks at it until there is a reason to.
- Anomaly detection learns the attacker. Detectors that model normal behavior per identity can take a stolen key's first burst of calls as the new normal if the key had no history to compare against. A key that was quiet for months and then reads every secret in the account should be the loudest event of the week. Often it is not.
AWS's own guidance is that a third party should not get a long term access key at all. It should assume a role in your account that you scope, with an external ID in the trust policy, and receive temporary credentials each time. [4] On Google Cloud the equivalent is to grant roles to the vendor's own identity (their service account, or an external identity through Workload Identity Federation) instead of exporting a key from one of your service accounts. Barracuda's own conclusion points the same way: short lived, narrowly scoped credentials "would have stopped this intrusion at its first step." [1]
How do you offboard a vendor from AWS and Google Cloud?
Do it in this order. The first two steps take an afternoon and close most of the risk.
1. Find every long lived key and every outside principal
AWS. The IAM credential report lists every user's access keys with when each was last rotated and last used. It covers one account, so run it in every account in your organization:
aws iam generate-credential-report
aws iam get-credential-report --query Content --output text | base64 --decode > credentials.csv
Any active key with an old access_key_1_last_used_date or access_key_2_last_used_date, or N/A, is a candidate. For access that goes to other accounts rather than through keys, an IAM Access Analyzer external access analyzer reports every resource policy, including role trust policies, that lets a principal outside your account or organization in. It is free. The unused access analyzer goes further and flags roles and access keys with no activity in a window you choose, but it is charged per role and user analyzed. [5]
Google Cloud. Cloud Asset Inventory lists every service account key across the organization in one call:
gcloud asset search-all-resources \
--scope=organizations/ORG_ID \
--asset-types=iam.googleapis.com/ServiceAccountKey
Keys of type USER_MANAGED are the ones someone created and exported; a far off or missing expiry means the key never stops working. To see when each key last authenticated, use Activity Analyzer, a Pre-GA feature that needs the Policy Analyzer API (policyanalyzer.googleapis.com) and the roles/policyanalyzer.activityAnalysisViewer role:
gcloud policy-intelligence query-activity \
--activity-type=serviceAccountKeyLastAuthentication \
--project=PROJECT_ID
The result carries an observation period, and authentications outside it are not included, so a missing entry is not proof that a key was never used. It also leaves out disabled keys, so once you deactivate a key it drops out of these results. [8] For outside principals, search your organization's IAM policies (Cloud Asset Inventory does this across projects) for members whose domain is not yours: vendor service accounts, external user accounts and federated identities.
2. Give every key an owner and a date
For each key and each outside principal, write down three things: the person inside your company who owns it, the vendor and project it exists for, and the date it should stop working. Put that on the resource itself, not in a spreadsheet: tags on the IAM user in AWS, the description and labels on the service account in Google Cloud.
Anything nobody claims within a week gets deactivated, not deleted. Deactivation can be reversed if something breaks. Deletion cannot, and you want the key around until you are sure what used it.
3. Replace keys with access that ends by itself
AWS. Move each vendor to a cross account role with an external ID that the vendor generates, scoped to what the work needs. The vendor gets temporary credentials on every call, and you can cut access by editing one trust policy. [4] Where a key truly cannot be avoided, the AWS Config managed rule access-keys-rotated marks keys older than maxAccessKeyAge (90 days by default) as NON_COMPLIANT. [10] It does not expire or deactivate anything; a person or an automated remediation still has to act on the finding.
Google Cloud. Grant roles to the vendor's own identity, or set up Workload Identity Federation for their workloads, so no key of yours exists in their systems at all. On organizations created since May 2024, domain restricted sharing (iam.allowedPolicyMemberDomains) is enforced by default, so you will need to allow the vendor's Workspace or Cloud Identity customer ID explicitly; scope that exception to the projects the work needs. [11] Then enforce iam.disableServiceAccountKeyCreation to stop new keys being exported, and set iam.serviceAccountKeyExpiryHours so that any exception still expires. It takes fixed values only (1h, 8h, 24h, 168h, 336h, 720h, 1440h or 2160h), cannot be merged with a parent policy, and an expiry can cause an outage if a key is still in use, so pick the shortest value that works. [7]
The same rule holds for the identity your own pipeline uses: a deploy job that holds a stored key is a vendor you forgot to offboard. Your CI is a cloud identity covers that side.
4. Make the end of a project an IAM event
Add one line to the vendor offboarding checklist: list every key, role binding and trust policy created for this vendor, and remove them on the last day. If you cannot produce that list on the last day, step 2 was not finished.
How to check it worked
Run the inventory from step 1 again a week later. The check is simple: every remaining long lived key and every outside principal has a named owner and an end date, and the count is going down. If a key you deactivated is still being tried, the audit logs may show failed calls from it; find out who is calling before you delete it.
Then decide what the first use of a vendor key from a new place should look like, and make sure something fires on it:
- AWS. GuardDuty's IAM findings cover this class of event.
InitialAccess:IAMUser/AnomalousBehavior,Discovery:IAMUser/AnomalousBehaviorandCredentialAccess:IAMUser/AnomalousBehaviorare raised when a user identity makes calls that are unusual for it, with factors such as the location of the request; the credential access one covers calls likeGetSecretValue.CredentialAccess:IAMUser/CompromisedCredentialsfires when a key that has leaked is used. [6] GuardDuty is not on by default, and the anomaly model needs history, which is one more reason a quiet vendor key deserves attention before anything happens. - Google Cloud. Event Threat Detection in Security Command Center, which needs the Premium or Enterprise tier, raises
Initial Access: Dormant Service Account Actionwhen a user managed service account that has been inactive for more than 180 days suddenly acts. [9] That is the shape of a forgotten vendor key, but 180 days is long. Shorten the window yourself with a log based alert on Cloud Audit Logs for calls authenticated by the keys you listed in step 1. Secret reads (AccessSecretVersionin Secret Manager) are Data Access audit logs, which are off by default, so enable Data Access audit logs for Secret Manager and for any other service the key could read first.
A stolen key that starts reading stored secrets is the loudest thing it can do, and the most useful to catch. Reading stored secrets from a key that has no business reading them is the kind of break from an agreed baseline that Access watch is built to flag.
Barracuda's lesson on this point is uncomfortable. Its most useful outside signal arrived three days after the attack began, after the activity had already stopped, from a vendor that did not think Barracuda was affected. [1] Detection that relies on someone else noticing will usually be late. That is why the steps above come first: a key that no longer exists cannot be used at all.
What goes wrong when you retire vendor keys?
- Something in production was quietly using the key. Vendor keys get reused for a cron job or a dashboard after the project ends. Deactivate first, watch the failed calls for a week, then delete.
- The key lives in more places than you think. You gave the key to the vendor once. The vendor may have copied it into a repository, a CI variable and a laptop. Secrets copied into services you do not control are their own risk, as the Azure API Management flaw showed. You cannot clean their systems, which is why rotating or removing it on your side is the only fix that counts.
- Rotation without removal. Rotating a key for a vendor that no longer works with you just hands them a fresh one. Ask whether the access should exist before asking how old it is.
- The policy fixes the future only.
iam.serviceAccountKeyExpiryHoursand new rotation rules do nothing for keys that already exist. [7] The old keys still need the inventory from step 1. - The secrets behind the key are left alone. Barracuda's attacker went from one key to the stored secrets it could read, then to the next system. [1] If a vendor key had read access to a secret store, the secrets in it need rotating too, not only the key.
- Detection turned on, never read. A GuardDuty or Security Command Center finding that lands in a channel nobody owns is the same as no finding. Give the alerts an owner the same way you gave the keys one.
Where this sits in our work
The audit reads service accounts and deploy credentials first, including every key held outside your company, and the fix replaces static keys with short lived credentials.
01 AuditKonstantins Feofantovs
Founder of rebuildstack. We audit cloud access and fix what we find, in your infrastructure and in your code.
Sources
- Forty-four hours: Anatomy of a machine-speed intrusion, Barracuda Networks,
- Barracuda XDR integration credentials, Barracuda Trust Center,
- Incident report: October security incident, Railway,
- Access to AWS accounts owned by third parties, AWS,
- IAM Access Analyzer findings, AWS,
- GuardDuty IAM finding types, AWS,
- Restrict IAM service account usage, Google Cloud,
- View recent usage for service accounts and keys, Google Cloud,
- Initial Access: Dormant Service Account Action, Google Cloud,
- access-keys-rotated, AWS Config,
- Restricting identities by domain, Google Cloud,