David Cowen pointed out that the EBS API does not log to Cloud Trail that creates a risk of undetected access to sensitive data inside a snapshot.
Daily Blog #675: The curious case of cloud trail and AWS EBS Block API access
To continue taking advantage of the AWS native forensic acquisition capabilities, we need a solution to detect direct API access to EBS Snapshot content.
SNAPSHOT 4N6IR IMAGER OPTION
First, we need the Cloud Trail logs in a location that can be monitored and generate alerts for these IAM events.
The Elastic Block Store service specifically has these three actions to write rules to detect.
Second, we need to audit our AWS accounts to make sure these permissions do not exist already.
Third, we need a way to detect the usage of the EBS permissions in our accounts.
One option is to use AWS Config with Global Resources included that covers IAM assuming its enabled.
I needed another option as my goal is to keep Snapshot 4n6ir Imager available as a stand-alone option for incident responders without dependencies. I decided to use the AWS Security Token Service (STS) and restricted IAM permissions to create detection boundaries for the usage of the EBS permissions.
IDENTITY ACCESS MANAGEMENT
The location from where you execute the Snapshot 4n6ir Imager python script needs the following STS policy permissions available.
Now create a policy with the following Elastic Block Store permissions. Resources have the option to limit to specific ARNs of snapshots under investigation. You can also create request conditions that limit policy access to a specific IP address or CIDRs.
Finally, create a user role with the AWS account number where the snapshot needs imaging with a unique External ID defined that has the EBS policy attached.
The Maximum CLI/API session duration needs to be expanded from the default 15 minutes up to 12 hours to cover the imaging time requirements.
Now when the Snapshot 4n6ir Imager python script assumes the role with EBS access, it generates an ‘AssumeRole’ event in Cloud Trails for monitoring and detection.
An encrypted EBS volume generates KMS events in Cloud Trail that associates the Role Session Name from STS as the username with this method too.
Hopefully, Amazon can add EBS API logging to Cloud Trail natively soon!
Recently I added options to take advantage of the list_changed_blocks() method from the direct API access to Elastic Block Store (EBS) Snapshot content. It is providing the investigator with the blocks that have changed from the base to the current snapshot. The Snapshot 4n6ir Imager now outputs a change log to a text file in the root of the execution directory.
$ cat snap-0257fc4fc73cb27f2_changelog.txt |----------|-------|------| |blockindex|offset |length| |----------|-------|------| |0 |0 |524288| |2 |1048576|524288| |4 |2097152|524288| |5 |2621440|524288| ...
Another feature that was needed was the ability to download a single block that failed the verification check. The list_snapshot_blocks() method would only allow me to pull a minimum of at least 100 block indexes that requires me to break the loop that starts at the required block.
$ python3 Snapshot-4n6ir-Imager.py --region us-east-2 --snapshot snap-0de67428c1be121f4 --single --block 0 Snapshot 4n6ir Imager v0.2.0 Region: us-east-2 Snapshot: snap-0de67428c1be121f4 Completed!
$ wget https://cloud.4n6ir.com/scripts/Snapshot-4n6ir-Imager.py.gz $ wget https://cloud.4n6ir.com/scripts/Snapshot-4n6ir-Imager.sha256.txt $ gunzip Snapshot-4n6ir-Imager.py.gz $ shasum -a 256 Snapshot-4n6ir-Imager.py f923db2cf22270e775856b11ed9ac2ad7acab89fa77ca36c6b8481233c54234e Snapshot-4n6ir-Imager.py
$ wget https://cloud.4n6ir.com/scripts/Snapshot-4n6ir-Imager-for-Docker.py.gz $ wget https://cloud.4n6ir.com/scripts/Snapshot-4n6ir-Imager-for-Docker.sha256.txt $ gunzip Snapshot-4n6ir-Imager-for-Docker.py.gz $ shasum -a 256 Snapshot-4n6ir-Imager-for-Docker.py 5d45e0ecdadb2ead94ffde9c5d02192d05326692d9c8570b1ff4694293092e0c Snapshot-4n6ir-Imager-for-Docker.py