AWS IAM Privilege Operations via Lambda Execution Role
Detection of IAM API calls that create or empower IAM users and roles, attach policies, or configure instance profiles when the caller is an assumed role session associated with AWS Lambda, potentially indicating privilege escalation or persistence.
This threat focuses on the abuse of AWS Lambda execution roles to perform sensitive IAM operations. Lambda functions, often running with over-permissioned roles, can be exploited by adversaries to escalate privileges and establish persistence within an AWS environment. An attacker gaining control of a Lambda function can leverage its execution role to make IAM API calls that would normally require elevated permissions. This includes creating new IAM users or roles, attaching policies to existing IAM entities, and modifying EC2 instance profiles. The scope of this threat includes any AWS environment utilizing Lambda functions with IAM permissions.
Attack Chain
- An attacker gains unauthorized access to a Lambda function, either through code injection, vulnerable dependencies, or misconfiguration.
- The attacker leverages the Lambda function’s execution role, which has excessive IAM permissions.
- The attacker executes IAM API calls, such as
CreateUser,CreateRole, orCreateAccessKey, to create new IAM identities. - The attacker uses
AttachUserPolicy,PutUserPolicy,AttachRolePolicy, orPutRolePolicyto grant elevated permissions to the newly created or existing IAM identities. - The attacker modifies instance profiles using
CreateInstanceProfileandAddRoleToInstanceProfileto prepare EC2 instances for lateral movement. - The attacker uses the newly created or modified IAM identities to assume roles and access resources they were not previously authorized to access via
sts:AssumeRole. - The attacker achieves privilege escalation, gaining control over sensitive AWS resources and services.
- The attacker establishes persistence by creating rogue IAM users, roles, or access keys.
Impact
A successful attack can lead to full compromise of the AWS environment. An attacker could create highly privileged IAM users and roles, granting them the ability to access and control all AWS resources. This can result in data breaches, service disruptions, and financial losses. The impact is magnified in environments where Lambda functions are heavily relied upon for critical business operations.
Recommendation
- Deploy the Sigma rule “AWS IAM Sensitive Operations via Lambda Execution Role” to your SIEM and tune for your environment to detect the described IAM API calls originating from Lambda execution roles.
- Review and restrict the permissions granted to Lambda execution roles, following the principle of least privilege, to minimize the potential impact of a compromised function.
- Monitor
aws.cloudtrail.user_identity.arnto identify the Lambda function and associated deployment path responsible for the IAM API calls. - Investigate
aws.cloudtrail.request_parametersfor targets such asuserName,groupName,roleName,policyArn, orinstanceProfileNameto understand the scope of the IAM operations. - Revoke or rotate the credentials of any compromised Lambda execution roles to prevent further unauthorized access.
- Remediate any rogue IAM users, roles, or access keys created by the attacker to eliminate persistence mechanisms.
Detection coverage 2
AWS IAM Sensitive Operations via Lambda Execution Role
highDetects successful IAM API calls that create or empower IAM users and roles, attach policies, or wire roles to instance profiles when the caller is an assumed role session associated with AWS Lambda.
AWS IAM Sensitive Operations via Lambda User Agent
mediumDetects successful IAM API calls that create or empower IAM users and roles, attach policies, or wire roles to instance profiles when the user agent indicates AWS Lambda.
Detection queries are kept inside the platform. Get full rules →