Skip to main content

Triage and Remediation

Remediation

Using Console

Sure, here are the step-by-step instructions to remediate the issue of CloudTrail Logging Bucket Should Use MFA Delete Feature in AWS:
  1. Log in to your AWS console.
  2. Navigate to the S3 service.
  3. Find the S3 bucket that is being used for CloudTrail logging.
  4. Click on the bucket name to open its properties.
  5. Click on the Permissions tab.
  6. Scroll down to the “Bucket Policy” section.
  7. Click on “Edit”.
  8. Add the following JSON code to the Bucket Policy:
  1. Replace “your-bucket-name” with the actual name of your S3 bucket.
  2. Click on “Save Changes” to update the Bucket Policy.
This will add a DenyDeleteWithoutMFA policy statement to the bucket policy, which will prevent any deletion of objects or modification of bucket policies without MFA authentication.

To remediate the misconfiguration “CloudTrail Logging Bucket Should Use MFA Delete Feature” for AWS using AWS CLI, follow these steps:
  1. Enable versioning for the S3 bucket where CloudTrail logs are stored by running the following command:
  1. Create a new IAM policy that grants permission to delete objects from the S3 bucket only if MFA authentication is provided. You can use the following policy as an example:
  1. Create a new IAM policy that grants permission to update the bucket policy to require MFA authentication for object deletions. You can use the following policy as an example:
  1. Create a new IAM role that can assume the policy created in step 3 and attach the policy created in step 2 to it. You can use the following command to create the role:
where “trust-policy.json” contains the following:
  1. Update the bucket policy to require MFA authentication for object deletions by running the following command:
where “bucket-policy.json” contains the following:
  1. Launch an EC2 instance with the IAM role created in step 4 and run the following command to delete the existing CloudTrail logging bucket policy:
  1. Finally, run the following command to update the CloudTrail logging bucket policy to require MFA authentication for object deletions:
where “cloudtrail-policy.json” contains the following:
After following these steps, the CloudTrail logging bucket should be configured to require MFA authentication for object deletions.
To remediate the misconfiguration of CloudTrail Logging Bucket Should Use MFA Delete Feature in AWS using Python, you can follow the below steps:
  1. Import the necessary libraries:
  1. Define the name of the S3 bucket that you want to remediate:
  1. Create an S3 client:
  1. Check if MFA delete is enabled for the bucket:
  1. If MFA delete is not enabled, enable it:
  1. Configure MFA delete for the bucket:
Note: Replace ‘your-bucket-name’ and ‘your-mfa-serial-number’ with the actual values of your S3 bucket name and MFA serial number respectively.
Terraform cannot enable S3 MFA Delete for a CloudTrail logging bucket, because AWS requires the root user’s MFA token for this operation and the AWS provider does not expose an argument to set MFADelete=Enabled.To remediate, you must follow the AWS Console or CLI steps (as in your verified command aws s3api put-bucket-versioning ... --versioning-configuration '{"MFADelete":"Enabled","Status":"Enabled"}' --mfa "ROOT_MFA_ARN CURRENT_TOKEN") using the account root user with MFA; this change cannot be expressed or enforced directly in Terraform.