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.CreateServiceAccountKeyandgoogle.iam.admin.v1.UploadServiceAccountKeyas 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.principalEmailis who made the request;protoPayload.request.namenames 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 PolicyCreatePolicy,UpdatePolicyandDeletePolicycalls 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:
- Keys are blocked by policy: you enforce the key creation constraint (Google states the legacy key constraints are enforced by default for organisations created on or after 3 May 2024) and need to know when it is bypassed through an exception.
- Keys are still allowed: older organisations often have not enforced the constraint yet. Detection gives you a list of who still creates keys while you migrate. See How to inventory Google Cloud service account keys and replace them with federation.
- Powerful service accounts exist: a key for a service account with Owner or Editor is as good as that role. See How to Find GCP Service Accounts With Owner or Editor Roles.
How this differs from the AWS case
| Aspect | AWS IAM | Google Cloud IAM |
|---|---|---|
| Event | CloudTrail CreateAccessKey | Cloud Audit Logs google.iam.admin.v1.CreateServiceAccountKey and UploadServiceAccountKey |
| Who gets the key | An IAM user (optional UserName parameter) | A service account, named in protoPayload.request.name; resource.type is service_account |
| Caller field | userIdentity | protoPayload.authenticationInfo.principalEmail |
| Preventive guardrail | Service control policies | Organisation policy constraints iam.managed.disableServiceAccountKeyCreation and iam.managed.disableServiceAccountKeyUpload |
| Main exception risk | An SCP carve-out | A 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.
| Signal | Service and method | Log type | Severity guide |
|---|---|---|---|
| Key created | iam.googleapis.com google.iam.admin.v1.CreateServiceAccountKey | Admin Activity | High outside exception list; medium inside it |
| Public key uploaded | iam.googleapis.com google.iam.admin.v1.UploadServiceAccountKey | Admin Activity | High: uploads are rare and the private half never touched Google |
| Key disabled or deleted | DisableServiceAccountKey, DeleteServiceAccountKey | Admin Activity | Informational; use for time-to-revoke and clean-up evidence |
| Key policy changed | orgpolicy.googleapis.com google.cloud.orgpolicy.v2.OrgPolicy.CreatePolicy, UpdatePolicy, DeletePolicy | Admin Activity | High 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 Created | Security Command Center Premium | Google 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
- Route Admin Activity logs centrally. Create a non-intercepting aggregated sink on the organisation with
includeChildrenset to true, filtered toprotoPayload.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. - 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):
Confirm against a test key which fields carry the result in your logs; Google's published example shows
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 1protoPayload.serviceName="iam.googleapis.com" (protoPayload.methodName="google.iam.admin.v1.CreateServiceAccountKey" OR protoPayload.methodName="google.iam.admin.v1.UploadServiceAccountKey")principalEmail,request.name,resourceName(the numeric service account ID) andresource.type="service_account". - Write the policy change query. Alert on Organization Policy writes that name a key constraint:
Organisation policy resource names include the constraint name (check one test event to confirm the format in your logs), so matchingSample 1
protoPayload.serviceName="orgpolicy.googleapis.com" protoPayload.methodName=~"OrgPolicy\.(CreatePolicy|UpdatePolicy|DeletePolicy)$" protoPayload.resourceName=~"ServiceAccountKey"ServiceAccountKeycovers the creation, upload, expiry and exposure response constraints. Google notes the v1 API logs undercloudresourcemanager.googleapis.com, so add that service if any tooling still uses v1. - 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
labelExtractorsif you want the caller and service account in the notification title. - 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.
- 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.
- 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
principalEmailshows impersonation through delegation. See GCP Audit Log Principal Fields. - 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 method | Fits | Detection consequence |
|---|---|---|
Project override of iam.managed.disableServiceAccountKeyCreation | A 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 policy | Larger estates where only named service accounts need keys | Narrower blast radius, but anyone who can bind the tag can widen it; also monitor tag bindings on service accounts |
Expiry with iam.serviceAccountKeyExpiryHours | Any exception project | Allowed 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
- 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.
- Exception test: repeat in an exception project and confirm the lower severity route.
- Policy test: in dry-run or a sandbox folder, update the key creation policy and confirm the policy change alert.
- 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
labelExtractorsthrough the API.
Hardening afterwards
- Enforce the managed constraints at the root:
iam.managed.disableServiceAccountKeyCreationandiam.managed.disableServiceAccountKeyUpload, with exceptions only from the register. See the Google Cloud Organization Policy Guide. - Keep exposure response on: confirm
iam.serviceAccountKeyExposureResponseisDISABLE_KEY, which Google states is the default behaviour from 16 June 2024 when no value is set;WAIT_FOR_ABUSEshould raise an alert of its own. - Restrict who can create keys: review who holds
iam.serviceAccountKeys.createon 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
| Framework | Reference | How this guide supports it |
|---|---|---|
| MITRE ATT&CK v20 | T1098.001 Additional Cloud Credentials; T1078.004 Cloud Accounts | Detects credential creation for persistence and later use of the service account |
| NIST SP 800-53 Rev 5 | IA-5 Authenticator Management; AC-2(4) Automated Audit Actions; AU-6 Audit Record Review, Analysis, and Reporting; CM-3 Configuration Change Control | Monitoring credential issuance and changes to preventive policy |
| NIST CSF 2.0 | DE.CM-03; DE.CM-09; DE.AE-02 | Monitoring activity and technology, analysing adverse events |
| CIS Controls v8.1 | Control 5 Account Management; Control 8 Audit Log Management | Governing 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:
UploadServiceAccountKeyregisters 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
CreateServiceAccountKeyandUploadServiceAccountKey. - 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_KEYacross the organisation.
Standards and references
- Google Cloud: IAM audit logging
- Google Cloud: Audit log examples for service accounts
- Google Cloud: Restricting service account usage
- Google Cloud: Organization Policy audit logging
- Google Cloud: Aggregated sinks
- Google Cloud: Configure log-based alerting policies
- Google Cloud: Event Threat Detection overview
- MITRE ATT&CK: T1098.001 Additional Cloud Credentials
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