Skip to main content

Triage and Remediation

Remediation

Using Console

To remediate the misconfiguration of unencrypted CloudTrail logs in AWS, follow these steps:
  1. Login to the AWS Management Console.
  2. Navigate to the CloudTrail service page.
  3. Select the trail that you want to modify, and click on “Edit” button.
  4. In the “Advanced” section, enable the “Enable log file encryption” option.
  5. Choose the AWS KMS key that you want to use for encryption.
  6. Click on “Save” button to save the changes.
Once the above steps are completed, the CloudTrail logs will be encrypted with the specified AWS KMS key. This will ensure that the logs are secure and protected from unauthorized access.

To remediate the misconfiguration of unencrypted AWS CloudTrail logs using AWS CLI, follow the below steps:
  1. Open the AWS CLI on your local machine and run the following command to enable CloudTrail log encryption:
Replace <trail_name> with the name of the CloudTrail trail that you want to encrypt, and <kms_key_id> with the ID of the KMS key that you want to use for encryption.
  1. Verify that CloudTrail log encryption is enabled by running the following command:
Replace <trail_name> with the name of the CloudTrail trail that you want to verify.
  1. Check the AWS CloudTrail console to ensure that the CloudTrail logs are being encrypted.
By following these steps, you can remediate the misconfiguration of unencrypted AWS CloudTrail logs using AWS CLI.
To remediate the misconfiguration of unencrypted CloudTrail logs in AWS using Python, you can follow these steps:
  1. First, you need to check if CloudTrail logs are encrypted or not. For this, you can use the AWS SDK for Python (Boto3) and run the following code:
  1. If the CloudTrail logs are not encrypted, you need to create a KMS key and enable encryption for CloudTrail. You can use the following code to create a KMS key and enable encryption for CloudTrail:
  1. Once CloudTrail encryption is enabled, you can verify that the logs are encrypted by running the first code snippet again.
Note: Make sure that you have the necessary IAM permissions to create KMS keys and update CloudTrail configurations.
Updating an existing aws_cloudtrail to set kms_key_id is an in-place change and should not replace the trail, but it will cause new log files to be written encrypted with this KMS key; ensure no conflicting encryption settings exist on the S3 bucket policy.To verify, terraform plan should show:
  • aws_kms_key.cloudtrail_logs being created, and
  • aws_cloudtrail.this updated in-place with kms_key_id changing from null (or a different key) to the ARN of aws_kms_key.cloudtrail_logs.