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
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

  1. Go to 'IAM'
  2. In the menu, under 'Access management', choose 'Roles'
  3. Select the overly permissive IAM Role
  4. Select the relevant policy
  5. 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

  1. https://docs.aws.amazon.com/lambda/latest/dg/access-control-identity-based.html
  2. https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy
  3. 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 CloudGuard Best Practices
  • AWS CloudGuard SOC2 based on AICPA TSC 2017
  • AWS HITRUST
  • AWS HITRUST v11.0.0
  • 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