Teams should treat the deployment workflow as an access boundary, not just the user who clicked deploy. Review the service account that Cloud Build or similar automation will use, remove inherited project-wide roles, and assign only the permissions required for packaging, publishing, and the specific resources the build must touch.
Why This Matters for Security Teams
Cloud Functions deployments are often treated as low-risk automation, but the deployment path itself can become a privilege escalation route. The build service account, deployment runner, and any linked artifact or secret access can quietly inherit more power than the function needs. That turns a simple code push into a control point for storage, secrets, logging, or broader project operations.
This is a recurring NHI problem: the identity that executes work is not the same as the human who approved it. NHI Management Group’s broader guidance on the Ultimate Guide to NHIs — Key Challenges and Risks shows how hidden automation paths expand blast radius when permissions are inherited rather than intentionally scoped. The issue also maps cleanly to the OWASP Non-Human Identity Top 10, which highlights over-privileged machine identities as a primary weakness. In practice, many security teams discover the exposure only after a function has already been used to access resources the deployment process should never have touched.
How It Works in Practice
The safest pattern is to treat the deployment workflow as a distinct access boundary and design around the exact permissions each step needs. Start by separating human approval from machine execution. The developer may trigger the deployment, but Cloud Build or similar automation should run under a dedicated service account with narrowly defined permissions for build, publish, and only the specific dependencies required by that function.
That usually means removing inherited project-wide roles and replacing them with resource-level grants. For example, the build identity may need to read source, write an artifact, and update one function, but it should not automatically gain access to all secrets, all storage buckets, or unrelated functions. Where possible, use short-lived credentials and workload identity instead of long-lived keys. That aligns with current guidance in the Top 10 NHI Issues and the NIST Cybersecurity Framework 2.0, which both favour least privilege, asset visibility, and continuous control.
- Use a dedicated service account for build and deploy automation.
- Remove broad inherited roles from the project or folder level.
- Grant only the permissions needed for the specific deployment path.
- Separate artifact access from runtime access whenever possible.
- Review secret manager, storage, and logging permissions independently.
For teams comparing real-world failure modes, the Azure Key Vault privilege escalation exposure is a useful reminder that secret access is often the hidden bridge from deployment automation to broader compromise. These controls tend to break down when a single shared deployment identity is reused across multiple environments because the permissions needed for one function quickly become transferable to everything else.
Common Variations and Edge Cases
Tighter deployment scoping often increases operational overhead, requiring teams to balance release speed against permission sprawl. That tradeoff becomes more visible in multi-environment pipelines, where a single function may need different permissions for test, staging, and production. Best practice is evolving, but current guidance suggests avoiding one oversized “deployment” role in favour of environment-specific identities and policies.
Edge cases arise when build steps must interact with private registries, KMS keys, or cross-project resources. In those environments, the risk is not just excessive privilege but privilege inheritance across chained automation. The 230M AWS environment compromise illustrates how automation trust can be abused when identities are too broadly empowered. NHIMG’s Ultimate Guide to NHIs — Why NHI Security Matters Now also notes that many organisations still lack confidence in their NHI controls, which is consistent with the 2024 Non-Human Identity Security Report finding that only 19.6% of security professionals are strongly confident in secure workload identity management. The practical answer is to keep the deployment identity narrow, ephemeral, and environment-specific. When pipelines depend on shared credentials, the model stops being least privilege and starts being shared trust.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Non-Human Identity Top 10 and CSA MAESTRO address the attack and risk surface, while NIST CSF 2.0 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identity Top 10 | NHI-01 | Over-privileged deployment identities are a core NHI failure mode. |
| NIST CSF 2.0 | PR.AC-4 | Least-privilege access for automation aligns directly with this control. |
| CSA MAESTRO | MAESTRO addresses identity and policy for cloud automation workflows. |
Inventory deployment service accounts and strip any permission not required for a single function release.