A serverless function is short-lived compute that runs on demand and shuts down after handling a request or event. It is well suited to lightweight tasks, but its execution limits, cold starts, and stateless design can make it a poor fit for long-running AI workflows or complex agent orchestration.
What Serverless Functions Are
Serverless functions are event-driven compute units that execute only when triggered, then stop. That execution model reduces always-on infrastructure management, but it also changes how teams think about packaging, scaling, observability, and trust boundaries because the runtime is ephemeral rather than persistent.
Why the Model Matters for Security
The main security value of serverless computing is that a smaller operational footprint can reduce some classes of server exposure. The trade-off is that each invocation may carry its own permissions, dependencies, secrets, and input handling logic, so security must be evaluated at the function boundary rather than at a long-lived host boundary. For a practical security overview, Serverless Security Guide covers function execution roles, event injection, function URLs, keys, and logging.
Because serverless functions are usually stateless, security controls that depend on persistent local state, long-lived sessions, or host-based assumptions can be weaker or simply inapplicable. That makes identity, event validation, and secret handling more important than the machine itself.
Common Failure Modes
Serverless functions often fail securely only if the surrounding event sources, permissions, and secrets are designed well. A weak trigger can invoke the function with attacker-controlled input; an overly broad execution role can turn a small bug into broad cloud access; and leaked keys or environment variables can expose downstream services. Cold starts and short execution windows can also hide abuse from teams that expect traditional endpoint-style telemetry.
Another common issue is dependency sprawl. Even a tiny function can import libraries, call APIs, and rely on storage, queues, or identity providers. If any of those dependencies are misconfigured or compromised, the function becomes an access path into a wider system rather than a narrow utility.
How Serverless Fits in Modern Architectures
Teams choose serverless for bursty workloads, glue logic, lightweight automation, and event processing because it can reduce provisioning overhead and scale quickly. It is a poor fit when the workload needs long-lived state, tight execution control, heavy computation, or complex orchestration. The architectural question is not whether serverless is “good” or “bad”, but whether the workload’s lifecycle, latency, and trust requirements match the platform’s event-first design.
That is why serverless is often used alongside queues, managed APIs, object storage, and managed identity services rather than as a standalone pattern. In practice, the function is only one part of the trust chain, and the surrounding services often determine the real security posture.
Risk and Threat Considerations
Serverless functions can concentrate risk in short-lived but highly privileged execution paths, especially when event sources, secrets, or API-facing triggers are not tightly governed. Attackers may try to inject malicious events, abuse exposed function URLs, or exploit overprivileged execution roles to pivot from a single request into broader cloud access.
Failure mechanism: A vulnerable trigger, excessive permissions, or exposed secret material lets an attacker turn an on-demand function into a transient but effective compromise path, even though the runtime itself is short-lived.
Impact: The result can include unauthorized data access, service abuse, downstream API calls, secret theft, or costs from runaway invocations and resource consumption.
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 OWASP API Security Top 10 address the attack and risk surface, while NIST CSF 2.0, NIST SP 800-53 Rev 5 and CIS Controls v8 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| NIST CSF 2.0 | PR.AA-05 — Least Privilege | Serverless functions rely on tightly scoped execution permissions. |
| DE.CM-01 — Network Monitoring and Event Analysis | Serverless abuse is often visible only through event and telemetry monitoring. | |
| Recommendation — Scope each function to least-privilege access and review its runtime permissions regularly. Monitor invocation patterns and event sources for anomalous function activity. | ||
| NIST SP 800-53 Rev 5 | IA-9 — Identification and Authentication (Service) | Functions and related services authenticate to other cloud services as non-human actors. |
| Recommendation — Use service authentication controls for function-to-service trust relationships. | ||
| CIS Controls v8 | CIS-5 — Account Management | Function identities and access paths require governance over who or what can use them. |
| Recommendation — Inventory and govern all function-linked accounts, roles, and access paths. | ||
| OWASP Non-Human Identity Top 10 | NHI-05 — Overprivileged NHI | Function execution identities often behave as non-human identities with excessive access risk. |
| Recommendation — Reduce function privilege to the minimum needed for each invocation path. | ||
| OWASP API Security Top 10 | API8 — Security Misconfiguration | Function URLs and event-facing endpoints are exposed through API-like interfaces and misconfiguration is a common failure mode. |
| Recommendation — Harden exposed function endpoints and validate access controls on every trigger. | ||
Practitioner Guidance
What to watch for: Treat the trigger, execution role, and secret scope as the real control surface for serverless security. The function code may be small, but the effective blast radius is defined by what it can read, call, or invoke once it starts.
Practitioner takeaway: If you cannot clearly explain what each trigger may send, what each function may reach, and what credentials it can access, the design is not yet serverless-safe.
Related resources from NHI Mgmt Group
- What breaks when serverless security depends on embedding controls directly into function code?
- What should teams look for when deciding whether a serverless function needs extra runtime protection?
- What happens when a serverless function can execute untrusted code or write to the wrong runtime location?
- What are the signs that a serverless function may have been tampered with?
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on October 30, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org