CloudTrail Organization Trail Auditor
Quick start (decision tree — read first)
Evaluate dimensions in order; the first failing dimension is the verdict.
| # |
Check |
Fail verdict |
Risk |
| 1 |
IsOrganizationTrail: false (from describe-trails) |
NO_ORG_TRAIL |
CRITICAL |
| 2 |
KmsKeyId null/empty (SSE-S3 defaults) |
NO_ENCRYPTION |
CRITICAL |
| 3 |
LogFileValidationEnabled: false |
NO_VALIDATION |
HIGH |
| 4 |
InsightsSelectors: [] (from get-insight-selectors) |
NO_INSIGHTS |
MEDIUM |
| 5 |
IsMultiRegionTrail: false OR CloudWatchLogsLogGroupArn: null OR IncludeGlobalServiceEvents: false OR CW retention < 90 days |
CONFIG_GAP |
MEDIUM |
| 6 |
All above pass |
OK |
LOW |
Pre-flight gate (mandatory): get-trail-status returns IsLogging. If false, append a CRITICAL finding regardless of the verdict, and recommend start-logging.
Invisible dependencies (require extra API calls — surface gaps in FINDINGS, never silently change the verdict): Organizations trusted-service access for cloudtrail.amazonaws.com, S3 bucket-policy s3:x-amz-acl: bucket-owner-full-control ACL, KMS key-policy kms:GenerateDataKey* grant, S3 lifecycle rules on the log and digest prefixes.
Output one block per trail: TRAIL / VERDICT / REASON / FINDINGS / REMEDIATION (see Output format).
Mindset
One-line takeaway: the verdict is the first failing dimension in a
strict order of severity — org coverage → encryption → validation → insights
→ config-gap. A trail that is not an org trail fails the most fundamental
audit gate regardless of how well everything else is configured.
CloudTrail is the forensic bedrock of an AWS account. A misconfigured org
trail does not merely "miss events"; it creates silent blind spots where
attacker actions leave no trace. Step 0 enumerates the non-obvious
CloudTrail behaviors that change classification; Steps 1–6 are the
deterministic first-fail-wins tree.
Pre-flight: trail status gate (run before classification)
Before evaluating trail configuration, verify the trail is actually logging.
A trail with perfect configuration but IsLogging: false collects nothing —
it is the most overlooked audit dimension because describe-trails returns the
config without the status.
| Status field |
Value |
Effect |
IsLogging (get-trail-status) |
true |
Proceed with full audit. |
IsLogging (get-trail-status) |
false |
Trail is STOPPED. This is a CRITICAL finding. Append to FINDINGS: "Trail isLogging=false — no events are being recorded despite configuration. Run aws cloudtrail start-logging --name <trail>." Continue the config audit so all gaps are surfaced, but note the trail is inactive. |
| Status unknown (no get-trail-status provided) |
— |
Proceed but append a WARNING: "Trail logging status not provided — verify with aws cloudtrail get-trail-status --name <trail>. A trail may be correctly configured but silently stopped." |
Multi-trail sweep note: aws cloudtrail describe-trails returns all trails
visible to the caller, but an org trail is only visible in the management
account (or delegated administrator). If the input comes from a member account,
the org trail will NOT appear — verify the caller is in the management account
before concluding NO_ORG_TRAIL.
Malformed-config ERROR block moved verbatim to references/error-handling.md — load on demand.
Process — Classification logic (apply in order, first-fail wins)
Step 0: Expert knowledge — non-obvious CloudTrail behaviors
Step 0 expert knowledge moved verbatim to references/advanced-patterns.md — load on demand.
Step 1: Organization trail check (NO_ORG_TRAIL — CRITICAL)
If IsOrganizationTrail is false or absent, the trail does NOT cover member
accounts. This is the most fundamental gap — an org without an org trail has
no centralized audit visibility into member-account API activity.
Verdict: NO_ORG_TRAIL (CRITICAL risk).
Even if every other dimension (encryption, validation, Insights) is correctly
configured, the trail only logs the account it was created in. Member-account
activity is invisible to the management account's security team.
Edge case — delegated administrator: If the trail was created by a
delegated administrator account (not the management account), the trail is
still an org trail — IsOrganizationTrail: true applies regardless of which
account created it, as long as the org trusted-service access is active.
Step 2: KMS encryption check (NO_ENCRYPTION — CRITICAL)
If IsOrganizationTrail: true (passed Step 1), check KmsKeyId:
KmsKeyId is null, empty, or absent → SSE-S3 (Amazon-managed AES-256)
is the default. This IS encryption, but the key is not customer-controlled.
For compliance frameworks (SOC 2, HIPAA, FedRAMP) requiring customer-managed
keys, this is a finding. Verdict: NO_ENCRYPTION (CRITICAL risk).
KmsKeyId is present → Verify the key is in the same region as the
trail and that the key policy grants CloudTrail service access. If the key
policy is missing the CloudTrail service principal, log delivery will fail
silently — the trail appears active but logs stop appearing in S3. Note as
a WARNING in FINDINGS but do not fail the dimension.
Verify the S3 bucket policy, KMS key policy, and S3 lifecycle rules
(all three are invisible from describe-trails and silently break member-account
log access on org trails). Run these in order; treat any non-conformance as a
CONFIG_GAP finding:
# 1. S3 bucket policy — must allow cloudtrail.amazonaws.com s3:PutObject with
# Condition StringEquals s3:x-amz-acl == bucket-owner-full-control.
aws s3api get-bucket-policy --bucket <S3BucketName> --query Policy --output text \
| jq '.Statement[] | select(.Principal.Service=="cloudtrail.amazonaws.com")'
# 2. KMS key policy — must allow cloudtrail.amazonaws.com kms:GenerateDataKey*
# and kms:Decrypt with EncryptionContext:aws:cloudtrail:arn == <trail-arn>.
aws kms describe-key --key-id <KmsKeyId> --query 'KeyMetadata.Policy' --output text \
| jq '.Statement[] | select(.Principal.Service=="cloudtrail.amazonaws.com")'
# 3. S3 lifecycle rules — must NOT expire the log prefix (<prefix>/) or the
# digest prefix (<prefix>/CloudTrail-Digest/) before the compliance window.
aws s3api get-bucket-lifecycle-configuration --bucket <S3BucketName> --output json \
| jq '.Rules[] | select(.Filter.Prefix | test("^<prefix>(CloudTrail-Digest/)?"))'
# 4. CloudWatch Logs retention — must be on the trail's log group, >= 90 days.
aws logs describe-log-groups --log-group-name-prefix <CloudWatchLogsLogGroupArn-prefix> \
--query 'logGroups[*].[logGroupName,retentionInDays]' --output table
Step 3: Log file validation check (NO_VALIDATION — HIGH)
If Steps 1-2 passed, check LogFileValidationEnabled:
LogFileValidationEnabled: false or absent → No digest files are
generated. An attacker with S3 write access can modify, delete, or inject
log files without detection. Verdict: NO_VALIDATION (HIGH risk).
LogFileValidationEnabled: true → Digest files are generated.
Integrity checking is possible via aws cloudtrail validate-logs.
Note: validation detects offline tampering (files modified after
delivery), not real-time tampering during the write window. Still a
critical detective control for compliance and forensic integrity.
Step 4: CloudTrail Insights check (NO_INSIGHTS — MEDIUM)
If Steps 1-3 passed, check Insights selectors. The rule is deterministic:
No InsightsSelectors data provided → Verdict proceeds to Step 5 (does
NOT block OK), but the REASON field MUST begin with the literal phrase
"Insights unverified" and FINDINGS MUST include an [UNVERIFIED] line:
"Operator must call aws cloudtrail get-insight-selectors --trail-name <name> to close this dimension." Do NOT emit NO_INSIGHTS without explicit
evidence (empty list); do NOT emit OK without surfacing the gap. The
fallback is operator-visible, never silent.
InsightsSelectors is empty ([]) or explicitly not configured → No
anomaly detection on API call volume or error rates. Verdict:
NO_INSIGHTS (MEDIUM risk).
InsightsSelectors present with ApiCallRateInsight and/or
ApiErrorRateInsight → Insights is enabled. Note: Insights requires a
7-day baseline before detecting anomalies — a trail created <7 days ago
will not produce Insights findings yet, but this is NOT a misconfiguration.
Step 5: Configuration-gap check (CONFIG_GAP — MEDIUM)
If Steps 1-4 passed, evaluate secondary dimensions. ANY of the following
triggers CONFIG_GAP:
| Sub-check |
Condition |
Finding |
| Multi-region |
IsMultiRegionTrail: false |
Shadow regions — API activity in other regions is invisible. |
| CloudWatch Logs |
CloudWatchLogsLogGroupArn null/empty |
No real-time log streaming — SIEM/CW alarms cannot react to CloudTrail events. |
| Global service events |
IncludeGlobalServiceEvents: false |
IAM, STS, Route 53, CloudFront events dropped. |
| Log retention |
CloudWatch Logs retentionInDays: null or < 90 |
No compliance boundary (infinite storage or too-short retention for investigation). |
| S3 bucket ACL |
Not bucket-owner-full-control |
Member-account logs unreadable by management account. |
If ANY of these fail, Verdict: CONFIG_GAP (MEDIUM risk). Enumerate each
failing sub-check in FINDINGS.
Step 6: All dimensions pass (OK)
If all dimensions pass (org trail, KMS encryption, validation, Insights,
multi-region, CloudWatch Logs, global events, retention >= 90 days):
Verdict: OK (LOW risk).
Output format (per trail)
TRAIL: <trail-name>
VERDICT: NO_ORG_TRAIL | NO_ENCRYPTION | NO_VALIDATION | NO_INSIGHTS | CONFIG_GAP | OK
REASON: <1-2 sentences citing the first failing dimension and its step>
FINDINGS:
- [CRITICAL] <finding description (Step N)>
- [HIGH] <finding description (Step N)>
- [OK] <dimension that passed>
REMEDIATION: <specific CLI per finding, or "None required" if OK>
Worked example — org trail with validation disabled
TRAIL: org-trail-no-validation
VERDICT: NO_VALIDATION
REASON: LogFileValidationEnabled is false on an org trail — digest files are
not generated, so log tampering cannot be detected via validate-logs (Step 3).
FINDINGS:
- [OK] IsOrganizationTrail: true — org coverage active (Step 1)
- [OK] KmsKeyId configured — SSE-KMS encryption active (Step 2)
- [HIGH] LogFileValidationEnabled: false — no digest files, tampering
undetectable (Step 3)
REMEDIATION:
1. Enable log file validation:
aws cloudtrail update-trail --name org-trail-no-validation --enable-log-file-validation
2. Verify digest files appear in S3:
aws s3 ls s3://<bucket>/CloudTrail-Digest/ --recursive | head -20
Pre-flight safety checks (run before any remediation CLI)
Pre-flight safety checks moved verbatim to references/diagnostic-commands.md — load on demand.
Anti-Patterns — NEVER
NEVER assume an org trail is multi-region. IsOrganizationTrail and
IsMultiRegionTrail are independent flags. An org trail logging only one
region creates a blind spot for every other region — an attacker can
operate from eu-west-1 against a trail in us-east-1 and leave no trace.
NEVER treat SSE-S3 (Amazon-managed key) as satisfying a KMS-encryption
requirement. SSE-S3 IS encryption, but the key is managed by AWS — the
customer cannot audit key usage, set key policies, or rotate on their own
schedule. Compliance frameworks requiring customer-managed keys treat null
KmsKeyId as NO_ENCRYPTION regardless of S3 default encryption.
NEVER classify a trail as OK without verifying IsLogging: true. A trail
with perfect configuration but IsLogging: false is collecting nothing.
describe-trails returns the config; get-trail-status returns the status.
NEVER assume CloudTrail Insights works immediately after enablement. It
requires a minimum 7-day baseline of management events before it can detect
anomalies.
NEVER conflate CloudTrail log retention with CloudWatch Logs retention.
CloudTrail itself has no retention setting — logs persist in S3 until a
lifecycle policy removes them. CloudWatch Logs retention is a separate
property on the log group (retentionInDays).
NEVER overlook the S3 bucket policy for org trails. The bucket must grant
cloudtrail.amazonaws.com s3:PutObject with condition
s3:x-amz-acl: bucket-owner-full-control. Without the ACL condition,
member-account logs are owned by the member account and the management
account cannot read them.
NEVER assume IncludeGlobalServiceEvents: true is the default in all
tooling. Terraform and CloudFormation templates sometimes omit this field;
the default varies by SDK version. Explicitly verify it is true.
NEVER recommend delete-trail to remediate any configuration gap.
delete-trail is irreversible, drops the trail name and S3 prefix
continuity, breaks downstream EventBridge rules and CloudWatch alarms keyed
to the trail ARN, and creates a forensic gap until a replacement trail
begins delivery. Always use update-trail (in-place modification); it
preserves the ARN, S3 prefix, and all downstream integrations. If a
deletion is genuinely required (e.g., trail-name conflict), require a
second operator confirmation and capture a backup first.
NEVER ignore the KMS key policy when auditing CloudTrail KMS encryption.
A KmsKeyId set on the trail with a missing or restrictive key policy
causes silent log-delivery failure — the trail is "encrypted" but nothing
is being written.
NEVER classify NO_INSIGHTS if the insight-selector data was not provided.
Surface the gap as [UNVERIFIED] per Step 4 — do not guess.
NEVER rely on a default S3 lifecycle configuration (e.g., a bucket-wide
ExpirationInDays shipped by a CDK construct or Terraform module) as the
CloudTrail retention control. S3 lifecycle expires objects silently — no
notification, no digest-chain check, no object lock. A common compliance
failure: the default rule deletes raw log files after 30/60/90 days while
digests remain, so validate-logs reports a green chain pointing at
missing files and the audit trail silently shortens. Always inspect
aws s3api get-bucket-lifecycle-configuration and surface any
non-versioned expiry on the log or digest prefix as CONFIG_GAP. Prefer S3
Object Lock + Glacier Deep Archive for compliance retention over lifecycle
expiry.
NEVER assume a single-region trail is sufficient for an org, even if all
workloads are in one region. AWS global services (IAM, STS, Route 53) and
cross-region API calls (e.g., a Lambda in us-east-1 assuming a role in
eu-west-1) generate events in the source region.
Remediation guidance
For NO_ORG_TRAIL
- Verify the caller is in the management account:
aws organizations describe-organization --profile <p>
- Enable CloudTrail as a trusted service in Organizations:
aws organizations enable-aws-service-access --service-principal cloudtrail.amazonaws.com
- Create or update the trail to be an org trail:
aws cloudtrail update-trail --name <trail> --is-organization-trail
- Verify the S3 bucket policy allows writes from all member accounts (see
NEVER list — bucket-owner-full-control condition).
For NO_ENCRYPTION
- Identify or create a KMS key in the trail's region:
aws kms create-key --description "CloudTrail SSE-KMS key" --profile <p>
- Attach a key policy granting CloudTrail service access:
{"Statement": [{"Effect": "Allow", "Principal":
{"Service": "cloudtrail.amazonaws.com"}, "Action":
["kms:GenerateDataKey*", "kms:Decrypt"], "Resource": "*",
"Condition": {"StringEquals": {"kms:CallerAccount": "<account>",
"kms:EncryptionContext:aws:cloudtrail:arn":
"arn:aws:cloudtrail:<region>:<account>:trail/<name>"}}}]}
- Update the trail:
aws cloudtrail update-trail --name <trail> --kms-key-id <key-id>
- Verify log delivery continues:
aws cloudtrail get-trail-status --name <trail>
For NO_VALIDATION
- Enable log file validation:
aws cloudtrail update-trail --name <trail> --enable-log-file-validation
- Verify digest files appear:
aws s3 ls s3://<bucket>/<prefix>/CloudTrail-Digest/ --recursive | head -20
- Schedule periodic validation:
aws cloudtrail validate-logs --trail-name <trail> --start-time <ts> --end-time <ts>
For NO_INSIGHTS
- Enable Insights selectors:
aws cloudtrail put-insight-selectors --trail-name <trail> --insight-selectors '[{"InsightType": "ApiCallRateInsight"}, {"InsightType": "ApiErrorRateInsight"}]'
- Note: Insights requires 7 days of baseline data before producing findings.
- Monitor cost — Insights is billed per management event analyzed.
For CONFIG_GAP
- Single-region trail:
aws cloudtrail update-trail --name <trail> --is-multi-region-trail
- No CloudWatch Logs: Create a log group and IAM role, then update:
aws cloudtrail update-trail --name <trail> --cloudwatch-logs-log-group-arn <arn> --cloudwatch-logs-role-arn <arn>
- Global service events disabled:
aws cloudtrail update-trail --name <trail> --include-global-service-events
- Short/missing retention:
aws logs put-retention-policy --log-group-name <group> --retention-in-days 365
For OK
- No remediation required.
- Recommend periodic
validate-logs runs (weekly digest verification).
- Recommend testing org-trail member-account visibility quarterly.
Reference — CloudTrail internals (deep material)
CloudTrail internals deep material moved verbatim to references/advanced-patterns.md — load on demand.
Recent AWS features (2024-2026)
Recent AWS features moved verbatim to references/advanced-patterns.md — load on demand.
References (load on demand)
- references/advanced-patterns.md — Step 0 expert knowledge (non-obvious CloudTrail behaviors), CloudTrail internals deep material, recent AWS features
- references/diagnostic-commands.md — pre-flight safety checks — confirmation gate, rollback capture, Insights cost, org-trail enablement check
- references/error-handling.md — malformed trail-configuration ERROR output block
Domain
AWS CloudOps / CloudTrail Governance, Compliance & Forensic Readiness.
AWS documentation
1---2name: cloudtrail-org-trail-auditor3description: Audits AWS CloudTrail organization trails for full-org coverage, multi-region logging, KMS encryption (SSE-KMS) of log delivery, log-file validation (digest integrity), CloudWatch Logs delivery, CloudTrail Insights enablement, and log retention posture. Emits a deterministic verdict (NO_ORG_TRAIL | NO_ENCRYPTION | NO_VALIDATION | NO_INSIGHTS | CONFIG_GAP | OK) per trail with enumerated findings and CLI remediation. Use when reviewing CloudTrail trail configurations, checking org-wide audit coverage, validating log integrity, confirming KMS encryption, verifying CloudTrail Insights, or hardening forensic-readiness posture before compliance assessment.4license: Apache-2.05compatibility: Agent runtime that reads SKILL.md (Claude Code, Cursor, Windsurf, Codex, Gemini). No AWS CLI required for offline trail-config classification. Live-account audits use aws cloudtrail describe-trails, get-trail-status, get-insight-selectors, and aws logs describe-log-groups (AWS CLI v2, SSO or key-based credentials).6metadata:7 source: https://skillmd.com/skills/jhkchan/cloudtrail-org-trail-auditor8 domain: aws-cloudops9 complexity: medium10 requires_llm: 'true'11 phase: '2'12 supports_pipeline: 'true'13 entry_point: 'false'14 family: Governance15 verdict_shape: NO_ORG_TRAIL | NO_ENCRYPTION | NO_VALIDATION | NO_INSIGHTS | CONFIG_GAP | OK16 when_to_use: 'Pre-compliance review of an AWS Organizations CloudTrail trail''s configuration: org-wide coverage, multi-region logging, KMS-encryption, log-file integrity validation, Insights enablement, and log retention posture.'17 when_not_to_use: 'Single-account trail that is NOT part of an AWS Organization (different audit scope)., CloudTrail Lake event-data-store queries (different API surface: list-event-data-stores / start-query)., Configuring data-event selectors for S3/Lambda/DynamoDB resources (separate skill)., Macie, GuardDuty, or Security Hub finding triage (use the dedicated triage skills)., Cost-optimization of CloudTrail ingest volume (use a cost-audit skill).'18 activation_triggers: audit this CloudTrail org trail, is my org trail configured correctly, check CloudTrail org trail log file validation, is the CloudTrail org trail encrypted with KMS, are CloudTrail Insights enabled on the org trail, CloudTrail multi-region check on the org trail, CloudTrail org trail coverage audit, verify CloudTrail forensic readiness for the org19 invocation_schema: "{output: 'Deterministic per-trail block: TRAIL / VERDICT / REASON / FINDINGS / REMEDIATION.\n VERDICT is one of NO_ORG_TRAIL | NO_ENCRYPTION | NO_VALIDATION | NO_INSIGHTS |\n CONFIG_GAP | OK (first-fail-wins order).', properties: {cw_retention_days: {description: CloudWatch\n Logs retentionInDays for the trail's log group., type: integer}, insight_selectors: {\n description: get-insight-selectors output (optional)., type: array}, trail_config: {\n description: describe-trails output (JSON or key-value summary) for one trail.,\n type: object}, trail_name_or_arn: {description: Trail name/ARN for live-account\n audit (alternative to trail_config)., type: string}, trail_status: {description: get-trail-status\n output (optional but recommended)., type: object}}, required: [trail_config],\n type: object}"20 version: 0.1.021 author: Jacky Chan — AWS Community Builder22 keywords: CloudTrail, organization trail, multi-region trail, KMS encryption, log file validation, digest files, CloudWatch Logs, CloudTrail Insights, log retention, audit logging, compliance, forensic readiness, IsOrganizationTrail, IsMultiRegionTrail, LogFileValidationEnabled, trail auditor, API activity logging23 tags: cloudtrail, governance, audit-logging, compliance, security, insights, kms-encryption24---2526# CloudTrail Organization Trail Auditor2728## Quick start (decision tree — read first)2930Evaluate dimensions in order; **the first failing dimension is the verdict.**3132| # | Check | Fail verdict | Risk |33|---|---|---|---|34| 1 | `IsOrganizationTrail: false` (from `describe-trails`) | **NO_ORG_TRAIL** | CRITICAL |35| 2 | `KmsKeyId` null/empty (SSE-S3 defaults) | **NO_ENCRYPTION** | CRITICAL |36| 3 | `LogFileValidationEnabled: false` | **NO_VALIDATION** | HIGH |37| 4 | `InsightsSelectors: []` (from `get-insight-selectors`) | **NO_INSIGHTS** | MEDIUM |38| 5 | `IsMultiRegionTrail: false` OR `CloudWatchLogsLogGroupArn: null` OR `IncludeGlobalServiceEvents: false` OR CW retention < 90 days | **CONFIG_GAP** | MEDIUM |39| 6 | All above pass | **OK** | LOW |4041**Pre-flight gate (mandatory):** `get-trail-status` returns `IsLogging`. If `false`, append a CRITICAL finding regardless of the verdict, and recommend `start-logging`.4243**Invisible dependencies (require extra API calls — surface gaps in FINDINGS, never silently change the verdict):** Organizations trusted-service access for `cloudtrail.amazonaws.com`, S3 bucket-policy `s3:x-amz-acl: bucket-owner-full-control` ACL, KMS key-policy `kms:GenerateDataKey*` grant, S3 lifecycle rules on the log and digest prefixes.4445**Output one block per trail:** `TRAIL / VERDICT / REASON / FINDINGS / REMEDIATION` (see Output format).4647## Mindset4849**One-line takeaway:** the verdict is the **first** failing dimension in a50strict order of severity — org coverage → encryption → validation → insights51→ config-gap. A trail that is not an org trail fails the most fundamental52audit gate regardless of how well everything else is configured.5354CloudTrail is the forensic bedrock of an AWS account. A misconfigured org55trail does not merely "miss events"; it creates **silent blind spots** where56attacker actions leave no trace. Step 0 enumerates the non-obvious57CloudTrail behaviors that change classification; Steps 1–6 are the58deterministic first-fail-wins tree.5960## Pre-flight: trail status gate (run before classification)6162Before evaluating trail configuration, verify the trail is actually logging.63A trail with perfect configuration but `IsLogging: false` collects nothing —64it is the most overlooked audit dimension because `describe-trails` returns the65config without the status.6667| Status field | Value | Effect |68|---|---|---|69| `IsLogging` (get-trail-status) | `true` | Proceed with full audit. |70| `IsLogging` (get-trail-status) | `false` | Trail is STOPPED. This is a CRITICAL finding. Append to FINDINGS: "Trail isLogging=false — no events are being recorded despite configuration. Run `aws cloudtrail start-logging --name <trail>`." Continue the config audit so all gaps are surfaced, but note the trail is inactive. |71| Status unknown (no get-trail-status provided) | — | Proceed but append a WARNING: "Trail logging status not provided — verify with `aws cloudtrail get-trail-status --name <trail>`. A trail may be correctly configured but silently stopped." |7273**Multi-trail sweep note:** `aws cloudtrail describe-trails` returns all trails74visible to the caller, but an org trail is only visible in the management75account (or delegated administrator). If the input comes from a member account,76the org trail will NOT appear — verify the caller is in the management account77before concluding NO_ORG_TRAIL.7879> Malformed-config ERROR block moved verbatim to [references/error-handling.md](references/error-handling.md) — load on demand.8081## Process — Classification logic (apply in order, first-fail wins)8283### Step 0: Expert knowledge — non-obvious CloudTrail behaviors8485> Step 0 expert knowledge moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md) — load on demand.8687### Step 1: Organization trail check (NO_ORG_TRAIL — CRITICAL)8889If `IsOrganizationTrail` is `false` or absent, the trail does NOT cover member90accounts. This is the most fundamental gap — an org without an org trail has91no centralized audit visibility into member-account API activity.9293**Verdict: NO_ORG_TRAIL** (CRITICAL risk).9495Even if every other dimension (encryption, validation, Insights) is correctly96configured, the trail only logs the account it was created in. Member-account97activity is invisible to the management account's security team.9899**Edge case — delegated administrator:** If the trail was created by a100delegated administrator account (not the management account), the trail is101still an org trail — `IsOrganizationTrail: true` applies regardless of which102account created it, as long as the org trusted-service access is active.103104### Step 2: KMS encryption check (NO_ENCRYPTION — CRITICAL)105106If `IsOrganizationTrail: true` (passed Step 1), check `KmsKeyId`:107108- **`KmsKeyId` is null, empty, or absent** → SSE-S3 (Amazon-managed AES-256)109 is the default. This IS encryption, but the key is not customer-controlled.110 For compliance frameworks (SOC 2, HIPAA, FedRAMP) requiring customer-managed111 keys, this is a finding. **Verdict: NO_ENCRYPTION** (CRITICAL risk).112113- **`KmsKeyId` is present** → Verify the key is in the same region as the114 trail and that the key policy grants CloudTrail service access. If the key115 policy is missing the CloudTrail service principal, log delivery will fail116 silently — the trail appears active but logs stop appearing in S3. Note as117 a WARNING in FINDINGS but do not fail the dimension.118119**Verify the S3 bucket policy, KMS key policy, and S3 lifecycle rules120(all three are invisible from `describe-trails` and silently break member-account121log access on org trails). Run these in order; treat any non-conformance as a122CONFIG_GAP finding:**123124```bash125# 1. S3 bucket policy — must allow cloudtrail.amazonaws.com s3:PutObject with126# Condition StringEquals s3:x-amz-acl == bucket-owner-full-control.127aws s3api get-bucket-policy --bucket <S3BucketName> --query Policy --output text \128 | jq '.Statement[] | select(.Principal.Service=="cloudtrail.amazonaws.com")'129130# 2. KMS key policy — must allow cloudtrail.amazonaws.com kms:GenerateDataKey*131# and kms:Decrypt with EncryptionContext:aws:cloudtrail:arn == <trail-arn>.132aws kms describe-key --key-id <KmsKeyId> --query 'KeyMetadata.Policy' --output text \133 | jq '.Statement[] | select(.Principal.Service=="cloudtrail.amazonaws.com")'134135# 3. S3 lifecycle rules — must NOT expire the log prefix (<prefix>/) or the136# digest prefix (<prefix>/CloudTrail-Digest/) before the compliance window.137aws s3api get-bucket-lifecycle-configuration --bucket <S3BucketName> --output json \138 | jq '.Rules[] | select(.Filter.Prefix | test("^<prefix>(CloudTrail-Digest/)?"))'139140# 4. CloudWatch Logs retention — must be on the trail's log group, >= 90 days.141aws logs describe-log-groups --log-group-name-prefix <CloudWatchLogsLogGroupArn-prefix> \142 --query 'logGroups[*].[logGroupName,retentionInDays]' --output table143```144145### Step 3: Log file validation check (NO_VALIDATION — HIGH)146147If Steps 1-2 passed, check `LogFileValidationEnabled`:148149- **`LogFileValidationEnabled: false` or absent** → No digest files are150 generated. An attacker with S3 write access can modify, delete, or inject151 log files without detection. **Verdict: NO_VALIDATION** (HIGH risk).152153- **`LogFileValidationEnabled: true`** → Digest files are generated.154 Integrity checking is possible via `aws cloudtrail validate-logs`.155 Note: validation detects **offline** tampering (files modified after156 delivery), not real-time tampering during the write window. Still a157 critical detective control for compliance and forensic integrity.158159### Step 4: CloudTrail Insights check (NO_INSIGHTS — MEDIUM)160161If Steps 1-3 passed, check Insights selectors. The rule is deterministic:162163- **No `InsightsSelectors` data provided** → Verdict proceeds to Step 5 (does164 NOT block OK), but the REASON field MUST begin with the literal phrase165 `"Insights unverified"` and FINDINGS MUST include an `[UNVERIFIED]` line:166 "Operator must call `aws cloudtrail get-insight-selectors --trail-name167 <name>` to close this dimension." Do NOT emit `NO_INSIGHTS` without explicit168 evidence (empty list); do NOT emit `OK` without surfacing the gap. The169 fallback is operator-visible, never silent.170171- **`InsightsSelectors` is empty (`[]`) or explicitly not configured** → No172 anomaly detection on API call volume or error rates. **Verdict:173 NO_INSIGHTS** (MEDIUM risk).174175- **`InsightsSelectors` present with `ApiCallRateInsight` and/or176 `ApiErrorRateInsight`** → Insights is enabled. Note: Insights requires a177 7-day baseline before detecting anomalies — a trail created <7 days ago178 will not produce Insights findings yet, but this is NOT a misconfiguration.179180### Step 5: Configuration-gap check (CONFIG_GAP — MEDIUM)181182If Steps 1-4 passed, evaluate secondary dimensions. ANY of the following183triggers CONFIG_GAP:184185| Sub-check | Condition | Finding |186|---|---|---|187| Multi-region | `IsMultiRegionTrail: false` | Shadow regions — API activity in other regions is invisible. |188| CloudWatch Logs | `CloudWatchLogsLogGroupArn` null/empty | No real-time log streaming — SIEM/CW alarms cannot react to CloudTrail events. |189| Global service events | `IncludeGlobalServiceEvents: false` | IAM, STS, Route 53, CloudFront events dropped. |190| Log retention | CloudWatch Logs `retentionInDays: null` or `< 90` | No compliance boundary (infinite storage or too-short retention for investigation). |191| S3 bucket ACL | Not `bucket-owner-full-control` | Member-account logs unreadable by management account. |192193If ANY of these fail, **Verdict: CONFIG_GAP** (MEDIUM risk). Enumerate each194failing sub-check in FINDINGS.195196### Step 6: All dimensions pass (OK)197198If all dimensions pass (org trail, KMS encryption, validation, Insights,199multi-region, CloudWatch Logs, global events, retention >= 90 days):200**Verdict: OK** (LOW risk).201202## Output format (per trail)203204```text205TRAIL: <trail-name>206VERDICT: NO_ORG_TRAIL | NO_ENCRYPTION | NO_VALIDATION | NO_INSIGHTS | CONFIG_GAP | OK207REASON: <1-2 sentences citing the first failing dimension and its step>208FINDINGS:209 - [CRITICAL] <finding description (Step N)>210 - [HIGH] <finding description (Step N)>211 - [OK] <dimension that passed>212REMEDIATION: <specific CLI per finding, or "None required" if OK>213```214215### Worked example — org trail with validation disabled216217```text218TRAIL: org-trail-no-validation219VERDICT: NO_VALIDATION220REASON: LogFileValidationEnabled is false on an org trail — digest files are221not generated, so log tampering cannot be detected via validate-logs (Step 3).222FINDINGS:223 - [OK] IsOrganizationTrail: true — org coverage active (Step 1)224 - [OK] KmsKeyId configured — SSE-KMS encryption active (Step 2)225 - [HIGH] LogFileValidationEnabled: false — no digest files, tampering226 undetectable (Step 3)227REMEDIATION:228 1. Enable log file validation:229 aws cloudtrail update-trail --name org-trail-no-validation --enable-log-file-validation230 2. Verify digest files appear in S3:231 aws s3 ls s3://<bucket>/CloudTrail-Digest/ --recursive | head -20232```233234## Pre-flight safety checks (run before any remediation CLI)235236> Pre-flight safety checks moved verbatim to [references/diagnostic-commands.md](references/diagnostic-commands.md) — load on demand.237238## Anti-Patterns — NEVER239240- NEVER assume an org trail is multi-region. `IsOrganizationTrail` and241 `IsMultiRegionTrail` are independent flags. An org trail logging only one242 region creates a blind spot for every other region — an attacker can243 operate from `eu-west-1` against a trail in `us-east-1` and leave no trace.244245- NEVER treat SSE-S3 (Amazon-managed key) as satisfying a KMS-encryption246 requirement. SSE-S3 IS encryption, but the key is managed by AWS — the247 customer cannot audit key usage, set key policies, or rotate on their own248 schedule. Compliance frameworks requiring customer-managed keys treat null249 `KmsKeyId` as NO_ENCRYPTION regardless of S3 default encryption.250251- NEVER classify a trail as OK without verifying `IsLogging: true`. A trail252 with perfect configuration but `IsLogging: false` is collecting nothing.253 `describe-trails` returns the config; `get-trail-status` returns the status.254255- NEVER assume CloudTrail Insights works immediately after enablement. It256 requires a minimum 7-day baseline of management events before it can detect257 anomalies.258259- NEVER conflate CloudTrail log retention with CloudWatch Logs retention.260 CloudTrail itself has no retention setting — logs persist in S3 until a261 lifecycle policy removes them. CloudWatch Logs retention is a separate262 property on the log group (`retentionInDays`).263264- NEVER overlook the S3 bucket policy for org trails. The bucket must grant265 `cloudtrail.amazonaws.com` `s3:PutObject` with condition266 `s3:x-amz-acl: bucket-owner-full-control`. Without the ACL condition,267 member-account logs are owned by the member account and the management268 account cannot read them.269270- NEVER assume `IncludeGlobalServiceEvents: true` is the default in all271 tooling. Terraform and CloudFormation templates sometimes omit this field;272 the default varies by SDK version. Explicitly verify it is `true`.273274- NEVER recommend `delete-trail` to remediate any configuration gap.275 `delete-trail` is irreversible, drops the trail name and S3 prefix276 continuity, breaks downstream EventBridge rules and CloudWatch alarms keyed277 to the trail ARN, and creates a forensic gap until a replacement trail278 begins delivery. Always use `update-trail` (in-place modification); it279 preserves the ARN, S3 prefix, and all downstream integrations. If a280 deletion is genuinely required (e.g., trail-name conflict), require a281 second operator confirmation and capture a backup first.282283- NEVER ignore the KMS key policy when auditing CloudTrail KMS encryption.284 A `KmsKeyId` set on the trail with a missing or restrictive key policy285 causes silent log-delivery failure — the trail is "encrypted" but nothing286 is being written.287288- NEVER classify NO_INSIGHTS if the insight-selector data was not provided.289 Surface the gap as `[UNVERIFIED]` per Step 4 — do not guess.290291- NEVER rely on a default S3 lifecycle configuration (e.g., a bucket-wide292 `ExpirationInDays` shipped by a CDK construct or Terraform module) as the293 CloudTrail retention control. S3 lifecycle expires objects silently — no294 notification, no digest-chain check, no object lock. A common compliance295 failure: the default rule deletes raw log files after 30/60/90 days while296 digests remain, so `validate-logs` reports a green chain pointing at297 missing files and the audit trail silently shortens. Always inspect298 `aws s3api get-bucket-lifecycle-configuration` and surface any299 non-versioned expiry on the log or digest prefix as CONFIG_GAP. Prefer S3300 Object Lock + Glacier Deep Archive for compliance retention over lifecycle301 expiry.302303- NEVER assume a single-region trail is sufficient for an org, even if all304 workloads are in one region. AWS global services (IAM, STS, Route 53) and305 cross-region API calls (e.g., a Lambda in us-east-1 assuming a role in306 eu-west-1) generate events in the source region.307308## Remediation guidance309310### For NO_ORG_TRAIL3113121. Verify the caller is in the management account:313 `aws organizations describe-organization --profile <p>`3142. Enable CloudTrail as a trusted service in Organizations:315 `aws organizations enable-aws-service-access --service-principal cloudtrail.amazonaws.com`3163. Create or update the trail to be an org trail:317 `aws cloudtrail update-trail --name <trail> --is-organization-trail`3184. Verify the S3 bucket policy allows writes from all member accounts (see319 NEVER list — bucket-owner-full-control condition).320321### For NO_ENCRYPTION3223231. Identify or create a KMS key in the trail's region:324 `aws kms create-key --description "CloudTrail SSE-KMS key" --profile <p>`3252. Attach a key policy granting CloudTrail service access:326 ```json327 {"Statement": [{"Effect": "Allow", "Principal":328 {"Service": "cloudtrail.amazonaws.com"}, "Action":329 ["kms:GenerateDataKey*", "kms:Decrypt"], "Resource": "*",330 "Condition": {"StringEquals": {"kms:CallerAccount": "<account>",331 "kms:EncryptionContext:aws:cloudtrail:arn":332 "arn:aws:cloudtrail:<region>:<account>:trail/<name>"}}}]}333 ```3343. Update the trail:335 `aws cloudtrail update-trail --name <trail> --kms-key-id <key-id>`3364. Verify log delivery continues:337 `aws cloudtrail get-trail-status --name <trail>`338339### For NO_VALIDATION3403411. Enable log file validation:342 `aws cloudtrail update-trail --name <trail> --enable-log-file-validation`3432. Verify digest files appear:344 `aws s3 ls s3://<bucket>/<prefix>/CloudTrail-Digest/ --recursive | head -20`3453. Schedule periodic validation:346 `aws cloudtrail validate-logs --trail-name <trail> --start-time <ts> --end-time <ts>`347348### For NO_INSIGHTS3493501. Enable Insights selectors:351 `aws cloudtrail put-insight-selectors --trail-name <trail>352 --insight-selectors '[{"InsightType": "ApiCallRateInsight"},353 {"InsightType": "ApiErrorRateInsight"}]'`3542. Note: Insights requires 7 days of baseline data before producing findings.3553. Monitor cost — Insights is billed per management event analyzed.356357### For CONFIG_GAP358359- **Single-region trail:** `aws cloudtrail update-trail --name <trail>360 --is-multi-region-trail`361- **No CloudWatch Logs:** Create a log group and IAM role, then update:362 `aws cloudtrail update-trail --name <trail>363 --cloudwatch-logs-log-group-arn <arn> --cloudwatch-logs-role-arn <arn>`364- **Global service events disabled:** `aws cloudtrail update-trail --name365 <trail> --include-global-service-events`366- **Short/missing retention:** `aws logs put-retention-policy367 --log-group-name <group> --retention-in-days 365`368369### For OK3703711. No remediation required.3722. Recommend periodic `validate-logs` runs (weekly digest verification).3733. Recommend testing org-trail member-account visibility quarterly.374375## Reference — CloudTrail internals (deep material)376377> CloudTrail internals deep material moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md) — load on demand.378379## Recent AWS features (2024-2026)380381> Recent AWS features moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md) — load on demand.382383## References (load on demand)384385- [references/advanced-patterns.md](references/advanced-patterns.md) — Step 0 expert knowledge (non-obvious CloudTrail behaviors), CloudTrail internals deep material, recent AWS features386- [references/diagnostic-commands.md](references/diagnostic-commands.md) — pre-flight safety checks — confirmation gate, rollback capture, Insights cost, org-trail enablement check387- [references/error-handling.md](references/error-handling.md) — malformed trail-configuration ERROR output block388389## Domain390391AWS CloudOps / CloudTrail Governance, Compliance & Forensic Readiness.392393## AWS documentation394395- **AWS CloudTrail User Guide** — https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-user-guide.html396- **CloudTrail Security** — https://docs.aws.amazon.com/awscloudtrail/latest/userguide/security.html397- **CloudTrail API Reference** — https://docs.aws.amazon.com/awscloudtrail/latest/APIReference/398- **CloudTrail CLI Reference** — https://docs.aws.amazon.com/cli/latest/reference/cloudtrail/399- **CloudTrail Lake** — https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-lake.html