This rule ensures Lambda functions have restricted public access to enhance security measures.
Rule | Lambda functions should restrict public access |
Framework | RBI Cyber Security Framework |
Severity | ✔ Critical |
Rule Description
According to the RBI (Reserve Bank of India) Cyber Security Framework, Lambda functions should restrict public access. This means that the Lambda functions should not be accessible to the public or unauthorized users. Public access to Lambda functions can pose security risks and potential breaches, making it crucial to enforce this rule.
Troubleshooting Steps
If you suspect that public access is enabled for a Lambda function, follow the troubleshooting steps below:
Necessary Codes
In the context of restricting public access to Lambda functions, there are code snippets you can use to reinforce this policy. These codes ensure that only authorized entities can invoke the Lambda functions.
Example 1: Restricting Access to VPC
This code snippet restricts the Lambda function to receive requests only from the specified Virtual Private Cloud (VPC) using its ID.
import json
def lambda_handler(event, context):
# Your Lambda function code here
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda!')
}
To implement this code:
lambda_handler
function.Example 2: Restricting Access Based on IP Addresses
This code snippet restricts the Lambda function to receive requests only from specified IP addresses or IP address ranges.
import json
def lambda_handler(event, context):
# Retrieve the source IP address from the event
source_ip = event['requestContext']['identity']['sourceIp']
# Allowed IP address list or ranges
allowed_ips = ['192.168.0.0/24', '10.0.0.0/16']
# Check if the source IP address is in the allowed list
if source_ip not in allowed_ips:
return {
'statusCode': 403,
'body': json.dumps('Access denied')
}
# Your Lambda function code here
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda!')
}
To implement this code:
lambda_handler
function.allowed_ips
list to include the desired IP addresses or ranges.Step-by-Step Guide for Remediation
If you need to restrict public access for a Lambda function according to the RBI Cyber Security Framework, follow these step-by-step instructions:
By following these steps, you can effectively restrict public access for Lambda functions, aligning with the RBI Cyber Security Framework requirements. Remember to regularly review and update the Lambda function's configuration to ensure ongoing compliance.