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, insideroles/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 canactAsa powerful identity is that identity, with a public endpoint attached.iam.serviceAccounts.getAccessToken,signBlob,signJwt,generateOpenIdConnectToken—roles/iam.serviceAccountTokenCreator. Callsiamcredentials.googleapis.comand mints the SA's credentials directly. No deployment, no workload: POSTgenerateAccessToken, 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:
- Enumerate minting-permission holders.
gcloud asset analyze-iam-policyor Policy Analyzer answers "who can actAs this service account" directly. On Azure,az role assignment list --allplus a filter on theMicrosoft.Authorization/roleAssignments/writeaction finds the grantors. - Use IAM Deny to wall off crown-jewel service accounts: deny
iam.serviceAccounts.getAccessTokento everyone except a break-glass group. Deny rules override allow bindings — Owner included. They attach at org, folder, or project level againstprincipalSetmembers — the exception layer on top of allow bindings, not a per-resource toggle. - 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. - 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?
Keep reading
Related articles from the SudoSecurity blog.
AWS Emulator Puts AWS on Your Laptop. Keep Your IAM Tests Off It.
AWS released AWS Emulator on November 11, a free local server that answers AWS API calls on 127.0.0.1 with per-run keys and fresh certificates.
Big Tech Plans to Work with the Public Sector for Cybersecurity
Both Microsoft, Inc. and Alphabet, Inc. will put a combined $30 billion dollars into cybersecurity over the next five years and work with the public sector on several initiatives to help improve cybersecurity.
Zero Trust Everything: The Complete Guide to Self-Hosting Teleport for Secure Infrastructure Access
SudoSecurity runs Teleport internally for everything — admin panel access, secure database connections, Kubernetes, and zero-trust philosophy across our entire team. This is the complete technical guide to installing, configuring, and running your own self-hosted Teleport cluster from scratch.
What is SSRF? Server-Side Request Forgery and the Attack That Breached Capital One
SSRF tricks your server into making requests to internal systems — cloud metadata services, internal APIs, AWS credentials endpoints. It turned a WAF misconfiguration into 100 million stolen Capital One records