Auto-defend serverless functions
Serverless auto-defend lets you automatically add the Serverless Defender to the AWS Lambda functions deployed in your account.
Prisma Cloud uses the AWS API to deploy the Serverless Defender as a Lambda layer based on the auto-defend rules.
It is an additional option for deploying the Serverless Defender, on top of manually adding it as a dependency or adding it as a Lambda layer.
Serverless auto-defend supports the following runtimes:
- Node.js 12.x, 14.x
- Python 3.6, 3.7, 3.8, 3.9
- Ruby 2.7
Limitations
- Auto-protect is implemented with a layer.
- AWS Lambda has a limit of five layers per function. If your functions have mutiple layers, and they might exceed the layer limit with auto-defend, consider protecting them with the embedded option.
- Prisma Cloud doesn’t support defending (or scanning) AWS Lambda functions that are deployed as container images at the time of creating a function in your AWS account.
Required permissions
Prisma Cloud needs the following permissions to automatically protect Lambda functions in your AWS account.
Add the following policy to an IAM user or role:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "PrismaCloudComputeServerlessAutoProtect", "Effect": "Allow", "Action": [ "lambda:PublishLayerVersion", "lambda:UpdateFunctionConfiguration", "lambda:GetLayerVersion", "lambda:GetFunctionConfiguration", "iam:SimulatePrincipalPolicy", "lambda:GetFunction", "lambda:ListFunctions", "iam:GetPolicyVersion", "iam:GetRole", "iam:ListRolePolicies", "iam:ListAttachedRolePolicies", "iam:GetRolePolicy", "iam:GetPolicy", "lambda:ListLayerVersions", "lambda:ListLayers", "lambda:DeleteLayerVersion", "kms:Decrypt", "kms:Encrypt", "kms:CreateGrant" ], "Resource": "*" } ] }
Serverless auto-defend rules
To secure one or multiple AWS Lambda functions using serverless auto-defend:
- Define a serverless protection runtime policy.
- Define a serverless WAAS policy.
- Add a serverless auto-defend rule.
Defining your runtime protection policy
By default, Prisma Cloud ships with an empty serverless runtime policy.
An empty policy disables runtime defense entirely.
You can enable runtime defense by creating a rule.
By default, new rules:
- Apply to all functions (*), but you can target them to specific functions by function name.
- Block all processes from running except the main process. This protects against command injection attacks.
When functions are invoked, they connect to Compute Console and retrieve the latest policy.
To ensure that functions start executing at time=0 with your custom policy, you must predefine the policy.
Predefined policy is embedded into your function along with the Serverless Defender by way of the TW_POLICY environment variable.
- Log into Prisma Cloud Console.
- Go toDefend > Runtime > Serverless Policy.
- ClickAdd rule.
- In theGeneraltab, enter a rule name.
- (Optional) InScope, target the rule to specific functions.Create a new collection.
- Set the rule parameters in theProcesses,Networking, andFile Systemtabs.
- ClickSave.
Defining your serverless WAAS policy
Prisma Cloud lets you protect your serverless functions against application layer attacks by utlizing the serverless Web Application and API Security (WAAS).
By default, the serverless WAAS is disabled.
To enable it, add a new serverless WAAS rule.
- Log into Prisma Cloud Console.
- Go toDefend > WAAS > Serverless.
- ClickAdd rule.
- In theGeneraltab, enter a rule name.
- (Optional) InScope, target the rule to specific functions.Create a new collection. In theFunctionsfield, enter a function name. Use pattern matching to refine how it’s applied.
- Set the protections you want to apply (SQLi,CMDi,Code injection,XSS,LFI).
- ClickSave.
Add a serverless auto-defend rule
The serverless auto-defend rules let you specify which functions you want to protect.
When defining a specific rule you can reference the relevant credential, regions, tags, function names and runtimes.
Each auto-defend rule is evaluated separately.
- Open Compute Console, and go toManage > Defenders > Deploy > Serverless auto-defend.
- Click onAdd rule.
- In the dialog, enter the following settings:
- Enter a rule name.
- InProvider- only AWS is supported.
- Specify the scope.The available resources for scope are:
- Functions- either specific names or prefix.
- Labels- allows specifying either regions (format - region:REGION_NAME) or AWS tags (format - KEY:VALUE).
- Specify the Console name.
- Specify the runtimes.
- Select or create credentials so that Prisma Cloud can access your account.