Documentation
README
Ensure Lambda functions do not allow unknown cross account access via permission policies
Description
Ensure that all your Amazon Lambda functions are configured to allow access only to trusted AWS accounts in order to protect against unauthorized cross-account access.
Rationale
Allowing unknown (unauthorized) AWS accounts to invoke your Amazon Lambda functions can lead to data exposure and data loss. To prevent any unauthorized invocation requests for your Lambda functions, restrict access only to trusted AWS accounts.
Impact
Restricting cross-account access may break existing integrations with partner or trusted accounts. Ensure all legitimate cross-account relationships are documented before restricting access.
Audit Procedure
Using AWS Console
- Login to the AWS Console using https://console.aws.amazon.com/lambda/.
- In the left column, under
AWS Lambda, clickFunctions. - Under
Function nameclick 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 statementssection, clickView policy document - Review the Resource-based policy document box. Find the "Principal" element and check the element value (ARN).
- Confirm that each AWS account ARN is an approved AWS account. If one or more of the ARNs is not an AWS account defined within your organization, refer to the remediation below.
- Repeat steps no. 2-8 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-policyon the functions listed
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.
- Identify the "Principal" element for each function for the ARN.
- Confirm that each AWS account ARN is an approved AWS account. If one or more of the ARNs is not an AWS account defined within your organization, refer to the remediation below.
- Repeat steps 2-5 for each Lambda function available.
- Run the Audit in the other AWS cloud regions.
Expected Result
All Lambda function resource-based policies contain only Principal ARNs belonging to trusted and approved AWS accounts within the organization.
Remediation
Using AWS Console
- Login to the AWS Console using https://console.aws.amazon.com/lambda/.
- In the left column, under
AWS Lambda, clickFunctions. - Under
Function nameclick 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 statementssection, select the policy statement that allows the unknown AWS Account cross-account access - Click Edit
- On the
Edit permissionspage, replace or remove the AWS Account(s) ARN of the unauthorized principal in the Principal box - Click Save
- Repeat steps for each Lambda function that failed the Audit
Using AWS CLI
N/A - This control is Console-based remediation only.
Default Value
Lambda functions do not allow cross-account access by default. Cross-account access requires explicit configuration of resource-based policies.
References
CIS Controls
| Controls Version | Control | IG 1 | IG 2 | IG 3 |
|---|---|---|---|---|
| v8 | 6.8 Define and Maintain Role-Based Access Control - Define and maintain role-based access control, through determining and documenting the access rights necessary for each role within the enterprise to successfully carry out its assigned duties. Perform access control reviews of enterprise assets to validate that all privileges are authorized, on a recurring schedule at a minimum annually, or more frequently. | x | ||
| v7 | 1.7 Deploy Port Level Access Control - Utilize port level access control, following 802.1x standards, to control which devices can authenticate to the network. | x | x |
Profile
Level 1 | Manual