| name | cis-aws-compute-12.6 |
| description | Ensure Lambda functions are not exposed to everyone |
| category | cis-compute |
| version | 1.1.0 |
| author | cyberstrike-official |
| tags | ["cis","aws","compute","lambda","serverless","public-access","permissions","resource-policy"] |
| cis_id | 12.6 |
| cis_benchmark | CIS AWS Compute Services Benchmark v1.1.0 |
| tech_stack | ["aws"] |
| cwe_ids | [] |
| chains_with | ["cis-aws-compute-12.4","cis-aws-compute-12.9","cis-aws-compute-12.10"] |
| prerequisites | [] |
| severity_boost | {} |
Ensure Lambda functions are not exposed to everyone
Description
A publicly accessible Amazon Lambda function is open to the public and can be reviewed by anyone. To protect against unauthorized users that are sending requests to invoke these functions they need to be changed so they are not exposed to the public.
Rationale
Allowing anyone to invoke and run your Amazon Lambda functions can lead to data exposure, data loss, and unexpected charges on your AWS bill.
Impact
Restricting public access may break existing integrations that rely on anonymous invocation of Lambda functions.
Audit Procedure
Using AWS Console
- Login to the AWS Console using https://console.aws.amazon.com/lambda/.
- In the left column, under
AWS Lambda, click Functions.
- Under
Function name click on the name of the function that you want to review
- Click the Configuration tab
- In the left column, click
Permissions.
- In the
Resource-based policy section, click View policy document
- Review the Resource-based policy document box. Find the "Principal" element defined for each policy statement and check the element value. If the element has one of the following values: "" or { "AWS": "" }, it means it is set to "Allow", and if it does not contain a "Condition" clause to filter the access, the selected Amazon Lambda function is set to anonymous access.
- If any of the Lambda functions have anonymous access set refer to the remediation below.
- Repeat steps 2 - 7 for each Lambda function available within the current AWS region.
- Repeat this Audit for all the other AWS regions.
Using AWS CLI
- Run
aws lambda list-functions
aws lambda list-functions --output table --query "Functions[*].FunctionName"
This command will provide a table titled ListFunctions
- Run
aws lambda get-policy
aws lambda get-policy --function-name "name_of_function" --output text --query "Policy"
This will provide an output of the policy assigned to that function.
- Find the "Principal" element defined for that function. If the element has one of the following values: "" or { "AWS": "" }, it means it is set to "Allow", and if it does not contain a "Condition" clause to filter the access, the selected Amazon Lambda function is set to anonymous access.