Lesson 6 of 6 Data Integrity, Backup and Retention

Proving Integrity with Code and Data Signing

This lesson explains how signing code and data proves who produced it and that it has not changed, and how enforcement rejects anything unsigned, defending against supply chain attacks.

Learning outcomes

After completing this lesson, you will be able to:

  • Identify the AWS signing services and what each signs.
  • Enforce signed Lambda code with a code signing configuration.
  • Describe how container images are signed and verified.

Signing services

A digital signature proves that code or data has not been altered and comes from the expected source. AWS Signer signs Lambda deployment packages and, through the open-source Notation tool, container images. Lambda code signing configurations and admission controllers in Kubernetes can then reject unsigned or altered code at deployment. KMS asymmetric keys sign your own data and documents with the Sign API and check them with Verify, or outside AWS with the public key. CloudTrail log file validation produces signed digest files that prove whether log files were modified or deleted after delivery. The following table summarises the services.

ServiceSigns
AWS SignerLambda packages, and container images through Notation, for verification at deployment
KMS asymmetric keysYour own data and documents, with Sign and Verify
CloudTrail log file validationDigest files that prove log integrity
Match the pairs

What signs what

Exam skills 5.2.2

Match each signing service with what it signs.

Log in to try this activity Interactive activities are free with an account.

Enforcing signed Lambda code

Code signing ensures that only code produced by a trusted pipeline runs in production. If an attacker, or a developer bypassing the pipeline, uploads a modified deployment package, the signature does not match and the deployment is rejected. For AWS Lambda, signing uses AWS Signer, and enforcement uses a code signing configuration attached to each function. The following list describes how enforcement works.

  • A signing profile in AWS Signer signs packages in the pipeline.
  • A code signing configuration names the allowed signing profiles.
  • With the policy set to Enforce, Lambda rejects unsigned, expired or tampered packages; Warn only logs.
  • An SCP condition on lambda:CodeSigningConfigArn can require code signing on every function.

The following diagram compares a Lambda package signed by the pipeline with an unsigned upload under code signing.

Code signing for Lambda. The pipeline signs each package with an AWS Signer profile, and a code signing configuration with the Enforce policy allows only that profile's signatures, so an unsigned zip uploaded from a laptop is rejected. An SCP condition can require a configuration on every function.
The scenario is illustrative.
True or false

Enforcing signed Lambda code

Exam skills 5.2.2 · 3.2.6

Check how Lambda code signing is enforced.

Log in to try this activity Interactive activities are free with an account.

Signing container images

Container images can be tampered with in the same way as Lambda packages, for example by pushing a modified image with the same tag. Images signed with AWS Signer and the open-source Notation tool carry signatures stored alongside the image in Amazon ECR. The signature can be verified at deployment, for example by an admission controller such as Kyverno or Gatekeeper in Amazon EKS, so only images built and signed by the pipeline run in production.

Worked example

Only signed code may run in Lambda

After a supply-chain incident, the company requires that only code built by its pipeline can be deployed to Lambda. A signing profile signs packages in the pipeline, and a code signing configuration with the Enforce policy rejects anything else:

PROFILE_ARN=$(aws signer put-signing-profile --profile-name pipeline_lambda \
  --platform-id AWSLambda-SHA384-ECDSA --query profileVersionArn --output text)

CSC_ARN=$(aws lambda create-code-signing-config \
  --allowed-publishers SigningProfileVersionArns=$PROFILE_ARN \
  --code-signing-policies UntrustedArtifactOnDeployment=Enforce \
  --query CodeSigningConfig.CodeSigningConfigArn --output text)
aws lambda put-function-code-signing-config --function-name payments --code-signing-config-arn $CSC_ARN

# In the pipeline
aws signer start-signing-job --profile-name pipeline_lambda \
  --source "s3={bucketName=acme-builds,key=payments.zip,version=$ZIP_VERSION_ID}" \
  --destination 's3={bucketName=acme-builds-signed,prefix=payments/}'

A developer uploading an unsigned zip from a laptop now receives an error. An SCP condition on lambda:CodeSigningConfigArn can require that every function in the organisation has a code signing configuration attached.

Check yourself

How can you sign and verify your own data?

Show answer

With KMS asymmetric keys.

Exam Tips

Remember for the exam

  • When Lambda must reject unsigned packages, use Signer with a code signing configuration set to Enforce.
  • Signer also signs container images with Notation.
  • To sign and verify your own data, use KMS asymmetric keys.
  • Require code signing organisation-wide with an SCP on lambda:CodeSigningConfigArn.
  • CloudTrail log file validation proves log integrity.