Skip to content

Lesson 3 of 14 · 14m

The Permissions That Matter Are the Ones That Grant Permissions

actAs, TokenCreator, listKeys, runCommand, and setIamPolicy are the real admin surface in both clouds.

Minting is the privilege

Teams audit for roles/owner and roles/editor. Attackers audit for different strings entirely.

On GCP, the dangerous permissions are the ones that mint or attach identity:

  • iam.serviceAccounts.actAs, inside roles/iam.serviceAccountUser, lets a principal attach a service account to a workload. Deploy a Cloud Run service with --service-account=powerful@project.iam.gserviceaccount.com, a GCE instance, a Cloud Function, a Dataflow job — the workload mints that SA's tokens from the metadata server on every request. Whoever can actAs a powerful identity is that identity, with a public endpoint attached.
  • iam.serviceAccounts.getAccessToken, signBlob, signJwt, generateOpenIdConnectToken — roles/iam.serviceAccountTokenCreator. Calls iamcredentials.googleapis.com and mints the SA's credentials directly. No deployment, no workload: POST generateAccessToken, receive a live token.
  • iam.serviceAccountKeys.create — roles/iam.serviceAccountKeyAdmin. Mints the eternal JSON key.
  • setIamPolicy — resourcemanager.projects.setIamPolicy, storage.buckets.setIamPolicy, and the same verb on every resource — edits the bindings themselves.

Azure's equivalents: Microsoft.Authorization/roleAssignments/write (Owner and User Access Administrator — granting is the crown), Microsoft.Storage/storageAccounts/listKeys/action, Microsoft.Compute/virtualMachines/runCommand/action, and the Global Admin elevateAccess toggle.

The composition problem

The wrong mental model is "least privilege means don't grant Owner." Watch the composition instead: roles/run.developer lets you deploy Cloud Run revisions. roles/iam.serviceAccountUser on a project-Editor default service account lets you choose that SA at deploy time. Neither role is Owner. Together they deploy a public service running as project Editor — full minting rights over nearly everything in the project.

Every public GCP privilege-escalation enumeration — Rhino Security's canonical list is the reference — is built from this shape: a boring role that can attach, mint, or edit identity on something more powerful. The Azure version is the same shape wearing different names: Contributor can't grant roles, but it can run commands as root — SYSTEM on Windows — on a VM carrying a vault-authorized managed identity. Two safe-looking permissions, one escalation.

The attach surface is broader than Cloud Run: gcloud compute instances create --service-account=, gcloud functions deploy --service-account, Dataflow workers, Cloud Composer environments — every deployment surface that takes an SA consumes actAs. Azure's equivalent is Microsoft.ManagedIdentity/userAssignedIdentities/*/assign/action: whoever can attach a powerful user-assigned identity to a VM they control mints it at IMDS. And on GCP, note that deployment itself is often delegated — a CI pipeline or Cloud Build service account holding actAs on a prod SA is an escalation that lives in your build config, not in a human's role list.

Deny the crown jewels, audit the minters

The tooling answers the question directly. Policy Analyzer — gcloud policy-intelligence query-policy, or the console page — lists who holds a role org-wide, and filters down to iam.serviceAccounts.actAs holders on a specific SA. Policy Troubleshooter answers the inverse: can this principal perform this permission on this resource, and which binding grants it. On Azure, a Resource Graph query over authorizationresources where type =~ 'microsoft.authorization/roleassignments' enumerates every assignment; filter the role definitions for roleAssignments/write to find your grantors.

The defenses, concretely:

  1. Enumerate minting-permission holders. gcloud asset analyze-iam-policy or Policy Analyzer answers "who can actAs this service account" directly. On Azure, az role assignment list --all plus a filter on the Microsoft.Authorization/roleAssignments/write action finds the grantors.
  2. Use IAM Deny to wall off crown-jewel service accounts: deny iam.serviceAccounts.getAccessToken to everyone except a break-glass group. Deny rules override allow bindings — Owner included. They attach at org, folder, or project level against principalSet members — the exception layer on top of allow bindings, not a per-resource toggle.
  3. Never let deployment roles (roles/run.developer, roles/cloudfunctions.developer, runCommand) touch identities carrying broad grants. Dedicated SAs per workload, narrow predefined roles, and the "who can attach" list reviewed like the admin list — because it is one.
  4. Alert on minting calls in audit logs: generateAccessToken, signBlob, service account key create/delete, listKeys, runCommand. These precede escalation; they are rarer than reads and far higher signal.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.