Event Information
-
Event meaning & impact
google.iam.admin.v1.UndeleteServiceAccountis emitted when a previously deleted Service Account is restored within its 30-day soft-delete window.- The Service Account’s identity (email/unique ID) becomes active again, and it can regain access to resources via existing or reattached IAM bindings, keys, and workload identities.
-
Security & compliance considerations
- Undeleting can silently re-enable access paths that were intentionally removed, impacting least-privilege, SoD, and deprovisioning controls (e.g., ISO 27001 A.9, SOC 2 CC6.x, CIS GCP 1.x, PCI-DSS 7.x).
- Treat this as a privileged action requiring justification and change records; ensure the actor (user/service) performing undelete has appropriate roles (e.g.,
roles/iam.serviceAccountAdmin) and is operating under an approved change.
-
Operational response & guardrails
- Correlate this event with prior
DeleteServiceAccountevents, IAM policy changes, and key usage to verify the restore is intentional and risk-acceptable. - Automate alerts on this event, trigger a review workflow (re-validate IAM roles, keys, and bindings), and, if the account was decommissioned for security reasons, immediately re-delete or restrict it via organization policy and IAM.
- Correlate this event with prior
Examples
-
Re-activating a previously compromised service account
- An attacker (or malicious insider) could undelete a service account that was disabled/deleted following a security incident and regain access tokens/keys or rebind new keys.
- Violates least-privilege and incident-response expectations in ISO 27001, SOC 2, and NIST 800-53 (IR, AC families) if no approval / change management is enforced.
-
Restoring legacy high-privilege roles and bypassing access reviews
- A service account with broad roles (e.g.,
roles/owner,roles/editor, or org-level custom roles) might be undeleted after being removed during an access review, effectively rolling back a risk remediation. - Undermines access governance and periodic recertification controls required in SOX, PCI DSS, and NIST (AC-2, AC-6).
- A service account with broad roles (e.g.,
-
Circumventing identity lifecycle and separation-of-duties controls
- If identity lifecycle dictates that unused/breached service accounts be permanently removed,
UndeleteServiceAccountcan be used to bypass that process without ticketing or approval, especially if logging/alerts are weak. - Non-compliant with change-management and SoD controls (e.g., ISO 27001 A.9 & A.12, PCI DSS 7 & 10) if the same role both deletes and undeletes accounts without independent oversight.
- If identity lifecycle dictates that unused/breached service accounts be permanently removed,
Remediation
Using Console
-
Prevent reactivation of compromised / retired service accounts
- In GCP Console, permanently delete high‑risk service accounts so they cannot be undeleted:
- Go to IAM & Admin → Service Accounts → select the project.
- Locate the service account (if disabled, it still appears).
- Click the service account → Delete → confirm.
- After 30 days soft‑delete window, it is permanently removed and cannot be undeleted (aligns with ISO 27001, SOC 2, NIST IR/AC).
- For accounts that must remain:
- Remove all keys: Service account → Keys → delete all keys.
- Remove all roles: IAM & Admin → IAM → find the service account principal → click Edit principal → remove high‑privilege roles (
Owner,Editor, custom org roles) → Save. - Disable the account: Service account → three‑dot menu → Disable; use this only with strong monitoring and approval workflow.
- In GCP Console, permanently delete high‑risk service accounts so they cannot be undeleted:
-
Control
UndeleteServiceAccountvia IAM and approvals- Restrict who can undelete accounts:
- Go to IAM & Admin → Roles → open custom admin roles and ensure they do not include
iam.serviceAccounts.undelete. - In IAM & Admin → IAM, remove
Owner/Editorfrom users/groups; instead, assign least‑privilege custom roles without undelete permission. - Reserve undelete capability for a tightly controlled group (e.g., Security Admins) with a documented change‑management / ticketing process (supports NIST AC‑2/AC‑6, PCI DSS 7).
- Go to IAM & Admin → Roles → open custom admin roles and ensure they do not include
- Enforce separation of duties:
- One group manages service account lifecycle (create/delete); another group (security / compliance) alone has
undelete(or vice versa). - Use Cloud Identity Groups and grant roles to groups only, not individuals, so SoD is enforced centrally.
- One group manages service account lifecycle (create/delete); another group (security / compliance) alone has
- Restrict who can undelete accounts:
-
Monitor, alert, and validate against compliance (GCP Console + Cloud Logging)
- Enable audit logs for IAM in all projects and org:
- Go to IAM & Admin → Audit Logs → select IAM Service.
- Turn on Admin Read and Admin Write for All principals for each project and at the Organization level.
- Create alerts for
UndeleteServiceAccountand high‑risk changes:- Go to Logging → Logs Explorer.
- Use a filter, e.g.:
- Click Create alert → configure Notification channel (email / Pub/Sub → SIEM) and require incident tickets for each alert (supports ISO 27001 A.9/A.12, PCI DSS 10).
- Periodically review:
- In IAM & Admin → IAM, run quarterly reviews to identify and remove legacy high‑privilege roles and org‑level custom roles from service accounts.
- Export IAM policies and audit logs to BigQuery / SIEM and reconcile with access reviews to ensure that deleted accounts or roles have not been reintroduced without approval.
- Enable audit logs for IAM in all projects and org:
Using CLI
-
Prevent undelete by design (preferred)
- Replace deletion with a “tombstone” pattern: remove all bindings, keys, and workload identity bindings, but do not rely on
deleteas the security measure:- Strip roles from the service account:
- Disable the service account (blocks token use and avoids the need for undelete):
- Delete all keys (user‑managed) to meet key‑revocation / incident-response requirements:
- Strip roles from the service account:
- Replace deletion with a “tombstone” pattern: remove all bindings, keys, and workload identity bindings, but do not rely on
-
Constrain who can undelete / restore high-privilege service accounts
- Remove
roles/iam.serviceAccountAdmin,roles/owner, and custom roles containingiam.serviceAccounts.undeletefrom operational / dev teams; assign only to a tightly controlled break-glass or security-admin group: - Create a custom role that explicitly excludes undelete for normal admins:
Then bind this role instead of
roles/iam.serviceAccountAdmin:
- Remove
-
Enforce approval, monitoring, and lifecycle compliance
- Require that “restore” operations happen only via a controlled CI/CD or ITSM pipeline (change ticket ID required) that calls
gcloudwith restricted service accounts:Ensure the pipeline’s service account hasiam.serviceAccounts.undeletebut no direct console access. - Enable and monitor Cloud Audit Logs for
UndeleteServiceAccount,SetIamPolicy, andCreateServiceAccountKey, and pipe to SCC / SIEM with real-time alerts to satisfy ISO 27001 / PCI DSS logging requirements: - Codify “no legacy high-privilege roles” as policy using Org Policy + Policy Controller (if using GKE/Anthos) to block restoring
roles/owner,roles/editor, or disallowed custom roles, and periodically reconcile via script:
- Require that “restore” operations happen only via a controlled CI/CD or ITSM pipeline (change ticket ID required) that calls
Using Python
-
Enforce strong IAM guardrails on
iam.serviceAccounts.undelete- Create an org‑level custom role without
iam.serviceAccounts.undeleteand migrate all human/admin identities to it; only a tightly controlled break-glass group should retain this permission. - Attach an org policy to restrict who can manage service accounts and keys, e.g.:
- Example Python snippet to enumerate who has
iam.serviceAccounts.undelete(via Cloud Asset Inventory) for review/cleanup:
- Create an org‑level custom role without
-
Automate detection & response for
UndeleteServiceAccountto enforce approvals- Enable Admin Activity Logs in Cloud Logging and create a log‑based alert on
google.iam.admin.v1.UndeleteServiceAccountto meet ISO/SOC2/NIST monitoring expectations. - Use a Cloud Function / Cloud Run (Python) triggered from Logging to auto-revoke any undeleted SA (remove keys, high-priv roles) unless a change ticket/approval exists.
- Example Python handler for a log-based trigger (pseudo-response workflow):
- Enable Admin Activity Logs in Cloud Logging and create a log‑based alert on
-
Codify lifecycle, SoD, and “no‑undelete” rules for compromised / legacy SAs
- Maintain a CMDB / security registry (e.g., in Firestore or a Git repo) of service accounts marked as
COMPROMISED/DECOMMISSIONED; your remediation function should auto-disable and alert if any such SA is undeleted, enforcing IR and change‑management controls. - Ensure SoD by having: one role allowed to delete SAs, another (security/change manager) allowed to approve/temporarily undelete; enforce via separate groups and documented workflows (ISO 27001 A.9/A.12, PCI DSS 7 & 10).
- Example Python snippet to enforce “never re‑enable compromised SAs” using a local deny‑list (replace with Firestore / DB in production):
- Maintain a CMDB / security registry (e.g., in Firestore or a Git repo) of service accounts marked as

