Every Google Cloud project quietly accumulates identities that no one in the organisation created: service agents, the Google-managed service accounts that let Compute Engine, Cloud Build, GKE, Pub/Sub and dozens of other services act on your resources. They hold role bindings in your IAM policies, they appear in your audit logs, and the access you grant them (a KMS key for customer-managed encryption, a bucket, a Pub/Sub topic) is part of your attack surface and your access reviews. This guide explains what service agents are, how to recognise them by email pattern, which of their roles you control and which you should leave alone, and how to inventory, monitor and review them. It is written for Google Cloud platform, IAM and security engineers. For IAM policy mechanics, user-managed service accounts and impersonation, see the Google Cloud IAM and Service Accounts Guide; this page goes deeper on the Google-managed side.
This is an independent guide from NHI Mgmt Group, based on Google Cloud's public 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
- Service agents are Google-managed identities that act for a service. Google Cloud creates and manages them; they are not created in your projects and you cannot access them directly, but their role bindings live in your IAM policies.
- Recognise them by email pattern. Most project-level agents use [email protected], with folder and organisation variants using service-folder- and service-org- prefixes.
- Leave the default service agent roles in place. Google advises not to revoke roles granted to service agents unless a role recommendation suggests it, because services can stop working.
- Govern the grants you add. Roles you give a service agent on a KMS key, bucket or topic are your decisions: scope them to the single resource and review them like any other non-human identity grant.
- Never hand a service agent role to anyone else. Google states that service agent roles should be granted only to service agents; use a predefined or custom role for people and workloads.
What service agents are
Google Cloud's service account documentation describes three kinds of service account. Service agents are the accounts Google Cloud creates and manages so that its services can access your resources on your behalf. The documentation states that service agents are not created in your projects and that you cannot access them directly: there are no keys to download and no way to impersonate them.
- When they appear: service agents are created automatically as you enable and use Google Cloud services, and some are granted a role on the project at the same time. Google states that it can introduce new service agents at any time, so the list in your projects will grow.
- Primary and supporting agents: Google's service agent reference marks one agent per API as the primary service agent; other agents for the same API serve a specific function, such as the GKE node service agent.
- Project, folder and organisation scope: most agents are per project. Some services also have folder-level and organisation-level agents, which Google's reference lists with no role granted automatically.
- Creating them in advance: to grant roles before first use, for example in Terraform or another policy-as-code system where automatic grants would not appear in stored policy, Google documents on-demand creation with gcloud workload-identity service-agents generate, the Terraform resource google_workload_identity_service_agent or the generateServiceAgents REST method. Agents created this way are not automatically granted roles, so you grant the listed role yourself.
- The role manager: Google documents a service agent, [email protected], that manages the roles granted to other service agents and is visible only in audit logs.
Service agent naming patterns
| Service | Service agent email pattern | Role Google grants on the project |
|---|---|---|
| Google APIs (legacy, shared) | [email protected] | Editor (roles/editor) |
| Compute Engine | [email protected] | roles/compute.serviceAgent |
| Cloud Build | [email protected] | roles/cloudbuild.serviceAgent |
| Cloud KMS | [email protected] | roles/cloudkms.serviceAgent |
| Cloud KMS (organisation) | service-org-ORGANIZATION_NUMBER@gcp-sa-cloudkms.iam.gserviceaccount.com | None granted automatically |
| Cloud Run | service-PROJECT_NUMBER@serverless-robot-prod.iam.gserviceaccount.com | roles/run.serviceAgent |
| Cloud Storage | service-PROJECT_NUMBER@gs-project-accounts.iam.gserviceaccount.com | None granted automatically |
| GKE | service-PROJECT_NUMBER@container-engine-robot.iam.gserviceaccount.com | roles/container.serviceAgent |
| GKE nodes | [email protected] | roles/container.defaultNodeServiceAgent |
| Pub/Sub | [email protected] | roles/pubsub.serviceAgent |
| Secret Manager | service-PROJECT_NUMBER@gcp-sa-secretmanager.iam.gserviceaccount.com | None granted automatically |
Patterns are taken from Google's service agent reference as updated on 24 November 2026. Names change and new agents are added, so build detection on the reference, not on a hard-coded list. A practical rule of thumb: most addresses ending in .iam.gserviceaccount.com that start with service-, plus [email protected], are Google-managed; NAME@PROJECT_ID.iam.gserviceaccount.com is one of yours.
Service agents versus service accounts
| Question | User-managed service account | Default service account | Service agent |
|---|---|---|---|
| Who creates it | You | Created automatically when you enable or use certain services | Google Cloud |
| Who manages it | You | You, after creation | Google Cloud |
| Email format | NAME@PROJECT_ID.iam.gserviceaccount.com | [email protected]; [email protected] | [email protected] and similar |
| Lives in your project | Yes | Yes | No |
| Keys and impersonation | Possible; restrict them | Possible; restrict them | No direct access |
| Disable or delete | At your discretion | At your discretion, after checking dependencies | Not applicable; manage its role bindings instead |
| Main governance action | Least privilege, keys, impersonation rights | Replace the automatic Editor grant with narrower roles | Keep default roles, scope the grants you add, monitor changes |
The confusion that causes most mistakes is between service agents and default service accounts. Default service accounts such as the Compute Engine default are user-managed, run your code and can carry an automatic Editor grant, which Google recommends replacing with less permissive roles. Service agents run Google's control plane for a service. See the Google Cloud IAM and Service Accounts Guide for the default account clean-up and the organisation policy that stops automatic grants.
Roles granted to service agents
Service agents hold two kinds of grant, and they are governed differently.
- Service agent roles Google grants: predefined roles named roles/SERVICE.serviceAgent (for example roles/cloudbuild.serviceAgent) granted on the project when the agent is created. Google states: "Unless a role recommendation suggests it, don't revoke the roles that are granted to service agents." Removing them can break the service.
- The Google APIs Service Agent: [email protected] is a shared agent for Google APIs. Google notes that the Editor role it holds is highly permissive and suggests using role recommendations to see whether its permissions can be safely reduced.
- Grants you add for a feature: customer-managed encryption keys are the common case. To use CMEK with Cloud Storage, you grant the project's Cloud Storage service agent roles/cloudkms.cryptoKeyEncrypterDecrypter on the key; gcloud storage service-agent with --authorize-cmek does this for you. Other services that support CMEK use the same model with their own service agent; check each service's CMEK page. These grants are your decisions and belong in access reviews.
- Service agent roles are for service agents only: Google's reference tells you not to grant service agent roles to any principal other than a service agent. These roles are designed for a Google control plane and can carry broad permissions; grant people and workloads a predefined or custom role instead.
What the IAM recommender covers
Google's role recommendations documentation states that for service agents the recommender only produces recommendations for basic roles (Owner, Editor or Viewer). For an agent that had a default role, a recommendation may suggest restoring that role; for an agent without one, it uses observed permission use. Service agents holding other roles receive no recommendations, so grants you add (such as a KMS role) need manual review. Recommendations are based on up to 90 days of usage.
Risks and misuse
Service agents themselves cannot be logged into, so the risks sit in the customer-side configuration around them.
| Risk | How it arises | Customer-side control | ATT&CK reference |
|---|---|---|---|
| Service agent role granted to a person or workload | An engineer copies a roles/SERVICE.serviceAgent binding to fix a permission error | Alert on service agent roles bound to any member not matching a service agent pattern | T1098.003 Additional Cloud Roles |
| Over-broad grants added for features | KMS, bucket or topic access granted at project or folder level instead of on the single resource | Grant on the resource; review added grants quarterly | T1078.004 Cloud Accounts |
| Broken services after clean-up | A least-privilege sweep or Terraform apply removes default service agent roles | Exclude service agents from automated removal; use recommendations only | Availability impact rather than a technique |
| Deny policies that block Google services | A deny rule targets a broad principal set that includes service agents | Add service agents as exceptions, as Google recommends for broad deny rules | Availability impact rather than a technique |
| Policy drift hidden in code | Automatic grants are absent from stored Terraform state and get overwritten | Create agents on demand and declare their grants in code | T1484 Domain or Tenant Policy Modification |
| Grants left after a feature is retired | CMEK or cross-project grants stay on keys and buckets after the dependent resource is gone | Tie each added grant to an owner and a resource; remove on decommission | T1078.004 Cloud Accounts |
Where identity fits
Service agents are non-human identities with entitlements in your environment, even though you do not own their credentials. Include them in the NHI inventory as a separate class: owner is Google for the identity, but your team owns every grant added to them. See the Non-Human Identity (NHI) Guide and the Service Account Security Guide.
Governance and monitoring
- Inventory: use Cloud Asset Inventory to search IAM policies across the organisation, for example gcloud asset search-all-iam-policies --scope=organizations/ORGANIZATION_ID with a memberTypes:serviceAccount query, then classify members by email pattern into user-managed, default and service agent. Run it from a dedicated project with the Cloud Asset API enabled.
- Classify grants: for each service agent, separate Google-granted service agent roles from grants your teams added, and record an owner and purpose for each added grant.
- Exclude from automated removal: mark service agent bindings as protected in Terraform modules, clean-up scripts and CIEM tooling so that least-privilege sweeps do not revoke them.
- Create agents on demand where you manage IAM in code: generate the agents for each service and declare their grants explicitly, then apply in a test project first and check the service still works before rolling to production.
- Alert on risky changes: Admin Activity audit logs are always written and record SetIamPolicy calls. Alert when a roles/*.serviceAgent role is bound to a member that is not a service agent, when a service agent role is removed outside change control, and when broad roles are added to a service agent.
- Review: check basic role recommendations for the Google APIs Service Agent and review added grants quarterly. Roll back a problematic change by restoring the previous policy version from your policy-as-code history.
What the logs show
- Admin Activity: always on; records IAM policy changes, including bindings that add or remove service agent roles.
- System Event: always on; records changes made by Google Cloud systems and managed service agents rather than direct user actions, such as autoscaling adding or removing VMs.
- Data Access: off by default except for BigQuery; turn it on for KMS and other sensitive services if you need a record of key use by service agents.
- Caller IP: for calls from one Google Cloud service to another, including service agent calls, callerIp is recorded as private, so filter on identity, not IP.
Route these logs to a central sink. See the Google Cloud Audit Logs and Log Sinks Guide.
Metrics
- Service agent roles bound to non-service-agent members: target zero.
- Added service agent grants with a recorded owner: target 100 percent.
- Added grants scoped to a single resource: percentage, rising over time.
- Unplanned removals of default service agent roles: count per quarter, target zero.
- Projects where the Google APIs Service Agent Editor recommendation has been reviewed: percentage.
Small and large estates
A small organisation with a handful of projects can review service agent grants by hand from the IAM page and an Asset Inventory export each quarter. A large estate should automate classification by email pattern, enforce protected bindings in shared Terraform modules and feed alerts into the SOC. See the Google Cloud Organization Policy Guide for organisation-wide guardrails.
Framework mapping
| Activity | NIST SP 800-53 Rev. 5 | NIST CSF 2.0 |
|---|---|---|
| Inventory service agents and their grants | CM-8, AC-2 | PR.AA-01 |
| Scope added grants to single resources | AC-6 | PR.AA-05 |
| Quarterly review of added grants | AC-6(7) | PR.AA-05 |
| Audit logging and alerting on IAM changes | AU-12 | DE.CM-03 |
Practitioner checklist
- Inventory IAM bindings across the organisation and classify every service account member as user-managed, default or service agent.
- Keep Google-granted service agent roles in place unless a role recommendation suggests otherwise.
- Record an owner and purpose for every grant your teams add to a service agent, and scope it to the single resource.
- Alert when any roles/*.serviceAgent role is bound to a member that is not a service agent.
- Protect service agent bindings from removal in Terraform modules, scripts and CIEM tooling.
- Create service agents on demand and declare their grants where IAM is managed as code.
- Review the basic role recommendation for the Google APIs Service Agent in each project.
- Add service agents as exceptions to broad deny rules, and test deny policies in a non-production project first.
- Remove added grants when the dependent feature or resource is retired.
Standards and references
- Google Cloud: Service agents
- Google Cloud: Service account types
- Google Cloud: Create and grant roles to service agents
- Google Cloud: Role recommendations overview
- Google Cloud: Search IAM allow policies
- Google Cloud: Cloud Audit Logs overview
- Google Cloud: Use customer-managed encryption keys (Cloud Storage)
Related NHI Mgmt Group resources: Google Cloud IAM and Service Accounts Guide · Google Cloud Service Account Keys Security Guide · Service Account Security Guide · Non-Human Identity (NHI) Guide · Cloud KMS and Cloud HSM Guide