End-of-Life (EoL)
Serverless Defender as a Lambda layer
Prisma Cloud Serverless Defenders protect serverless functions at runtime.
Currently, Prisma Cloud supports AWS Lambda functions.
Lambda layers are ZIP archives that contain libraries, custom runtimes, or other dependencies.
Layers let you add reusable components to your functions, and focus deployment packages on business logic.
They are extracted to the /opt directory in the function execution environment.
For more information, see the AWS Lambda layers documentation.
Prisma Cloud delivers Serverless Defender as a Lambda layer.
Deploy Serverless Defender to your function by wrapping the handler and setting an environment variable.
The following runtimes are supported for Serverlerss Defender as a Lambda layer:
- Node.js 10.x, 12.x
- Python 2.7, 3.6, 3.7 and 3.8
Securing serverless functions
To secure an AWS Lambda function with the Serverless Defender layer:
- Download the Serverless Defender Lambda layer ZIP file.
- Upload the layer to AWS.
- Define a serverless protection runtime policy.
- Define a serverless WAAS policy.
- Add the layer to your function, update the handler, and set an environment variable. After completing this integration, Serverless Defender runs when your function is invoked.
Download the Serverless Defender layer
Download the Serverless Defender layer from Compute Console.
- Open Console, then go toManage > Defenders > Deploy.
- Choose the DNS name or IP address that Serverless Defender uses to connect to Console.
- Set the Defender type toServerless.
- Select a runtime.Prisma Cloud supports Lambda layers forNode.jsandPythononly.
- ForDeployment Type, selectLayer.
- Download the Serverless Defender layer. A ZIP file is downloaded to your host.
Upload the Serverless Defender layer to AWS
Add the layer to the AWS Lambda service as a resource available to all functions.
- In the AWS Management Console, go to the Lambda service.
- ClickLayers.
- InName, entertwistlock.
- ClickUpload, and select the file you just downloaded, twistlock_defender_layer.zip
- Select the compatible runtimes:PythonorNode.js.
- ClickCreate.
Defining your runtime protection policy
Prisma Cloud ships with a default runtime policy for all serverless functions that blocks all processes from running except the main process.
This default policy protects against command injection attacks.
You can customize the policy with additional rules.
By default, new rules apply to all functions (*), but you can target them to specific functions by function name.
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) Target the rule to specific functions.
- 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) Target the rule to specific functions.
- Set the protections you want to apply (SQLi,CMDi,Code injection,XSS,LFI).
- ClickSave.
Embed the Serverless Defender
Embed the Serverless Defender as a layer, and run it when your function is invoked. If you are using a deployment framework such as SAM or Serverless Framework you can reference the layer from within the configuration file.
Prerequisites:
- You already have a Lambda function.
- Your Lambda function is written for Node.js 10.x or Python.
- Your function’s execution role grants it permission to write to CloudWatch Logs. Note that theAWSLambdaBasicExecutionRolegrants permission to write to CloudWatch Logs.
- Go to the function designer in the AWS Management Console.
- Click on theLayersicon.
- In theReferenced Layerspanel, clickAdd a layer.
- In theSelect from list of runtime compatible layers, selecttwistlock.
- In theVersiondrop-down list, select1.
- ClickAdd.When you return to the function designer, you’ll see that your function now uses one layer.
- Update the handler for your function to be twistlock.handler.
- Set the TW_POLICY and ORIGINAL_HANDLER environment variable, which specifies how your function connects to Compute Console to retrieve policy and send audits.
- In Compute Console, go toManage > Defenders > Deploy > Single Defender.
- ForDefender type, selectServerless.
- InSet the Twistlock environment variable, enter the function name and region.
- Copy the generatedValue.
- In AWS Console, open your function in the designer, and scroll down to theEnvironment variablespanel.
- ForKey, enter TW_POLICY.
- ForValue, paste the rule you copied from Compute Console.
- For ORIGINAL_HANDLER, this is the original value of handelr for your function before your modification.
- ClickSaveto preserve all your changes.