Sub topic 8
Validating log file integrity
This chapter assumes you can create a trail that delivers to S3 and run AWS CLI commands. It also assumes you know basic IAM permissions. Logs are only useful as evidence if you can show nobody changed them. Log file integrity validation lets you check that.
What validation protects against
An attacker who gains access to your account may try to hide their tracks by editing or deleting log files in the S3 bucket. Validation detects three kinds of tampering:
- A log file was modified after delivery.
- A log file was deleted.
- A digest file was modified or deleted.
Validation does not stop tampering, and it does not prove that an event is accurate. It only proves that a file is the same as when CloudTrail delivered it.
How it works
When you turn on validation for a trail, CloudTrail starts writing a digest file about once an hour. A digest file lists every log file delivered in that hour, with the SHA-256 hash of each one. CloudTrail signs the digest with a private key that belongs to the Region, using SHA256withRSA. It also stores the signature of the previous digest inside each new digest. This links the digests into a chain, so removing one digest breaks the link.
Digest files go into the same bucket as the logs, under a separate prefix:
AWSLogs/123456789012/CloudTrail-Digest/us-east-1/2026/11/20/Turning validation on
Validation is a trail setting. Set it when you create the trail, or change an existing trail:
aws cloudtrail update-trail \
--name org-audit-trail \
--enable-log-file-validationValidation covers only the period after you enable it. Files delivered earlier have no digests and cannot be checked.
Running a validation
Use validate-logs with the trail ARN and a time range:
aws cloudtrail validate-logs \
--trail-arn arn:aws:cloudtrail:us-east-1:123456789012:trail/org-audit-trail \
--start-time 2026-11-01T00:00:00Z \
--end-time 2026-11-20T00:00:00Z \
--verboseWithout --end-time, the command checks up to the current time. The --verbose flag prints a line for each file, which helps when something fails. The summary looks like this:
Results requested for 2026-11-01T00:00:00Z to 2026-11-20T00:00:00Z
Results found for 2026-11-01T00:00:00Z to 2026-11-20T00:00:00Z:
456/456 digest files valid
3120/3120 log files validThe identity you run this with needs cloudtrail:GetTrail and cloudtrail:ListPublicKeys, plus s3:ListBucket and s3:GetObject on the bucket.
Reading failures
| Message | Likely meaning |
|---|---|
| Log file hash mismatch | The log file was changed after delivery. |
| Log file not found | The log file was deleted or moved. |
| Digest file signature invalid | The digest was changed, or the key lookup failed. |
| No digest files found | Logging was stopped, validation was not enabled, or the digests were deleted. |
| Digest chain broken | A digest in the sequence is missing. |
A failure does not always mean an attack. Lifecycle rules, manual moves, or copying logs to another bucket also produce errors. Check these first. If the trail was deleted or the logs were moved, pass --s3-bucket and --s3-prefix so the command looks in the right place.
A routine
- Enable validation on every trail you depend on for audits.
- Run
validate-logson a schedule, for example daily over the last 24 hours, and alert on any non-zero failure count. - Run it over the full affected period at the start of any investigation, before you trust the events you read.
Exercise
A colleague moved last month's CloudTrail log files to an archive bucket. validate-logs now reports "Log file not found" for many files. Does this prove an attacker deleted them, and what would you do?
Show answer
No. The command looks for the files at their original delivery location, so a manual move produces the same error as a deletion. Check whether the files exist in the archive bucket. If they do, rerun validate-logs with --s3-bucket and --s3-prefix pointing at the new location. If they are missing there too, treat it as possible tampering and investigate.