1. Resources
  2. Detection rules
  3. Disabled or Deleted Service Account or Key Restored in Google Cloud

Disabled or Deleted Service Account or Key Restored in Google Cloud detection rules

An attacker enables a disabled service account or key, or undeletes a deleted service account, and gets back an identity that was retired or shut off, together with every role it still holds.

Platform
Google Cloud
Severity
Medium
Log source
Google Cloud Audit Logs
Last updated
MITRE ATT&CK technique
T1098Account Manipulation
Rule formats
Sigmaand queries for: SplunkMicrosoft SentinelIBM QRadar
What an attacker needs
The right to enable or undelete a service account, or to enable a key, plus a disabled or recently deleted account that still holds roles.
Impact
The restored account returns with every role it still holds and without an allow policy change, and a re-enabled key works again from anywhere.
Response
Disable the restored account or key again, delete a key that was exposed or stolen, and contain the principal that restored it.
Mitigation
Remove the role bindings of retired service accounts and delete disabled keys after the waiting period, so that a restoration gives nothing back.
API methods
google.iam.admin.v1.EnableServiceAccountgoogle.iam.admin.v1.UndeleteServiceAccountgoogle.iam.admin.v1.EnableServiceAccountKey

How the attack works

Google's guidance is to disable a service account that is no longer used and to delete it only later, and to disable a key before deleting it. Disabling is also how a compromised account or key is contained. Both states are reversible. EnableServiceAccount turns a disabled account back on, EnableServiceAccountKey makes a disabled key authenticate again, and UndeleteServiceAccount restores an account for 30 days after its deletion. Google documents that a re-enabled account keeps all of its IAM bindings and that an undeleted account keeps its identity and its roles.

For an attacker this is a shortcut. Creating a new service account and granting it roles produces a new identity and an allow policy change, which is what defenders watch. Restoring a retired account produces neither. The identity is old, its role bindings were never removed, and its name is already known to the organization. A disabled key is the sharper case. If the attacker holds a copy of a key that was disabled, by its owner during containment or by Google after the key was found exposed, enabling it makes the stolen copy work again. Each call is an Admin Activity audit entry under iam.googleapis.com, which is always written.

What an attacker needs

  • iam.serviceAccounts.enable or iam.serviceAccounts.undelete on the account, which Service Account Admin contains, or iam.serviceAccountKeys.enable for a key, which Service Account Key Admin contains.
  • A disabled or recently deleted service account that still has role bindings, or a disabled key whose private part the attacker holds.
  • A way to use the restored account afterwards, such as a key, the right to impersonate it or the right to attach it to a resource.

Impact

The access of the restored service account. Its roles come back as they were, without any allow policy change, so an account that was retired with broad roles returns with them. A re-enabled key works from anywhere again, with the service account's roles. When the account or key had been disabled to contain an incident, the restoration undoes the containment.

Detection rules

Google Cloud Service Account Enabled or Undeleted

Detects EnableServiceAccount and UndeleteServiceAccount calls to the IAM API (Admin Activity audit log, always written). Google documents that a re-enabled service account keeps all of its IAM bindings and that an undeleted account keeps its identity and its roles, so the call returns the access of a retired or contained identity without any allow policy change. The account is named in protoPayload.resourceName and the caller in principalEmail. Google documents that enabling an account that is already enabled has no effect, and the rule cannot tell that case from a real restoration. Google lists the method names and the log type but publishes no example of these entries, so the rule matches on the method name alone.

LevelMediumStatusExperimentalLog sourceGoogle Cloud Audit Logs
title: Google Cloud Service Account Enabled or Undeleted
id: 8b0704cc-cf03-4c51-bf7d-7ddb886b1cc3
status: experimental
description: >-
  Detects EnableServiceAccount and UndeleteServiceAccount calls to the IAM
  API (Admin Activity audit log, always written). Google documents that a
  re-enabled service account keeps all of its IAM bindings and that an
  undeleted account keeps its identity and its roles, so the call returns the
  access of a retired or contained identity without any allow policy change.
  The account is named in protoPayload.resourceName and the caller in
  principalEmail. Google documents that enabling an account that is already
  enabled has no effect, and the rule cannot tell that case from a real
  restoration. Google lists the method names and the log type but publishes
  no example of these entries, so the rule matches on the method name alone.
references:
  - https://docs.cloud.google.com/iam/docs/audit-logging
  - https://docs.cloud.google.com/iam/docs/service-accounts-disable-enable
  - https://docs.cloud.google.com/iam/docs/service-accounts-delete-undelete
  - https://docs.cloud.google.com/iam/docs/best-practices-service-accounts
author: Forestall
date: 2026-11-18
tags:
  - attack.persistence
  - attack.privilege-escalation
  - attack.t1098
logsource:
  product: gcp
  service: gcp.audit
detection:
  selection:
    protoPayload.serviceName: iam.googleapis.com
    protoPayload.methodName:
      - google.iam.admin.v1.EnableServiceAccount
      - google.iam.admin.v1.UndeleteServiceAccount
  condition: selection
falsepositives:
  - An administrator undoing a mistaken disable or delete, and seasonal workloads whose service account is disabled between runs. Both are rare. Confirm each restoration with the owner of the account, and exclude automation that disables and enables accounts on a schedule by principalEmail in a filter_* selection.
level: medium

False positives

  • An administrator undoing a mistaken disable or delete, and seasonal workloads whose service account is disabled between runs. Both are rare. Confirm each restoration with the owner of the account, and exclude automation that disables and enables accounts on a schedule by principalEmail in a filter_* selection.

Disabled Google Cloud Service Account Key Enabled

Detects EnableServiceAccountKey calls to the IAM API (Admin Activity audit log, always written). The call makes a disabled service account key authenticate again. Keys are disabled before deletion, during the containment of a leak, and by Google itself when it finds a key exposed, so a key that is enabled again deserves a reason. Whoever holds a copy of the key can use it again from anywhere. Google states that the console cannot enable keys, so the call comes from the gcloud CLI or another API client. The key is named in protoPayload.resourceName and the caller in principalEmail. Google lists the method name and the log type but publishes no example of the entry, so the rule matches on the method name alone.

LevelMediumStatusExperimentalLog sourceGoogle Cloud Audit Logs
title: Disabled Google Cloud Service Account Key Enabled
id: 6d71ca27-8209-4ff0-8932-9d596d4530a4
status: experimental
description: >-
  Detects EnableServiceAccountKey calls to the IAM API (Admin Activity audit
  log, always written). The call makes a disabled service account key
  authenticate again. Keys are disabled before deletion, during the
  containment of a leak, and by Google itself when it finds a key exposed, so
  a key that is enabled again deserves a reason. Whoever holds a copy of the
  key can use it again from anywhere. Google states that the console cannot
  enable keys, so the call comes from the gcloud CLI or another API client.
  The key is named in protoPayload.resourceName and the caller in
  principalEmail. Google lists the method name and the log type but publishes
  no example of the entry, so the rule matches on the method name alone.
references:
  - https://docs.cloud.google.com/iam/docs/audit-logging
  - https://docs.cloud.google.com/iam/docs/keys-disable-enable
  - https://docs.cloud.google.com/resource-manager/docs/organization-policy/restricting-service-accounts
author: Forestall
date: 2026-11-18
tags:
  - attack.persistence
  - attack.privilege-escalation
  - attack.t1098
logsource:
  product: gcp
  service: gcp.audit
detection:
  selection:
    protoPayload.serviceName: iam.googleapis.com
    protoPayload.methodName: google.iam.admin.v1.EnableServiceAccountKey
  condition: selection
falsepositives:
  - A key that was disabled as a test before deletion and turned out to be still in use. The call is rare. Confirm each one with the owner of the application, and move the application off the key afterwards.
level: medium

False positives

  • A key that was disabled as a test before deletion and turned out to be still in use. The call is rare. Confirm each one with the owner of the application, and move the application off the key afterwards.

Detection logic

Patterns that need more than one event, a baseline or knowledge of your own environment. Each is a hypothesis to build and tune in your SIEM, not a ready rule.

Key disabled by Google's exposure response is enabled again

Detection hypothesisSequence of events

Google disables a service account key that it finds exposed, for example in a public repository, and logs that under its own system principal. Whoever enables that key again is either unaware that it leaked or is the party that holds the leaked copy. Both cases need a response.

  1. A google.iam.admin.v1.DisableServiceAccountKey entry from iam.googleapis.com whose protoPayload.authenticationInfo.principalEmail is gcp-compromised-key-response@system.gserviceaccount.com. Note the key in protoPayload.resourceName.
  2. Any later google.iam.admin.v1.EnableServiceAccountKey entry for the same key, by any caller.
  3. Alert on the pair, and check for entries authenticated with that key afterwards. Google documents the key in protoPayload.authenticationInfo.serviceAccountKeyName of entries that were authenticated with a service account key.

Eventsgoogle.iam.admin.v1.DisableServiceAccountKeygoogle.iam.admin.v1.EnableServiceAccountKey

LimitsGoogle does not guarantee that it detects exposed keys, so this covers only the keys it did disable. Google publishes no example of the disable and enable entries, so check how your entries name the key before joining on it. Some services, including Compute Engine, do not log the key name of the caller.

Service account enabled after a long time in the disabled state

Detection hypothesisSequence of eventsCompares with an earlier value

An account that is disabled for a short maintenance window and enabled again is routine. An account that was disabled weeks or months ago as unused, and is enabled by someone other than its owner, is a retired identity being brought back.

  1. A google.iam.admin.v1.EnableServiceAccount or google.iam.admin.v1.UndeleteServiceAccount entry. Note the account in protoPayload.resourceName and the caller in protoPayload.authenticationInfo.principalEmail.
  2. Find the latest google.iam.admin.v1.DisableServiceAccount or google.iam.admin.v1.DeleteServiceAccount entry for the same account and compare the two callers and the time between the entries.
  3. Alert when the account was disabled for more than 7 days, or when the caller that restores it differs from the caller that disabled it.

Eventsgoogle.iam.admin.v1.EnableServiceAccountgoogle.iam.admin.v1.UndeleteServiceAccountgoogle.iam.admin.v1.DisableServiceAccountgoogle.iam.admin.v1.DeleteServiceAccount

LimitsThe earlier entry may be older than the retention of the log store that is searched, in which case the comparison finds nothing. Seasonal workloads are disabled and enabled on purpose. The 7 days are a starting point.

Triage

  • Identify the caller (protoPayload.authenticationInfo.principalEmail) and the account or key in protoPayload.resourceName, and find out why it was disabled or deleted and by whom. Search for the earlier disable or delete entry for the same resource.
  • If the key or account was disabled during an incident, or the disable entry has the caller gcp-compromised-key-response@system.gserviceaccount.com, treat the enable call as hostile until the owner confirms it.
  • List the roles the account holds on its project, folder and organization. Restoring an account with no roles matters little. Restoring one with broad roles matters a lot.
  • Check how the account is used after the restoration. Look for audit entries with the account as caller, for new keys on it and for grants of Service Account Token Creator or Service Account User on it.
  • Check whether the caller normally manages service accounts, and what else it did around the same time.

Response

Once the attack is confirmed:

  1. Disable the restored account or key again. If the key was known to be exposed or stolen, delete it, because a deleted key cannot be enabled.
  2. Contain the caller. Remove its service account administration roles and reset its credentials.
  3. Review the audit entries with the restored account as caller since the restoration, and remove what it created, such as keys, role bindings, service accounts and workloads.
  4. Remove the role bindings of the account if it is not needed, so that a further restoration gives no access.
  5. Check the other disabled accounts and keys in the affected projects for enable calls nobody approved.

Mitigation

  • Remove the role bindings of a service account when it is retired, not only the account. A disabled or deleted account with no roles gives nothing back when it is restored.
  • Delete disabled keys once the waiting period is over. A deleted key cannot be enabled or undeleted.
  • Grant Service Account Admin and Service Account Key Admin on individual service accounts, and only to the team that manages them.
  • Keep the organization policy constraint iam.serviceAccountKeyExposureResponse at DISABLE_KEY, its default, and treat a key that Google disabled as compromised. Delete it and do not enable it again.
  • Record why each account or key was disabled, so that a later enable call can be checked against that reason.

Frequently asked questions

Why would an attacker restore an old service account instead of creating a new one?

A new account has to be given roles, and that allow policy change is a well-watched event. Google documents that a re-enabled service account keeps all of its IAM bindings and that an undeleted account keeps its identity and its roles. Restoring a retired account therefore returns its access with one call and no policy change. No public incident report describes this at the audit event level. The page follows from what Google documents about these calls.

How long can a deleted service account be undeleted?

Google documents 30 days. An account can usually be undeleted if it was deleted 30 days ago or less and no new account with the same name exists. After that IAM removes it permanently. Its role bindings are not removed at once either. Google states they are purged after a maximum of 60 days and appear with a `deleted:` prefix until then.

Does Google log it when it disables an exposed key itself?

Yes. Google documents that when it disables a key it found exposed, the audit logs contain the disable action by the principal `gcp-compromised-key-response@system.gserviceaccount.com`. Such a key should be treated as compromised and deleted. An enable call for it afterwards is one of the detection logic entries on this page.

Can a disabled key be enabled in the Google Cloud console?

No. Google states that the console cannot enable service account keys and that the gcloud CLI or the REST API has to be used. An `EnableServiceAccountKey` entry therefore comes from a command line tool, a script or another API client, which fits how rarely the call is needed.

References

We respect your privacy

We use cookies to keep this site secure and working properly. With your permission, we also use optional cookies to understand usage and improve the experience. Cookie Policy

You can change your choice at any time.