Privilege Escalation
lambda:UpdateFunctionConfiguration (layer injection)
An attacker with lambda:UpdateFunctionConfiguration attaches a hostile layer to an existing function, running code with the function's execution role on the next invocation.
Required Permissions
Description
Lambda layers are shared code that Lambda loads before the function handler runs. They include extensions, which run alongside the handler and can read the execution role's credentials from the Lambda environment.
The hackaws agent publishes an ephemeral layer in the platform account that contains a Lambda extension. The extension reads AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_SESSION_TOKEN from the environment on startup and uploads them to a pre-signed S3 URL baked into the extension code. The agent adds the layer to a chosen customer function, waits for the next invocation, reads the credentials from S3, and then removes the layer and restores the original configuration.
No iam:PassRole is required because the function is already configured with its execution role. No handler code or environment variable is changed; the only trace is the layer list.
Impact
Short-term credentials for the function's execution role. The attack reaches any role attached to a function the caller can modify, including roles not trusted by any principal the attacker controls.
Detection
Alert on UpdateFunctionConfiguration events that change the Layers field. Reconcile the layer list on every function against a baseline. Alert on layers whose ARN is in an account outside the organization.
Mitigation
Deny lambda:UpdateFunctionConfiguration from non-deploy principals through an SCP. Use a Condition on lambda:Layer to pin layers to an allowlist of internal ARNs. Review function configurations on a schedule for layers from external accounts.