
Simulates CVE-2026-23007 serverless cold-start memory remanence; demonstrates how persistent global state across Lambda invocations can leak secrets between executions.
# lambda_remanence.py - Simulated Lambda environment reuse
import os, secrets
def first_invocation():
# Simulates storing a secret in a global variable
global SECRET
SECRET = secrets.token_hex(16)
return "Initialized"
def second_invocation():
# Another function in same container? Actually, separate invocations share memory.
# Here we just read the global if it exists
global SECRET
return SECRET if 'SECRET' in globals() else "No secret"
print("Cold start: ", first_invocation())
print("Warm start: ", second_invocation())
Serverless platforms reuse execution environments (containers) across function invocations without zeroing global memory. An attacker’s function that shares the same underlying host (or even same account) might access remnants of previous executions, leaking secrets.
Run:
python lambda_remanence.py
The second invocation reads the secret set during the first.