Join our Newsletter — 33% off our NHI Course
Home› Guides› How to detect service account key creation in…
Guide SOC & Detection Engineering

How to detect service account key creation in Google Cloud: audit log alerts and policy exceptions

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 28 November 2026 12 min read
On this page

A new Google Cloud service account key is a long-lived credential that anyone holding the file can use until it expires or is deleted, and creating one is a quiet way to keep access to a project. This runbook shows how to detect key creation and key upload in Cloud Audit Logs across an organisation, how to route those events centrally, how to write the alert so that approved exception projects do not drown it, and how to triage a hit. It also covers the second half of the signal that is specific to Google Cloud: changes to the organisation policy constraints that block keys, because an attacker or a hurried engineer who cannot create a key will often lift the policy first. It is for detection engineers and cloud security teams. For the AWS equivalent, see How to detect AWS access key creation for another user.

This is an independent guide from NHI Mgmt Group, based on Google Cloud's public IAM documentation as of November 2026. It is not sponsored or reviewed by Google. Product features change, so confirm settings against Google Cloud's current documentation.

Key takeaways

  • Key creation is always logged. Google documents google.iam.admin.v1.CreateServiceAccountKey and google.iam.admin.v1.UploadServiceAccountKey as Admin Activity audit logs (permission type ADMIN_WRITE), which are written by default, so there is no logging switch to turn on.
  • The caller and the target are separate fields. protoPayload.authenticationInfo.principalEmail is who made the request; protoPayload.request.name names the service account that received the key. A human creating a key for a production service account is the case to page on.
  • Watch the policy as well as the key. In an organisation that enforces iam.managed.disableServiceAccountKeyCreation, a successful key creation means an exception exists. Alert on Organization Policy CreatePolicy, UpdatePolicy and DeletePolicy calls that touch the key constraints.
  • Exceptions belong in a list your alert can read. Approved exception projects (or tagged service accounts) should be a maintained list that lowers severity, not a filter that hides events.
  • Central routing needs testing. Route Admin Activity logs with an aggregated sink to a central project, then prove with a test key that the alert in that project fires on routed entries.

When you need this

Creating credentials for an existing cloud identity is what MITRE ATT&CK records as T1098.001 Additional Cloud Credentials: an intruder with iam.serviceAccountKeys.create on a service account can mint a key, leave, and come back as that service account later. Build this detection when:

How this differs from the AWS case

AspectAWS IAMGoogle Cloud IAM
EventCloudTrail CreateAccessKeyCloud Audit Logs google.iam.admin.v1.CreateServiceAccountKey and UploadServiceAccountKey
Who gets the keyAn IAM user (optional UserName parameter)A service account, named in protoPayload.request.name; resource.type is service_account
Caller fielduserIdentityprotoPayload.authenticationInfo.principalEmail
Preventive guardrailService control policiesOrganisation policy constraints iam.managed.disableServiceAccountKeyCreation and iam.managed.disableServiceAccountKeyUpload
Main exception riskAn SCP carve-outA project-level override of the constraint, or a tag condition that excludes some service accounts

Before you start

These are the events the detection uses. All come from the IAM and Organization Policy audit logging pages Google publishes.

SignalService and methodLog typeSeverity guide
Key creatediam.googleapis.com google.iam.admin.v1.CreateServiceAccountKeyAdmin ActivityHigh outside exception list; medium inside it
Public key uploadediam.googleapis.com google.iam.admin.v1.UploadServiceAccountKeyAdmin ActivityHigh: uploads are rare and the private half never touched Google
Key disabled or deletedDisableServiceAccountKey, DeleteServiceAccountKeyAdmin ActivityInformational; use for time-to-revoke and clean-up evidence
Key policy changedorgpolicy.googleapis.com google.cloud.orgpolicy.v2.OrgPolicy.CreatePolicy, UpdatePolicy, DeletePolicyAdmin ActivityHigh when the policy name contains a key constraint
Managed finding (optional)Event Threat Detection: Persistence: Service Account Key Created; Initial Access: Dormant Service Account Key CreatedSecurity Command Center PremiumGoogle sets Low and High default severity respectively
  • Permissions: to create an aggregated sink you need logging configuration rights at the organisation or folder; Google states that granting the sink writer identity access on a destination in another project needs Owner on that project.
  • A central project: a security logging project with a log bucket (or a SIEM fed from Pub/Sub or BigQuery).
  • An exception register: the projects and service accounts that are allowed keys, with owner, reason and expiry. The Google Cloud Service Account Keys Security Guide covers when a key is justified.

Step-by-step

  1. Route Admin Activity logs centrally. Create a non-intercepting aggregated sink on the organisation with includeChildren set to true, filtered to protoPayload.serviceName="iam.googleapis.com" OR protoPayload.serviceName="orgpolicy.googleapis.com" (or to all Admin Activity logs if you want them anyway), with a log bucket in the security project as destination. Grant the sink writer identity Logs Bucket Writer (roles/logging.bucketWriter) on that bucket. See the Google Cloud Audit Logs and Log Sinks Guide.
  2. Write the key creation query. In Logs Explorer, start from Google's documented filter and add the upload method (label: sample, adjust to your estate):

    1 Sample only, based on the public documentation cited. Assess it independently against the current official documentation, test outside production and back up first.

    Sample 1
    protoPayload.serviceName="iam.googleapis.com"
    (protoPayload.methodName="google.iam.admin.v1.CreateServiceAccountKey"
     OR protoPayload.methodName="google.iam.admin.v1.UploadServiceAccountKey")
    Confirm against a test key which fields carry the result in your logs; Google's published example shows principalEmail, request.name, resourceName (the numeric service account ID) and resource.type="service_account".
  3. Write the policy change query. Alert on Organization Policy writes that name a key constraint:
    Sample 1
    protoPayload.serviceName="orgpolicy.googleapis.com"
    protoPayload.methodName=~"OrgPolicy\.(CreatePolicy|UpdatePolicy|DeletePolicy)$"
    protoPayload.resourceName=~"ServiceAccountKey"
    Organisation policy resource names include the constraint name (check one test event to confirm the format in your logs), so matching ServiceAccountKey covers the creation, upload, expiry and exposure response constraints. Google notes the v1 API logs under cloudresourcemanager.googleapis.com, so add that service if any tooling still uses v1.
  4. Create log-based alerting policies. From Logs Explorer choose Create log alert for each query. Google documents a single condition per policy, a notification frequency (five minutes is one console option) and an autoclose that defaults to seven days. Labels cannot be extracted in the console; use the Monitoring API labelExtractors if you want the caller and service account in the notification title.
  5. Test central alerting. Google's log-based alert documentation says policies scan entries that a project-level sink routes into a bucket in that project. Create a test key in a sandbox project, delete it, and confirm the central alert fired. If it did not, define the alert in each project through infrastructure as code, or alert from your SIEM instead.
  6. Apply the exception list. Join hits to the exception register by project ID and service account. Inside the list, raise a medium-severity ticket that checks the key was expected and has an expiry; outside it, page. Never put the exception list into the log filter itself, because then the register silently becomes a blind spot.
  7. Enrich with context. For each hit, add the roles held by the target service account (Cloud Asset Inventory or IAM policy analysis), whether the caller is a human or a service account, and whether principalEmail shows impersonation through delegation. See GCP Audit Log Principal Fields.
  8. Turn on managed findings where licensed. With Security Command Center Premium, Event Threat Detection raises Persistence: Service Account Key Created and Initial Access: Dormant Service Account Key Created (a key created for a user-managed service account inactive for more than 180 days). Treat these as a second source, not a replacement for your own rule. See the Security Command Center Guide.

Org policy exceptions done safely

Google's organisation policy documentation gives two ways to carve out an exception: override the parent policy at a project, or add a condition based on tags so that tagged service accounts are excluded. Both are policy changes that your step 3 alert will see.

Exception methodFitsDetection consequence
Project override of iam.managed.disableServiceAccountKeyCreationA small number of whole projects that need keys (for example a vendor integration project)Every service account in that project can now get keys; keep the project on the exception list with an expiry date
Tag condition on the policyLarger estates where only named service accounts need keysNarrower blast radius, but anyone who can bind the tag can widen it; also monitor tag bindings on service accounts
Expiry with iam.serviceAccountKeyExpiryHoursAny exception projectAllowed values run from 1h to 2160h; a key that outlives the setting suggests it was created before the policy, because Google states these constraints are not retroactive

Small vs large organisations: a small organisation can treat every key creation as a page and review each by hand. A large one needs the exception register, enrichment by role, and a weekly report of medium-severity hits so that owners confirm their keys are still needed.

Verify it worked

  1. Positive test: in a sandbox project outside the exception list, with the constraint not enforced, create a key for a test service account. The high-severity alert should fire with caller and target. Delete the key.
  2. Exception test: repeat in an exception project and confirm the lower severity route.
  3. Policy test: in dry-run or a sandbox folder, update the key creation policy and confirm the policy change alert.
  4. Negative test: list keys and confirm no alert (listing is a read, recorded as Data Access, not Admin Activity).

Triage a real hit by asking: is the caller a person or a pipeline? Is the target on the exception list? What can the target service account do? Has the new key been used (key authentication metrics and Data Access logs)? If the key is unexplained, disable it first (reversible), confirm nothing legitimate broke, then delete it, and follow the Google Cloud Project Compromise Playbook. If Google has flagged the key as exposed, use How to respond to a Google Cloud exposed service account key alert.

Rollback and common errors

Alerting changes no access; rollback means muting or editing a policy, never deleting the sink.

  • Central alert never fires: the aggregated sink is not including children, the writer identity lacks bucket permission, or the alert does not scan entries routed by an aggregated sink. Test as in step 5.
  • Policy alert misses changes: tooling uses the v1 API, logged under cloudresourcemanager.googleapis.com.
  • No caller details in the notification: labels were not extracted; use labelExtractors through the API.

Hardening afterwards

  • Enforce the managed constraints at the root: iam.managed.disableServiceAccountKeyCreation and iam.managed.disableServiceAccountKeyUpload, with exceptions only from the register. See the Google Cloud Organization Policy Guide.
  • Keep exposure response on: confirm iam.serviceAccountKeyExposureResponse is DISABLE_KEY, which Google states is the default behaviour from 16 June 2024 when no value is set; WAIT_FOR_ABUSE should raise an alert of its own.
  • Restrict who can create keys: review who holds iam.serviceAccountKeys.create on each service account. See How to Audit GCP Service Account Impersonation Rights.
  • Replace keys with federation: attached service accounts and Workload Identity Federation remove the need for files. See the Workload Identity Federation Cheat Sheet.

Metrics

  • Keys created outside the exception list: per month (target zero).
  • Key policy changes without a change record: per quarter (target zero).
  • Exception projects with an expiry date: percentage (target 100%).
  • Time to disable an unexplained key: median from alert to disable.
  • Detection test pass rate: quarterly synthetic key creations detected end to end.

Framework mapping

FrameworkReferenceHow this guide supports it
MITRE ATT&CK v20T1098.001 Additional Cloud Credentials; T1078.004 Cloud AccountsDetects credential creation for persistence and later use of the service account
NIST SP 800-53 Rev 5IA-5 Authenticator Management; AC-2(4) Automated Audit Actions; AU-6 Audit Record Review, Analysis, and Reporting; CM-3 Configuration Change ControlMonitoring credential issuance and changes to preventive policy
NIST CSF 2.0DE.CM-03; DE.CM-09; DE.AE-02Monitoring activity and technology, analysing adverse events
CIS Controls v8.1Control 5 Account Management; Control 8 Audit Log ManagementGoverning service account credentials and reviewing audit logs. See the CIS Control 5 Account Management Guide.

Common failure patterns

  • Filtering out the exception projects: the register becomes the one place nobody looks, which is where an attacker with project rights would create keys.
  • Watching keys but not the policy: a project override followed by a key creation shows as a medium-severity hit unless the policy change itself alerted.
  • Only per-project alerts: new projects arrive without the alert; central routing or infrastructure as code for every project fixes it.
  • Ignoring uploads: UploadServiceAccountKey registers a public key whose private half was made elsewhere, so it never shows in a key download audit.
  • Assuming the policy removed old keys: Google states the constraints are not retroactive; inventory existing keys separately.

Practitioner checklist

  • An aggregated organisation sink routes IAM and Organization Policy Admin Activity logs to a central bucket.
  • Log alerts cover CreateServiceAccountKey and UploadServiceAccountKey.
  • A separate alert covers Organization Policy writes on the key constraints, for v2 and v1 APIs.
  • The exception register lowers severity, never hides events.
  • Notifications carry caller, target service account and project.
  • Central alerting has been proved with a test key.
  • Exception projects set iam.serviceAccountKeyExpiryHours.
  • Exposure response is DISABLE_KEY across the organisation.

Standards and references

Related NHI Mgmt Group resources: Google Cloud Service Account Keys Security Guide · How to inventory Google Cloud service account keys and replace them with federation · Google Cloud Audit Logs and Log Sinks Guide · How to detect AWS access key creation for another user

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.