This rule ensures Lambda functions have secure policies against public access.
Rule | Lambda function policies should prohibit public access |
Framework | AWS Foundational Security Best Practices |
Severity | ✔ Critical |
Policy Description:
The policy for Lambda functions should prohibit public access to ensure compliance with AWS Foundational Security Best Practices. This policy helps protect sensitive data and prevents unauthorized access to your Lambda functions.
Policy Details:
To enforce this policy, you need to configure the necessary permissions and settings for your Lambda functions. Here are the steps to follow:
1. Disable Public Access:
a. Open the AWS Management Console and navigate to the Lambda service. b. Select the Lambda function for which you want to disable public access. c. In the function settings, locate the "Permissions" tab. d. Under the "Network settings" section, ensure that the "Public access" option is disabled.
2. Implement VPCs and Private Subnets:
a. Establish a Virtual Private Cloud (VPC) to isolate your Lambda functions. b. Create one or more private subnets within the VPC. c. Configure your Lambda functions to use the private subnets for execution. d. Ensure that the necessary VPC and subnet configurations are correctly set for your Lambda functions.
3. Restrict IAM Policies:
a. Review the existing IAM policies related to Lambda functions. b. Ensure that the IAM policies do not grant excessive permissions or allow public access. c. Remove any unnecessary IAM policies or permissions that could potentially expose your Lambda functions to the public.
4. Enable Resource-Specific Permissions:
a. Configure resource-specific permissions to restrict access to individual Lambda functions. b. Define appropriate IAM roles and policies to control access based on specific functions or resource ARNs. c. Implement least privilege principles and grant permissions only to the necessary individuals or services.
Troubleshooting Steps:
If you encounter any issues or unintended public access to your Lambda functions despite following the policy guidelines, consider the following troubleshooting steps:
Verify Function Settings:
Check Lambda Execution Role:
Test Network Connectivity:
Review VPC and Subnet Configuration:
Audit IAM Policies:
Example Policy Code:
Here is an example IAM policy code snippet that can be attached to your Lambda function's execution role. Modify the resource ARN and other attributes according to your specific requirements:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Deny", "Action": [ "lambda:InvokeFunction" ], "Resource": "arn:aws:lambda:region:account-id:function:function-name", "Condition": { "IpAddress": { "aws:SourceIp": [ "0.0.0.0/0" ] } } } ] }
Note: The example policy code denies invocation of the Lambda function from any IP address (0.0.0.0/0). Modify the
region
, account-id
, and function-name
parameters to match your specific setup.Remediation Steps:
If your Lambda function does not comply with the policy and public access is enabled, follow these steps to remediate the issue:
By following these steps, you can ensure that your Lambda functions adhere to the policy and prevent unauthorized public access, enhancing the security of your AWS environment.