Check provider logo

Lambda function environment variables are encrypted with a customer-managed KMS key

awslambda_function_env_vars_not_encrypted_with_cmk

Severitymedium
Serviceawslambda
by Prowler

AWS Lambda function environment variables are encrypted at rest using a customer-managed KMS key (CMK) rather than the default AWS-managed Lambda service key.

The presence of a KMSKeyArn on the function configuration indicates CMK-based encryption is active.

Risk

Without a CMK, environment variables are encrypted with an AWS-managed key, removing customer control over rotation, auditing, and revocation.

If variables contain secrets or connection strings, loss of key control weakens confidentiality and can fail compliance requirements (PCI-DSS, HIPAA, FedRAMP) that mandate customer-controlled encryption.

Run this check with Prowler CLI

prowler aws --checks awslambda_function_env_vars_not_encrypted_with_cmk

Recommendation

Encrypt Lambda environment variables with a customer-managed KMS key to maintain full control over key lifecycle and access.

  • Create a dedicated KMS key per application or per function for blast-radius isolation
  • Enable automatic key rotation (EnableKeyRotation: true)
  • Grant only the Lambda execution role decrypt access via a key policy condition on kms:ViaService
  • Prefer AWS Secrets Manager or SSM Parameter Store (SecureString) for secrets — environment variables should hold non-secret configuration only

Remediation

CLI

aws lambda update-function-configuration --function-name <function-name> --kms-key-arn <cmk-arn>

Native IaC
Terraform
Other
  1. Create or identify a KMS CMK in the same region as the function
  2. Grant the Lambda execution role kms:Decrypt and kms:GenerateDataKey on the key
  3. In the Lambda console go to Configuration > Environment variables > Edit
  4. Under Encryption configuration, select your CMK
  5. Save — Lambda re-encrypts all environment variables with the chosen key

Source Code

Resource Type

AwsLambdaFunction

References