Basic Steps involved:
-
Create a S3 bucket
-
Configure a Cloud trail to dump logs into the created S3 bucket
-
Configure a user in a user group[for better organization].
-
Create a policy and attach it to the created user-group to access the s3 bucket.
-
Configure a role to access bucket
-
Configure user to assume role to access bucket
-
Installing Boto3 in wazuh to use aws sdk.
-
Configure wazuh to use the user and role created to read the s3 bucket.
Steps in Detail:
Creating a S3 bucket
- Just create a bucket with default permissions no requirements additional here
Configure a Cloud trail to dump logs into the created S3 bucket
-
Create a new Cloud trail by going to the following page: Management & Governance > CloudTrail and clicking create a new trail.
-
Specify the trail name, and choose existing s3 bucket for storage location.
-
Choose relevant logs that needs to be logged into wauzh, which is divided into Management, Data and Insights events.
-
Specify the filters for relavent events.
-
Review and Create the trail
Configure a user and usergroup to access the s3 bucket
-
Create a AWS User-group in the IAM
-
Create a User attached to the User Group Created
-
Then go to Security credentials, scroll down to Access keys, and click Create access key.
-
Select and confirm the Command Line Interface (CLI) use case and click Next
-
Create the key, save that key and id as it will be required in upcoming set
Create a policy and attach it to the created user-group
-
Click Policies > Create policy
-
Switch to JSON Editor
-
Add the required resources and Action in it, sample given below:
"Version": "2012-10-17",
"Statement": [
{
"Sid": "GetS3Logs",
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::<WAZUH_AWS_BUCKET>/*",
"arn:aws:s3:::<WAZUH_AWS_BUCKET>"
]
}
]
}
-
Confirm and create the policy.
-
Go the User group created
-
Navigate to Permissions , click on Add permissions, then Attach policies.
-
Search the policy created and attach it to the group.
-
Review and confirm it.
Configure a role for user to assume
-
Go to Roles on the left side of the AWS console in IAM and click Create role.
-
Choose AWS service as Trusted entity type, S3 as service and Use case then click Next.
-
Choose the previously created policy as permission.
-
Add the Created User’s ARN number as the following format: ‘AWS’:'
' under Principal in Trust Policy -
Review and create the role.
-
Go to the Policy Created and edit the Permissions as follows:
-
Add the sys:AssumeRolepermission under Actions
-
Add the ARN of the Created Role under Resource
-
Copy and store the ARN of the create Role.
Installing Boto3 in wazuh to use aws sdk.
-
Install python3 and pip3 if they are not present
-
pip3 install --upgrade pip -
Run a. in case the python version is
<3.10, b. in case of python version>3.11a.
pip3 install boto3==1.34.135 pyarrow==14.0.1 numpy==1.26.0b.
pip3 install --break-system-packages boto3==1.34.135 pyarrow==14.0.1 numpy==1.26.0
Configure wazuh to use the user and role created to read the s3 bucket.
- Create a file in the root home directory /root/.aws/credentials with the Values of the user created in the following format:
[default] aws_access_key_id=<Access Key ID> aws_secret_access_key=<Secret Access Key> region=us-east-1 - Add the following into ossec.conf:
<ossec_config> <bucket type="cloudtrail"> <name><WAZUH_AWS_BUCKET></name> <aws_profile>default</aws_profile> <iam_role_arn><ARN of Role Created></iam_role_arn> </bucket> </ossec_config> - Restart the wazuh manager service using systemctl restart wazuh-manager
Demo
TBD
Sayonara