Documentation
README
Ensure that Code Signing is enabled for Lambda functions
Description
Ensure that all your Amazon Lambda functions are configured to use the Code Signing feature in order to restrict the deployment of unverified code.
Rationale
Code Signing, ensures that the function code is signed by an approved (trusted) source, and that it has not been altered since signing, and that the code signature has not expired or been revoked.
Impact
Enabling code signing adds an additional step to the deployment process. All code packages must be signed before deployment, which may slow down CI/CD pipelines.
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
Configurationtab - Under General configuration on the left column, click
Code signing. - Under the
Code signing configurationsection check for any code signing configurations created for the function. - If there are no code signing configurations available or listed is not enabled, refer to the remediation.
- Repeat steps 2-7 for each Lambda function within the current region.
- Then repeat the Audit process for all other 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-function-code-signing-config
aws lambda get-function-code-signing-config --function-name "name_of_function" --query "CodeSigningConfigArn"
- The command output should return an array with the requested ARN(s).
- If the get-function-code-signing-config command output returns null, there are no code signing configurations for the Lambda function.
- Refer to the remediation below.
- Repeat step 2-5 for each Lambda function available in the selected AWS region.
- Perform the Audit process for all other regions used.
Expected Result
Each Lambda function has a code signing configuration with a valid CodeSigningConfigArn associated.
Remediation
Using AWS Console
- Login to the AWS console using https://console.aws.amazon.com/signer
- Click on
Create Signing Profileif none are set up. If you already have some created in the left panel click onSigning Profiles,Create Signing Profile. ***Note a Signing Profile is a trusted publisher and is analogous to the use of a digital signing certificate to generate signatures for your application code. - On the
Create Signing Profilesetup page provide:- Profile name
- Specify the Signature Validity period (6 months up to 12 months is recommended)
- Click on
Create Profile - Go to the Amazon Lambda console https://console.aws.amazon.com/lambda/.
- In the left panel, under Additional resources, click on
Code signing configurations. - Click on
Create configuration - On the
Create code signing configurationsetup page:- Description box - provide a short description to identify this configuration
- Click inside the
Signing profile version ARNbox and select the Signing Profile created above. - For
Signature validation policy, click the signature validation policy suitable for your Lambda function. **Note - A signature check can fail if the code is not signed by an allowed Signing Profile, or if the signature has expired or has been revoked. - Click Enforce - blocking the deployment of the code and also issue a warning.
- Click
Create configuration
- Go to the Amazon Lambda console https://console.aws.amazon.com/lambda/.
- Click Functions.
- Under Function name click on the name of the function that you want to review
- Click the Configuration tab
- In the left menu click Code signing.
- Click Edit
- On the
Edit code signing, select the code signing configuration created above from the drop down - Click
Save
The Lambda function is now configured to use code signing.
- Next Upload a signed .zip file or provide an S3 URL of a signed .zip made by a signing job in AWS Signer.
- To start a signing job, go to AWS Signer console at https://console.aws.amazon.com/signer.
- In the left panel, click on Signing Jobs.
- Start a Signing Job to generate a signature for your code package and place the signed code package in the specified destination path.
- Start Signing Job setup page:
- Select the Signing Profile created in dropdown list.
- Code asset source location, specify the Amazon S3 location of the code package (.zip file) to be signed. Only S3 buckets available in the current region are displayed and can be used.
- Signature destination path with prefix where the signed code package should be uploaded.
- Start Job to deploy your new Signing Job
- Job status reads Succeeded, you can find the signed .zip package in your assigned S3 bucket.
- Publish the signed code package to the selected Lambda function.
- Amazon Lambda will perform signature checks to verify that the code has not been altered since signing. **Note - The service verifies if the code is signed by one of the allowed signing profiles available.
- Repeat steps for each Lambda function that was captured in the Audit.
Using AWS CLI
N/A - This control is Console-based remediation only.
Default Value
Code Signing is not enabled by default for Lambda functions.
References
CIS Controls
| Controls Version | Control | IG 1 | IG 2 | IG 3 |
|---|---|---|---|---|
| v8 | 2.7 Allowlist Authorized Scripts - Use technical controls, such as digital signatures and version control, to ensure that only authorized scripts, such as specific .ps1, .py, etc., files, are allowed to execute. Block unauthorized scripts from executing. Reassess bi-annually, or more frequently. | x | ||
| v8 | 10.2 Configure Automatic Anti-Malware Signature Updates - Configure automatic updates for anti-malware signature files on all enterprise assets. | x | x | x |
| v7 | 5.3 Securely Store Master Images - Store the master images and templates on securely configured servers, validated with integrity monitoring tools, to ensure that only authorized changes to the images are possible. | x | x | |
| v7 | 8.2 Ensure Anti-Malware Software and Signatures are Updated - Ensure that the organization's anti-malware software updates its scanning engine and signature database on a regular basis. | x | x | x |
Profile
Level 1 | Manual