Attackers can use that access to inject new processes, run malware or mining code, and potentially move from the function into other cloud resources. In a serverless environment, the writable runtime surface is limited, so abuse often concentrates in temporary storage and injected execution paths. Strong runtime controls need to block those actions before they turn a short-lived function into an attack foothold.
How Untrusted Serverless Execution Becomes a Real Breakout Path
When a function can run untrusted code or write outside its intended runtime surface, the security boundary shifts from “ephemeral compute” to “arbitrary execution with cloud reach.” The immediate concern is not the function itself, but what that code can touch: temporary storage, injected processes, environment variables, network paths, and any attached permissions that let the function talk to other services.
That is why serverless compromises often look small at first and still matter. A short-lived container or sandbox can be enough to stage malware, launch mining activity, or prepare follow-on access if the runtime is not tightly constrained.
Why Writable Runtime Surfaces Are the Main Exposure
Serverless platforms assume the runtime is tightly controlled, so the writable areas are usually narrow and predictable. When that assumption fails, an attacker may use the writable path to drop binaries, alter execution flow, or place payloads where the platform will later load them.
Temporary directories, injected startup hooks, and misdirected writes are especially risky because they can convert a one-time execution opportunity into persistent abuse for the life of the invocation or the reused execution environment. The smaller the runtime surface should be, the more important it is to verify exactly which paths are writable and which are only supposed to be readable.
That distinction is often what separates harmless logging or scratch use from a breakout condition. If the function can modify a location that affects import paths, command launch, or dependency resolution, then code execution becomes materially easier even without a classic server compromise.
What the Attacker Gains After the Function Is Abused
Once untrusted code runs inside the function context, the attacker inherits whatever the function can reach. In practice, that can include cloud APIs, queues, object storage, databases, internal service endpoints, and secrets exposed to the runtime.
The result is often lateral movement, not because serverless is inherently weak, but because the function is frequently trusted to do useful work on behalf of other systems. If permissions are broad, a single abused invocation can become an access bridge into adjacent cloud resources.
That is also why runtime abuse frequently blends into ordinary platform behavior. Mining code, command execution, and short-lived stagers can all look like legitimate function activity unless the environment is monitored for unusual process creation, suspicious outbound connections, or unexpected writes to runtime locations.
Risk and Threat Considerations
When writable runtime locations or arbitrary code execution are available, the main risk is not just code tampering, but privilege amplification inside a trusted execution context. An attacker can use the function to run payloads, harvest reachable secrets, and pivot into other cloud services that trust the function’s permissions.
Failure mechanism: Abuse of temporary storage, injection points, or writable runtime paths lets hostile code survive long enough to execute, alter behavior, or stage follow-on activity before the invocation ends.
Impact: The function can become a foothold for malware, cryptomining, secret access, or cloud lateral movement, with blast radius determined by the function’s permissions and network reach.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
MITRE ATT&CK and OWASP API Security Top 10 address the attack and risk surface, while 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 SP 800-53 Rev 5 | SI-7 — Software, Firmware, and Information Integrity | Covers runtime integrity when code injection or tampering can alter function behavior. |
| CM-7 — Least Functionality | Directly fits limiting writable paths, process creation, and runtime capabilities in functions. | |
| AC-6 — Least Privilege | Applies when function permissions determine whether abuse can reach other cloud resources. | |
| Recommendation — Enforce integrity checks and block unauthorized code changes before execution. Restrict serverless functions to only the runtime capabilities they strictly need. Reduce function permissions so abuse cannot readily pivot into adjacent services. | ||
| CIS Controls v8 | CIS-4 — Secure Configuration of Enterprise Assets and Software | Serverless runtime hardening depends on secure configuration of writable paths and execution settings. |
| Recommendation — Harden function runtime settings and remove unnecessary writeable execution surfaces. | ||
| MITRE ATT&CK | T1059 — Command and Scripting Interpreter | Untrusted code execution maps to attacker use of scripting or command interpreters. |
| Recommendation — Detect and block unexpected interpreter use inside serverless execution contexts. | ||
| OWASP API Security Top 10 | API8 — Security Misconfiguration | Misconfigured runtime locations or permissions can expose serverless execution surfaces. |
| Recommendation — Audit function configuration for writable paths, runtime hooks, and overexposed permissions. | ||
Practitioner Guidance
What to verify: Confirm which runtime paths are writable, whether any of them influence execution, and whether the function can spawn child processes or fetch code at runtime. If any of those are true, treat the function as high-risk until the boundary is reduced.
Decision rule: If a function can write to a location that affects execution or can access production services with broad permissions, prioritize permission reduction and runtime hardening before tuning detection logic.
Practitioner takeaway: The key question is not whether serverless is ephemeral, but whether the runtime is still constrained enough that one successful write or code injection cannot become a broader cloud compromise.
Related resources from NHI Mgmt Group
- What happens when untrusted code is allowed to execute on a workstation during a supply chain attack?
- What happens when an attacker can execute code in a shared tenant runtime with access to internal management credentials?
- What breaks when a workflow engine can execute untrusted code inside the same environment that stores secrets?
- How should security teams respond when a package install can execute hidden runtime code?