Hi Eric,
I did some testing this morning, and I'm not having any issues using the AWS wodle to gather/parse encrypted CloudTrail logs. I think the problem you faced may be that CloudTrail is configured to use KMS to encrypt the logs, but the IAM user/role that Wazuh is configured to use to pull down the CloudTrail logs from the S3 bucket does not have sufficient access to the KMS key.
In my testing environment, I used the 'Create a new KMS key' from within the CloudTrail config:
If you look at the key policy that gets defined for this KMS key, it is fairly permissive, but there is an important permission in the statement. This allows any users within the account to decrypt the files:
{
"Sid": "Allow principals in the account to decrypt log files",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": [
"kms:Decrypt",
"kms:ReEncryptFrom"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"kms:CallerAccount": "123412341234"
},
"StringLike": {
"kms:EncryptionContext:aws:cloudtrail:arn": "arn:aws:cloudtrail:*:123412341234:trail/*"
}
}
}
In my testing environment, I'm assuming an IAM Role in the AWS Account with the access to list/get objects from the S3 bucket for CloudTrail, so it has access to the key.
If I remove this statement from the key policy, the wodle starts failing:
DEBUG: {"aws": {"log_info": {"s3bucket": "myTestBucket", "aws_account_alias": "test-encrypted", "log_file": "AWSLogs/123412341234/CloudTrail/ap-southeast-1/2018/10/05/123412341234_CloudTrail_ap-southeast-1_20181005T1520Z_5lk7llR9Hh81Z9Zt.json.gz"}, "aws_account_id": "123412341234"}, "integration": "aws", "error_msg": "Unkown error reading/parsing file AWSLogs/123412341234/CloudTrail/ap-southeast-1/2018/10/05/123412341234-southeast-1_20181005T1520Z_5lk7llR9Hh81Z9Zt.json.gz: An error occurred (AccessDenied) when calling the GetObject operation: Access Denied"}
DEBUG: ++ File previously processed, but reparse flag set: AWSLogs/123412341234/CloudTrail/ap-southeast-1/2018/10/05/123412341234_CloudTrail_ap-southeast-1_20181005T1520Z_D9uESE0MxVcx3Nse.json.gz
DEBUG: ++ Found new log: AWSLogs/123412341234/CloudTrail/ap-southeast-1/2018/10/05/123412341234_CloudTrail_ap-southeast-1_20181005T1520Z_D9uESE0MxVcx3Nse.json.gz
DEBUG: ++ Unkown error reading/parsing file AWSLogs/123412341234/CloudTrail/ap-southeast-1/2018/10/05/123412341234_CloudTrail_ap-southeast-1_20181005T1520Z_D9uESE0MxVcx3Nse.json.gz: An error occurred (AccessDenied) when calling the GetObject operation: Access Denied; skipping..
So I then added back in the following statement to the KMS key policy:
{
"Sid": "Allow Wazuh CloudTrail log parser role access to decrypt files",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::123412341234:role/myWazuhRoleName"
},
"Action": [
"kms:Decrypt",
"kms:ReEncryptFrom"
],
"Resource": "*",
"Condition": {
"StringLike": {
"kms:EncryptionContext:aws:cloudtrail:arn": "arn:aws:cloudtrail:*:123412341234:trail/*"
}
}
}
After adding this statement into the key policy, Wazuh was again able to download the CloudTrail logs...
So double check that the key policy you have defined grants the IAM user/role sufficient access.
Thanks,
Jeremy