1. Resources
  2. Detection sources
  3. google.iam.admin.v1.CreateServiceAccountKey

google.iam.admin.v1.CreateServiceAccountKey: A user-managed key was created for a service account

Recorded when someone creates a long-lived key for a service account. Whoever holds the private key can act as the account from anywhere, until the key is disabled, deleted or expires.

Log source
Google Cloud Audit Logs
Detection value
High
Volume
Low (estimate)
Last updated
Log
Google Cloud Audit Logs (iam.googleapis.com, on by default)
Service
iam.googleapis.com
Operation
google.iam.admin.v1.CreateServiceAccountKey
Detects
6 attacks (1 rule · 7 detection logic)
MITRE ATT&CK
5 techniques in 3 tactics
Threat groups
4 groups that MITRE ATT&CK records using these techniques
Fields the rules read
protoPayload.serviceNameprotoPayload.methodName

When it is written

IAM writes this Admin Activity entry when CreateServiceAccountKey is called for the account in request.name; the IAM audit logging page lists it with the permission iam.serviceAccountKeys.create, which Service Account Key Admin (roles/iam.serviceAccountKeyAdmin) grants. Google notes that the basic roles can carry the permission too. Google creates the key pair, keeps the public key, and returns the private key once, in the response; it can't be downloaded again. The request can set the key's format (private_key_type, a credentials JSON file by default) and algorithm.

An account holds at most 10 keys. Keys don't expire unless the iam.serviceAccountKeyExpiryHours organization policy sets a lifetime for newly created keys. Where iam.disableServiceAccountKeyCreation is enforced, the call fails, and Google documents the error as FAILED_PRECONDITION. Google enforces that constraint by default in organizations created on or after 3 May 2024, and describes exempting single projects or folders from it with a tag. The managed constraint iam.managed.disableServiceAccountKeyCreation blocks key creation in the same way; Google gives no error text for it.

Google's example entry has resource.type service_account and shows the request, not the response; its AuditLog reference says sensitive response data can be left out, so the private key is not expected in the log. The API's response is the new key, whose name ends in the key ID; Google does not show whether the entry keeps it. Calls made later with the key in general name it in authenticationInfo.serviceAccountKeyName; Google notes that some services, App Engine and Compute Engine among them, do not log the key name.

How to turn it on

Google Cloud Audit Logs records google.iam.admin.v1.CreateServiceAccountKey calls to iam.googleapis.com without any setup. Vendor documentation

Admin Activity audit logs (changes to the configuration or metadata of a resource, such as allow policies, service accounts and keys) are written in every project, folder and organization without any setup. They can't be turned off or excluded, cost nothing, and are kept for 400 days in the _Required log bucket, a period you can't change. Data Access audit logs are off by default for every service except BigQuery: they cover reading configuration or metadata (ADMIN_READ) and reading or writing user data (DATA_READ, DATA_WRITE). Turn them on per service, or for all services, in the auditConfigs section of the IAM policy of the organization, folder or project; a project inherits what its folder and organization turn on and can't turn it off. A principal can be exempted per service and log type (exemptedMembers), and its calls then write no Data Access entry. They go to the _Default bucket, kept for 30 days by default, and can add charges.

  • Google Workspace and Cloud Identity audit logs (Admin, Login, Groups, OAuth token and SAML events) reach Cloud Logging only after a super administrator turns on sharing with Google Cloud: Admin console > Account > Account settings > Legal and compliance > Sharing options > Enabled. They are written at the organization level (organizations/<org-id>/logs/...), and which of them are shared depends on the edition. Admin audit events are Admin Activity entries.
  • To keep the records longer and send them to a SIEM, route them with a sink: an aggregated sink at the organization collects the entries of every folder and project under it, to Pub/Sub, Cloud Storage, BigQuery or a log bucket.
  • The Logs Viewer role (roles/logging.viewer) reads Admin Activity entries; Data Access entries in _Default need Private Logs Viewer (roles/logging.privateLogViewer).
  • The lookup command reads one project. Organization-level entries (Workspace and Cloud Identity, and changes made on an organization or folder) are read with --organization=<org-id> or --folder=<folder-id> in its place.
  • Google gives no delivery delay for Cloud Audit Logs; Workspace states that shared data arrives in near real time.
See which Data Access audit logs a project turns on (read only)
gcloud projects get-iam-policy <project-id> --format="yaml(auditConfigs)"
Based on vendor documentation.
See which Data Access audit logs the organization turns on (read only)
gcloud organizations get-iam-policy <org-id> --format="yaml(auditConfigs)"
Based on vendor documentation.
List the organization's sinks, which route audit logs to a SIEM (read only)
gcloud logging sinks list --organization=<org-id>
Based on vendor documentation.
List a project's log buckets and their retention (read only)
gcloud logging buckets list --project=<project-id>
Based on vendor documentation.
Find recent google.iam.admin.v1.CreateServiceAccountKey records (read only)
gcloud logging read 'protoPayload.methodName="google.iam.admin.v1.CreateServiceAccountKey"' --project=<project-id> --freshness=7d --limit=5
Based on vendor documentation.

Fields

The operation’s own fields first, then the fields every Google Cloud Audit Logs record has. Field names are the JSON paths of the record as the vendor documents it.

FieldWhat it holds
protoPayload.request.nameThe service account the key is for, projects/<project or ->/serviceAccounts/<email or unique ID> (shown in Google's example).
protoPayload.request.private_key_typeThe format of the private key returned (the API's privateKeyType, written here in the snake_case of Google's IAM admin entries; not shown in Google's example). Default TYPE_GOOGLE_CREDENTIALS_FILE.
resource.labels.email_idThe email address of the service account (resource.type is service_account).
resource.labels.unique_idThe numeric unique ID of that service account.
Fields every Google Cloud Audit Logs record has (22)
FieldWhat it holds
logNameThe log the entry belongs to: the project, folder or organization, then cloudaudit.googleapis.com%2Factivity (Admin Activity), %2Fdata_access, %2Fsystem_event or %2Fpolicy (Policy Denied).
resource.typeThe kind of monitored resource the entry is about (project, service_account, audited_resource...).
resource.labelsThe labels that identify that resource; which ones depends on resource.type (project_id, email_id...).
timestampWhen the operation took place.
receiveTimestampWhen Cloud Logging received the entry; later than timestamp.
severityThe severity of the entry (NOTICE for most audit entries, ERROR for many failed calls).
insertIdAn identifier Cloud Logging gives the entry, unique within the log.
protoPayload.serviceNameRead by 1 ruleThe API service the operation was performed by (iam.googleapis.com, admin.googleapis.com).
protoPayload.methodNameRead by 1 ruleThe method that was called, usually the API method name. The operation this page is about.
protoPayload.resourceNameThe resource the operation targets, as a path without the service name (projects/<id>/serviceAccounts/<email>).
protoPayload.authenticationInfo.principalEmailThe account that made the request: a user, a service account, or the service account acting for an external identity. Never redacted for a write or a call that succeeded; a read that failed with permission denied can hide it, unless the caller is a service account.
protoPayload.authenticationInfo.serviceAccountDelegationInfoFor a request made with service account credentials obtained by impersonation, the chain of principals that delegated to it, in the order the delegation happened.
protoPayload.authenticationInfo.serviceAccountKeyNameThe service account key used to create or exchange the credentials, when one was.
protoPayload.authorizationInfoOne entry per resource and IAM permission checked, with granted true or false.
protoPayload.requestMetadata.callerIpThe address the request came from. Google replaces some internal and VM callers with placeholder values (private, gce-internal-ip).
protoPayload.requestMetadata.callerSuppliedUserAgentThe client's user agent as the caller sent it; not authenticated.
protoPayload.status.codeThe result as a google.rpc.Code number: absent or 0 when the call succeeded, 7 (PERMISSION_DENIED), 5 (NOT_FOUND) and others when it failed.
protoPayload.status.messageThe error message of a failed call.
protoPayload.requestThe request, as the service's API reference documents it; large, sensitive or duplicated parameters can be left out.
protoPayload.responseThe response, with the same limits as request.
protoPayload.metadataOther data the service records about the operation. Google Workspace entries put the Admin console event here (event: eventName, eventType and its parameter list).
protoPayload.serviceDataThe older place for service-specific data, deprecated in favour of metadata but still written by some services.

Values to know

protoPayload.status.message

ValueMeaningSignal
Key creation is not allowed on this service accountThe `iam.disableServiceAccountKeyCreation` policy blocked the callThe guardrail worked; repeated attempts, or a policy change soon after, are worth a look. Google documents this text as the error the caller receives and shows no audit entry of a blocked call, so confirm the text on a record of your own.Failure

protoPayload.status.code

ValueMeaningSignal
7PERMISSION_DENIEDThe caller lacks iam.serviceAccountKeys.create on the account. Google's API reference says a request that names the project as - gets a 403 in place of a 404 for an account that does not exist, so a denied call can also be a wrong account name.Failure
9FAILED_PRECONDITIONThe status Google documents for a call that the iam.disableServiceAccountKeyCreation policy blocks.Failure

Volume and noise

Low where keys are discouraged: Google recommends Workload Identity Federation over keys for workloads outside Google Cloud. Legacy integrations that still use keys create them on setup and rotation. The detection rule reports every key created. A key created by a person, for an account that holds broad roles or domain-wide delegation, or for an account that has not been used for months is the entry to read first.

Keeping it manageable

  • Compare the caller with the account in resource.labels.email_id: a person creating a key for a privileged service account is the case to confirm first.
  • Follow the key: entries of later calls authenticated with it in general carry its name in protoPayload.authenticationInfo.serviceAccountKeyName (some services, App Engine and Compute Engine among them, do not log it); check where they come from (callerIp). Where the entry does not show the new key's ID, list the account's keys and match on the time the key became valid (validAfterTime).
  • Read failures too: status.message saying key creation is not allowed means an organization policy blocked the attempt.
  • Check the organization policy history: a key created soon after iam.disableServiceAccountKeyCreation was lifted, or after a project was tagged as exempt from it, can be the guardrail being removed for this purpose.

Sample event

A Google Cloud Audit Logs record in the vendor’s format, with made-up values.

{
  "protoPayload": {
    "@type": "type.googleapis.com/google.cloud.audit.AuditLog",
    "authenticationInfo": {
      "principalEmail": "admin@corp.example.com"
    },
    "requestMetadata": {
      "callerIp": "203.0.113.24",
      "requestAttributes": {},
      "destinationAttributes": {}
    },
    "serviceName": "iam.googleapis.com",
    "methodName": "google.iam.admin.v1.CreateServiceAccountKey",
    "resourceName": "projects/-/serviceAccounts/100000000000000000011",
    "request": {
      "@type": "type.googleapis.com/google.iam.admin.v1.CreateServiceAccountKeyRequest",
      "name": "projects/-/serviceAccounts/report-exporter@corp-prod-01.iam.gserviceaccount.com",
      "private_key_type": "TYPE_GOOGLE_CREDENTIALS_FILE"
    },
    "status": {}
  },
  "insertId": "1x2y3z4a5b6c",
  "resource": {
    "type": "service_account",
    "labels": {
      "email_id": "report-exporter@corp-prod-01.iam.gserviceaccount.com",
      "project_id": "corp-prod-01",
      "unique_id": "100000000000000000011"
    }
  },
  "timestamp": "2026-11-18T09:30:12.345678Z",
  "severity": "NOTICE",
  "logName": "projects/corp-prod-01/logs/cloudaudit.googleapis.com%2Factivity",
  "receiveTimestamp": "2026-11-18T09:30:13.012345678Z"
}

Attacks this event reveals

Detection rules that read this event:

Detection logic (hypotheses that join this event with others) for:

References