Skip to main content

Event Information

  • Event meaning & impact
    • google.iam.admin.v1.UndeleteServiceAccount is 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 DeleteServiceAccount events, 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.

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).
  • Circumventing identity lifecycle and separation-of-duties controls
    • If identity lifecycle dictates that unused/breached service accounts be permanently removed, UndeleteServiceAccount can 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.

Remediation

Using Console

  • Prevent reactivation of compromised / retired service accounts
    • In GCP Console, permanently delete high‑risk service accounts so they cannot be undeleted:
      1. Go to IAM & Admin → Service Accounts → select the project.
      2. Locate the service account (if disabled, it still appears).
      3. Click the service account → Delete → confirm.
      4. 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:
      1. Remove all keys: Service accountKeys → delete all keys.
      2. Remove all roles: IAM & Admin → IAM → find the service account principal → click Edit principal → remove high‑privilege roles (Owner, Editor, custom org roles) → Save.
      3. Disable the account: Service account → three‑dot menu → Disable; use this only with strong monitoring and approval workflow.
  • Control UndeleteServiceAccount via IAM and approvals
    • Restrict who can undelete accounts:
      1. Go to IAM & Admin → Roles → open custom admin roles and ensure they do not include iam.serviceAccounts.undelete.
      2. In IAM & Admin → IAM, remove Owner/Editor from users/groups; instead, assign least‑privilege custom roles without undelete permission.
      3. 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).
    • Enforce separation of duties:
      1. One group manages service account lifecycle (create/delete); another group (security / compliance) alone has undelete (or vice versa).
      2. Use Cloud Identity Groups and grant roles to groups only, not individuals, so SoD is enforced centrally.
  • Monitor, alert, and validate against compliance (GCP Console + Cloud Logging)
    • Enable audit logs for IAM in all projects and org:
      1. Go to IAM & Admin → Audit Logs → select IAM Service.
      2. Turn on Admin Read and Admin Write for All principals for each project and at the Organization level.
    • Create alerts for UndeleteServiceAccount and high‑risk changes:
      1. Go to Logging → Logs Explorer.
      2. Use a filter, e.g.:
      3. 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:
      1. In IAM & Admin → IAM, run quarterly reviews to identify and remove legacy high‑privilege roles and org‑level custom roles from service accounts.
      2. 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.

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 delete as 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:
  • Constrain who can undelete / restore high-privilege service accounts
    • Remove roles/iam.serviceAccountAdmin, roles/owner, and custom roles containing iam.serviceAccounts.undelete from 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:
  • 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 gcloud with restricted service accounts:
      Ensure the pipeline’s service account has iam.serviceAccounts.undelete but no direct console access.
    • Enable and monitor Cloud Audit Logs for UndeleteServiceAccount, SetIamPolicy, and CreateServiceAccountKey, 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:

Using Python

  • Enforce strong IAM guardrails on iam.serviceAccounts.undelete
    • Create an org‑level custom role without iam.serviceAccounts.undelete and 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:
  • Automate detection & response for UndeleteServiceAccount to enforce approvals
    • Enable Admin Activity Logs in Cloud Logging and create a log‑based alert on google.iam.admin.v1.UndeleteServiceAccount to 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):
  • 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):