Serverless security focuses on ephemeral functions and managed execution environments, while container security often assumes more persistent workloads and more direct control over hosts or clusters. Serverless requires visibility into code execution, function configuration, and event-triggered behavior with minimal operational overhead. Container controls alone usually do not provide enough runtime coverage.
Why This Matters for Security Teams
Serverless and container platforms both reduce infrastructure management, but they shift risk in different places. container security usually centres on images, registries, orchestration, host hardening, and cluster policy. serverless security moves the focus to function code, event sources, execution permissions, and the managed service boundary. Teams that apply one model to the other often miss where identity, secrets, and runtime controls actually live.
The practical issue is not just deployment style. It is the security ownership model. Containers often expose more of the stack, which makes runtime inspection and network segmentation more familiar. Serverless hides the host and shortens the lifecycle, so misconfigurations in IAM, triggers, and logging can create outsized risk. NIST’s Cybersecurity Framework 2.0 is useful here because it pushes teams to map controls to assets and outcomes instead of assuming the same control set works everywhere.
NHIMG research shows why visibility matters: in The State of Non-Human Identity Security, only 1.5 out of 10 organisations were highly confident in securing NHIs, and lack of credential rotation was cited as the top cause of NHI-related attacks by 45% of organisations. In practice, many security teams discover the gap only after a function or container has already used an over-privileged secret in production.
How It Works in Practice
Container security is usually built around lifecycle control. Teams scan images before deployment, enforce admission policies, restrict runtime capabilities, monitor east-west traffic, and protect the cluster control plane. The container itself is often treated as a semi-persistent workload, so security programs focus on reducing attack surface across image, node, namespace, and orchestration layers.
Serverless security is more event and identity centric. The unit of control is the function invocation, not the server. That means access should be evaluated against the code path, trigger, and permissions needed for that specific action. Best practice is evolving toward short-lived secrets, least-privilege IAM roles per function, and strong logging for event sources, because a function may exist for seconds and then disappear. This is where NHIs become operationally important, because every function, trigger, and API connection is acting through a non-human identity.
For implementation, teams commonly separate controls into three layers:
-
Build time: scan container images, function packages, and IaC for secrets, risky dependencies, and unsafe permissions.
-
Deploy time: enforce policy-as-code for registry trust, runtime limits, and identity bindings.
-
Run time: monitor invocation patterns, privilege use, outbound connections, and secret access.
The difference is visible in incident response too. A container may be isolated, quarantined, or reimaged. A serverless function is more likely to be remediated by revoking its role, rotating its secret, or disabling the trigger. Guidance from the Massive Docker Hub Secrets Leak and the Docker Hub Auth Secrets in Container Images articles also reinforces a common lesson: secrets embedded in images or deployment artifacts become difficult to control once copied into multiple execution environments.
These controls tend to break down when teams mix serverless functions, containers, and shared secrets in the same pipeline because ownership of identity, logging, and revocation becomes unclear.
Common Variations and Edge Cases
Tighter runtime control often increases operational overhead, requiring organisations to balance security depth against deployment speed. That tradeoff is especially visible when serverless and container workloads are combined in one application path.
One common edge case is a containerised service that calls serverless functions as downstream tasks. In that pattern, container hardening alone does not protect the function permissions, and serverless IAM alone does not protect the container image supply chain. Another edge case is when functions run inside managed container abstractions. There is no universal standard for this yet, so guidance should be treated as environment specific rather than one-size-fits-all.
Another practical difference is observability. Containers often support richer host and process telemetry, while serverless platforms may restrict low-level inspection. That makes request tracing, identity-aware logging, and configuration review more important for functions. Current guidance suggests prioritising the following where serverless is used heavily:
-
Per-function least privilege rather than shared execution roles.
-
Automatic rotation of secrets with short TTLs.
-
Trigger review for every event source and webhook path.
-
Policy checks on both code and infrastructure templates.
For containers, the recurring blind spot is assuming the orchestrator solves the problem. It does not replace image provenance, runtime hardening, or secret hygiene. The security model must match the workload model, not the deployment marketing label.
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, OWASP Agentic AI Top 10 and CSA MAESTRO address the attack and risk surface, while NIST CSF 2.0 and NIST AI RMF set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identity Top 10 | NHI-03 | Serverless and containers both depend on safe secret rotation and short-lived credentials. |
| OWASP Agentic AI Top 10 | A-04 | Function and workload identities need runtime authorization, not static assumptions. |
| CSA MAESTRO | ID-01 | Covers identity, workload trust, and runtime governance across managed compute models. |
| NIST CSF 2.0 | PR.AC-4 | Least privilege and access governance apply differently to functions and containers. |
| NIST AI RMF | GOVERN | Identity and runtime governance need clear ownership across ephemeral and persistent workloads. |
Inventory non-human identities and rotate or revoke credentials before they become persistent attack paths.
Related resources from NHI Mgmt Group
- What is the difference between shift left and runtime enforcement for container security?
- What is the difference between static image security and runtime container security?
- What is the difference between provenance and integrity in container security?
- What is the difference between agentless and agent-based container security?