Ensure that Lambda Function execution role policy doesn't have excessive permissions (Contains a wildcard)
Determine the specific permissions needed by your Lambda Functions, and then craft IAM policies for these permissions only, instead of full administrative privileges.There should not be any policies that grant blanket permissions ('*') to resources. It is recommended and considered a standard security best practice to grant least privileges that is, granting only the permissions required to perform a task.
Risk Level: High
Cloud Entity: AWS Lambda
CloudGuard Rule ID: D9.AWS.IAM.55
Covered by Spectral: No
Category: Compute
GSL LOGIC
Lambda should not have executionRole.combinedPolicies contain [ relationType!='AssumeRole' and policyDocument.Statement contain [Effect='Allow' and (Action contain [$ regexMatch /\*/] or Action regexMatch /\*/) ]]
REMEDIATION
From Portal
- Go to 'IAM'
- In the menu, under 'Access management', choose 'Roles'
- Select the overly permissive IAM Role
- Select the relevant policy
- Redefine its permissions based on the principle of least privilege
From TF
To update an IAM policy, edit the 'Action' argument:
resource "aws_iam_policy" "example_iam_policy" {
..
policy = jsonencode({
..
Statement = [
{
..
Action = ACTIONS-LIST
..
},
]
})
}
From Command Line
To update a managed policy, use:
aws iam create-policy-version --policy-arn POLICY-ARN --policy-document POLICY-DOCUMENT
Note: Additional instructions (For example: How to update inline policy) can be found within the references.
References
- https://docs.aws.amazon.com/lambda/latest/dg/access-control-identity-based.html
- https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy
- https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_manage-edit.html
AWS Lambda
AWS Lambda lets you run code without provisioning or managing servers. You pay only for the compute time you consume - there is no charge when your code is not running.
With Lambda, you can run code for virtually any type of application or backend service - all with zero administration. Just upload your code and Lambda takes care of everything required to run and scale your code with high availability. You can set up your code to automatically trigger from other AWS services or call it directly from any web or mobile app.
Compliance Frameworks
- AWS CSA CCM v.4.0.1
- AWS CloudGuard Best Practices
- AWS CloudGuard SOC2 based on AICPA TSC 2017
- AWS HITRUST
- AWS HITRUST v11.0.0
- AWS ISO27001:2022
- AWS ITSG-33
- AWS MITRE ATT&CK Framework v10
- AWS MITRE ATT&CK Framework v11.3
- AWS NIST 800-53 Rev 5
- AWS PCI-DSS 4.0
- AWS Security Risk Management
- CloudGuard AWS All Rules Ruleset
Updated about 1 year ago