
Lambda MicroVM Sandbox Test: Credentials, Fork Bombs, and Snapshot State
I ran attack code as root inside Lambda MicroVMs. The execution role is the real boundary, a fork bomb kills the VM, and snapshot state repeats across VMs.
I ran attack code as root inside AWS Lambda MicroVMs to see what the sandbox lets through. MicroVMs give a per-user or per-session sandbox its own Firecracker virtual machine: VM-level isolation, near-instant launch and resume from a snapshot, and state that survives idle periods. The pitch is for AI coding assistants, interactive analytics, vulnerability scanners, and anything else that has to run code it didn't write.
MicroVMs launched June 22, 2026. x86 support landed Nov 11. A handful of posts already walk through the hello-world setup and the pricing model, so this one skips that and goes straight at the sandbox: what it exposes to the code running inside it, what happens when that code misbehaves, and where the documentation doesn't match what the service actually does.
I built two images, launched seven MicroVMs across two rounds, ran five categories of attack from inside the guest, and tore everything down afterward. Account cost: under $2 combined, with full teardown confirmed by listing every resource type at the end.
Setup
An image is built from a zip containing a Dockerfile and application code, uploaded to S3.
create-microvm-image runs the Dockerfile, starts the app, waits for a /ready signal, and takes a Firecracker snapshot of the fully initialized memory and disk state. Every MicroVM launched from that image resumes from the snapshot instead of booting cold.My guest app is a small Python HTTP server with a few endpoints:
/ returns identity and init-time values, /fresh generates values at request time instead, /set and /state write and read a bit of state, and /sh and /py run a command or a script and return the output. Two images: one at the default 2 GB / 1 vCPU baseline, and one built with additionalOsCapabilities: ["ALL"] for the elevated-capability tests.I launched MicroVMs with and without an execution role attached, so I had a clean control for the credential test. The role I attached,
MicrovmDemoExecRole , had exactly one permission: read a single object in S3, a "canary" file used to prove the credentials were real and scoped correctly, not just present.What held up
Guest-to-guest network isolation. Every MicroVM's interface shows an identical-looking
169.254.0.2/30 address. At first glance that reads like a shared subnet. It isn't. It's a dedicated point-to-point link per VM, not a LAN. An apparent "open port 8080" when MicroVM A targeted that address was A reaching its own server, not a sibling's. I confirmed this by testing a definitely-closed port (9999) on the same address, which correctly refused the connection, proving the address resolves locally rather than to a neighbor. Each VM also carries a distinct, globally-routable IPv6 address, and A had no route to B's real IPv6 address at all.I repeated the test from the elevated-capability image.
additionalOsCapabilities: ALL let the guest set promiscuous mode on its own interface and create a new network namespace with unshare --net , both of which worked. Neither found anything, because the interface is a dedicated virtio link to only the gateway and the metadata service, so there's no shared segment to capture traffic from. The neighbor table showed only the gateway and the metadata address, never another tenant.This is a guest-perspective test only. It doesn't rule out a host- or hypervisor-level attack path, and testing that would be out of scope for a customer account under AWS's penetration-testing policy anyway. What I can say is that nothing reachable from inside one MicroVM's own network stack led to another one.
Elevated capabilities stay inside the VM boundary. The second image's guest reported a full capability bitmask (
CapEff: 000001ffffffffff ). Mounting a tmpfs worked. Creating a network namespace worked. None of the host's actual block devices were visible ( /dev/sd* , /dev/nvme* , /dev/vd* were all absent), and dmesg showed what reads as the VM's own kernel ring buffer after a snapshot resume, not a shared host log. Elevated capabilities are real inside the sandbox, and contained by the VM boundary rather than relying on a container's cgroup alone.Suspend and resume preserves state correctly. I set an in-memory value and wrote a file, called
suspend-microvm , confirmed the state transition, then sent a request. It resumed in about 1.3 seconds with both the in-memory value and the file intact.What didn't hold up, or holds up with a sharp edge
Execution-role credentials leak to any root process in the guest
Lambda MicroVMs exposes an EC2-style metadata service at
169.254.169.254 . A MicroVM with an execution role attached serves latest/meta-data/iam/security-credentials/execution_role , with a live AccessKeyId, SecretAccessKey, and session Token. A MicroVM with no execution role doesn't have that path at all, which makes a clean control.I extracted the credentials from the metadata service and used them directly, not through any SDK convenience that might have hidden a failure:
$ aws sts get-caller-identity{ "Arn": "arn:aws:sts::111122223333:assumed-role/MicrovmDemoExecRole/Lambda-microvmsExecutor-microvm-..."}
$ aws s3 cp s3://.../canary/secret.txt -CANARY-SECRET-1794579432
$ aws s3 lsAn error occurred (AccessDenied) ... s3:ListAllMyBuckets
$ aws iam list-usersAn error occurred (AccessDenied) ... iam:ListUsers

This is not a bug. It's the same credential-vending mechanism EC2 instance profiles and ECS task roles use, and it's documented. The reason it's worth a whole section: code running inside a MicroVM, including code an AI agent wrote and you never reviewed, has exactly the access of whatever execution role you attached, as root, reachable over a well-known address with no extra privilege required. The "attack" here succeeded exactly as far as IAM allowed it to, and not one step further. That boundary is the actual control. Get the role's scope wrong and the boundary moves with it.
A fork bomb kills the whole sandbox. A memory bomb kills only the process.
I ran an uncapped fork bomb (
:(){ :|:& };: , roughly 4,000 forks) inside one MicroVM. Result: the entire VM went from RUNNING to TERMINATED .$ aws lambda-microvms get-microvm --microvm-identifier ...{ "state": "TERMINATED", "stateReason": "Container Stopped with Exit Code: 137"}Exit code 137 is SIGKILL, consistent with the runtime killing the VM outright. I didn't determine which limit it hit (process count, memory, or CPU). It did not recover, and the sibling MicroVM I was also running showed no change in response latency (roughly 0.8–0.9 seconds before, during, and after), which is the result you want: a tenant that misbehaves badly enough gets killed, and the neighbor doesn't notice.
A memory-only test on a separate, clean MicroVM told a different story. A Python process allocating 10 MB chunks in a loop climbed to about 7.6 to 7.8 GB before being OOM-killed (return code -9). The process died. The VM did not. It stayed
RUNNING and kept answering requests normally afterward. free -m inside that VM reported exactly 8016 MB total memory, an exact match for the documented 8 GB peak burst ceiling on the default 2 GB baseline / 1 vCPU sizing tier.

Two different abuse patterns, two different outcomes, both consistent with the documented sizing model. Forking too aggressively gets the whole sandbox killed. A memory-heavy workload gets capped at the platform's stated ceiling and the VM itself survives. Worth knowing which one your workload looks more like before you ship it.
Snapshot-time state duplicates across unrelated MicroVMs
Anything your init code generates once, before the snapshot is taken, gets baked into that snapshot and handed out identically to every MicroVM that resumes from it. I generated a UUID and a random token at startup and exposed them at
/ . Four of five independently launched MicroVMs, launched minutes apart, returned the exact same values. A fifth returned different ones, for reasons I couldn't pin down from the guest side. It may be a distinct snapshot instance in a small resume pool. I'm stating that as an open question rather than claiming universal duplication, because the data doesn't support "always."The documented fix works as described: an endpoint that generates the UUID and token at request time, not init time, produced distinct values on every MicroVM, every time. The lesson generalizes past UUIDs. API keys, nonces, session identifiers, and anything else your init code generates once are candidates, unless you explicitly defer generation to request time or use the snapshot-compatibility hooks AWS documents for exactly this reason.
Egress isn't actually opt-in
The getting-started guide's own example passes
--egress-network-connectors explicitly, which reads like egress is something you turn on. I launched a MicroVM passing only --ingress-network-connectors , omitting the egress flag entirely.$ aws lambda-microvms run-microvm --ingress-network-connectors $ING{ "egressNetworkConnectors": [ "arn:aws:lambda:us-east-1:aws:network-connector:aws-network-connector:INTERNET_EGRESS" ]}The response attached
INTERNET_EGRESS anyway, and the guest reached https://example.com/ with an HTTP 200 in under half a second. If you're relying on leaving the flag unset as your network boundary, it isn't one. If you need a MicroVM with no outbound access, you need to prove it from inside the guest, not infer it from the CLI flags you passed.

Three things the documentation gets wrong, or doesn't say
I want to be specific about the difference between "the docs are wrong" and "the docs don't say," because I got one of these wrong myself on the first pass and had to walk it back.
1. The getting-started example's own CLI call fails as written. The tutorial's
get-microvm-image --image-identifier my-first-microvm-image example uses a bare image name. In practice, get-microvm-image and delete-microvm-image require the full ARN:$ aws lambda-microvms get-microvm-image --image-identifier hooks-getonly-repro2An error occurred (ValidationException): Invalid ARN format: hooks-getonly-repro2
$ aws lambda-microvms get-microvm-image --image-identifier \ arn:aws:lambda:us-east-1:111122223333:microvm-image:hooks-getonly-repro2hooks-getonly-repro2 CREATE_FAILED
2. The image build hooks are called over POST, and a failure reports as a 5xx, not a 4xx. The hooks table in the docs lists the path and the status codes your handler should return, but not the HTTP method. I built a guest that only implemented
do_GET for the /ready and /validate paths. The build failed:FAILED Ready hook check failed: the application returned a server error (HTTP 5xx) responseThat's exactly
HTTPStatus.NOT_IMPLEMENTED (501), which is what Python's own BaseHTTPRequestHandler returns for an HTTP method with no handler defined. If your hook handler only answers GET, expect a 5xx build failure, not a 4xx one.

3. The per-account quota is a memory ceiling, not a MicroVM count. Running several MicroVMs concurrently at the default 2 GB baseline hit a wall faster than I expected:
An error occurred (ServiceQuotaExceededException) when callingthe RunMicrovm operation: The base maximum allocated memorylimit has been reached for this account.The exact number of concurrent VMs that triggers this moved between my two test rounds (roughly six in the first, four in the second, with other VMs already running), which is consistent with it tracking total requested memory across the account rather than a fixed count. I didn't confirm that against the quota documentation. Check your account's quota before planning a demo, or a production deployment, with many concurrent MicroVMs.

What I got wrong and corrected before publishing: I initially logged the metadata service's token header name as a fifth discrepancy, claiming only
X-metadata-token worked and the EC2-style X-aws-ec2-metadata-token would fail. I re-tested both, deliberately, after writing that claim down. Both worked, full round-trip, token acquired and used successfully either way. That's not a real discrepancy, and I'm not publishing it as one. Flagging the correction here instead, because catching your own wrong claim before it goes out is worth more than a clean-looking list of five findings.What this didn't test
- Hypervisor or Firecracker-level escape. Not realistic to test from inside a customer account, and out of bounds for AWS's standard penetration-testing policy anyway. Everything above is a guest-perspective test of the sandbox boundary as presented to the code running inside it, not an audit of the virtualization layer underneath it.
- Side channels between MicroVMs sharing physical hardware.
- Cross-account isolation.
- Whether idle MicroVMs bill exactly as the idle policy describes over a longer window than this test ran.
Teardown and cost
Every MicroVM, both images, both IAM roles, the S3 bucket, and all CloudWatch log groups were deleted at the end of each test round. I confirmed a clean account state by listing every resource type involved and getting empty results back for all of them. Total MicroVM runtime across both rounds was well under an hour, at the default 2 GB / 1 vCPU baseline, with per-second billing. Combined cost was under $2.
The actual takeaway
None of the findings here are a vulnerability in the usual sense. The credential exposure is the documented vending mechanism. The fork-bomb kill is the platform doing its job. The snapshot duplication has a documented fix. The egress default is a gap between what the getting-started flow implies and what the API does, not a security hole on its own.
The sandbox does what it says and nothing more. If you're planning to run AI-agent-written code inside a MicroVM, the execution role you attach is the real boundary, not the VM. Scope it like you'd scope any role you can't read the code calling it.
Built and torn down November 13, 2026, in us-east-1. Two images (default and
additionalOsCapabilities: ALL ), seven MicroVMs across two test rounds, full teardown confirmed after each round. Total cost under $2.Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article