Chapter 7. Running and Securing Serverless Functions in a VPC
In the preceding chapter, you explored how attackers can exploit vulnerable Lambda functions to execute arbitrary code, exfiltrate environment variables from the function’s execution environment via outbound network access, and retrieve secrets from AWS Secrets Manager. One effective way to prevent this from happening is to block outbound connections and protect your Lambda function against data exfiltration through a VPC with restrictive network controls. By doing so, attackers cannot leverage techniques that rely on outbound connectivity, such as sending stolen environment variables, secrets, or other sensitive data to external servers. Even if an attacker successfully exploits a code injection vulnerability, their ability to exfiltrate data is significantly reduced.
To help you learn how to configure Lambda functions within a VPC with restrictive network controls, this chapter is divided into the following sections:
-
“Updating the Lambda Function Execution Role with the Required VPC Permissions”
-
“Setting Up and Configuring a VPC with Restricted Outbound Access”
-
“Attaching the Lambda Function to the VPC with Restricted Outbound Access”
-
“Setting Up an API Gateway REST API That Routes Requests to the Lambda Function”
-
“Updating the S3-Hosted Website to Use the API Gateway Endpoint URL”
-
“Verifying That Code Injection Attacks Attempting Outbound Access No Longer Work”
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access