Ensure service account keys are rotated within 90 days
Description
Service account keys must be rotated regularly to limit the window of exposure from compromised credentials.
⚠️ Risk Impact
Old service account keys are a prime target for attackers. Unrotated keys provide persistent access even after a breach is detected.
🔍 How EchelonGraph Detects This
EchelonGraph's Tier 1 Cloud Scanner automatically checks for this condition across all connected Google Cloud accounts. Violations are flagged as high-severity findings with remediation guidance.
🖥️ Manual Verification
gcloud iam service-accounts keys list --iam-account=SA_EMAIL --format='table(name,validAfterTime,validBeforeTime)'🔧 Remediation
Delete keys older than 90 days and generate new ones. Use Workload Identity Federation to eliminate keys entirely.
💀 Real-World Attack Scenario
A CI/CD pipeline stored a GCP service account key in a Jenkins environment variable. The key was created 14 months ago and never rotated. When Jenkins was compromised through a known CVE, the attacker extracted the key and used it to access production BigQuery datasets for 3 weeks before the anomalous queries triggered an alert.
💰 Cost of Non-Compliance
CircleCI breach (2023): all customer secrets potentially exposed due to unrotated service account keys. Average time to detect compromised credentials: 292 days (IBM 2024). Each additional day of dwell time costs approximately $15K in breach damages.
📋 Audit Questions
- 1.List all service account keys and their creation dates.
- 2.What is your key rotation policy and how is it enforced?
- 3.Are there any service account keys older than 90 days? Justify each.
- 4.Have you evaluated Workload Identity Federation to eliminate keys?
🎯 MITRE ATT&CK Mapping
🏗️ Infrastructure as Code Fix
# Eliminate keys entirely with Workload Identity Federation:
resource "google_iam_workload_identity_pool" "github" {
workload_identity_pool_id = "github-pool"
display_name = "GitHub Actions Pool"
}
resource "google_iam_workload_identity_pool_provider" "github" {
workload_identity_pool_id = google_iam_workload_identity_pool.github.workload_identity_pool_id
workload_identity_pool_provider_id = "github-provider"
attribute_mapping = {
"google.subject" = "assertion.sub"
}
oidc { issuer_uri = "https://token.actions.githubusercontent.com" }
}⚡ Common Pitfalls
- ⛔Rotating the key but not updating all services that reference it, causing outages
- ⛔Storing rotated keys in version control, creating a history of valid credentials
- ⛔Having a rotation policy on paper but no automated enforcement mechanism
📈 Business Value
Automated key rotation or elimination reduces your attack surface by removing the most common cloud breach vector. Organizations using Workload Identity Federation eliminate 100% of key-related incidents.
⏱️ Effort Estimate
1-2 hours per service account for rotation; 2-5 days to migrate to Workload Identity
EchelonGraph flags keys >90 days old across all service accounts in <60 seconds
🔗 Cross-Framework References
Automate CIS GCP 1.3 compliance
EchelonGraph continuously monitors this control across all your cloud accounts.
Start Free →