10 of 50 in All Controls
aws

Secure S3 Audit Trails and CloudTrail Loop Prevention

IDAWS-DATA-004
Severity
medium
Automation
Auto
Category
data-protection
Enforcementrecommended
Complexity / Impact
low(low impact)
Risk Profile
low likelihood(low residual)
Cloud Scopeaws:account
Environments
productionnon-production
Target Resources
S3
Services
s3cloudtrailorganizationsconfig
Tags
s3loggingcloudtrailloop-preventiondata-protectionlanding-zone
Frameworks
CIS AWSAWS FSBP
Governance
Cloud Security (quarterly)
Created
2026-05-03
Last Updated
2026-06-04

Specification & Description

Enable S3 server access logging for buckets tagged as sensitive while explicitly prohibiting logging on CloudTrail buckets to prevent infinite recursive logging loops and associated cost spikes.

Technical Specifications

AWS S3 server access logging is critical for auditing sensitive data access. However, enabling server access logging on a bucket that also serves as a target for AWS CloudTrail (or as its own logging target) creates an infinite recursive loop: every log delivery is recorded as an access event, which triggers a new log delivery. This results in massive storage growth and uncontrolled costs. This control mandates tagging for sensitive buckets to ensure audit trails exist where necessary, while enforcing a guardrail to prevent logging on the central CloudTrail log archive bucket.

Security Rationale

Tag-driven selective logging focuses forensic visibility on critical data (PII, financial, source code) without the overhead of logging every low-risk utility bucket. Prohibiting logging on the CloudTrail bucket is a mandatory operational safety guardrail to avoid service-wide log bombardment and financial loss from recursive storage events.

Business & Security Impact

Failure to disable logging on CloudTrail buckets can lead to service interruption due to S3 API throttling and unexpected high costs. Conversely, a lack of logging on sensitive buckets impairs forensic capabilities during a security incident.

Policy Exceptions (1)

Central logging buckets are exempt to prevent recursive loops.

Operational & Implementation Notes

Enabling server access logging on a bucket that receives its own logs or receives frequent CloudTrail logs will cause exponential log growth. Always use a separate, dedicated logging bucket that does not have logging enabled for itself.

Compliance Framework Mappings (2)

Regulatory baselines and industry standards mapped to this control specification.

Beta
Framework / StandardMapped Requirements & ControlsControls
CIS AWS Foundations Benchmark v3.0CIS AWS
3.6
1
AWS Foundational Security Best PracticesAWS FSBP
S3.9
1

* Compliance framework mappings are provided for informational architectural reference. Always verify control alignment against your organization's formal audit requirements.

Automated Detection & Rule Logic

Detection Engine: config-rule • Automated: Yes

Uses S3_BUCKET_LOGGING_ENABLED scoped via tags to sensitive buckets. Additionally, a custom check should verify the CloudTrail bucket is NOT in the compliance list.

Verify No Loopbash
aws s3api get-bucket-logging --bucket <CLOUDTRAIL_LOG_BUCKET>
# Expected: {} (Empty)

Preventative Enforcement Policies

Log Delivery & Loop Preventionjson
# 1. Bucket policy: Allow delivery to central logging bucket
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowS3LogDeliveryOrgOnly",
      "Effect": "Allow",
      "Principal": { 
        "Service": "logging.s3.amazonaws.com" 
      },
      "Action": "s3:PutObject",
      "Resource": "arn:aws:s3:::CENTRAL-LOGGING-BUCKET/s3-access-logs/*",
      "Condition": {
        "StringEquals": {
          "aws:SourceOrgID": "o-xxxxxxxxxx"
        }
      }
    }
  ]
}

# 2. SCP: Deny logging on CloudTrail buckets (safety guardrail)
{
  "Sid": "DenyLoggingOnCloudTrailBuckets",
  "Effect": "Deny",
  "Action": "s3:PutBucketLogging",
  "Resource": "arn:aws:s3:::cloudtrail-logs-*",
  "Condition": { "Bool": { "aws:PrincipalIsAWSService": "false" } }
}

Remediation Guide & Automation

Tag sensitive buckets, enable access logging targeting the Log Archive account, and verify that the primary CloudTrail log bucket has logging disabled.

Step-by-Step Instructions

  1. Tag sensitive buckets with SecuritySensitivity: High.
  2. Setup a central logging bucket in the Log Archive account.
  3. Enable server access logging on sensitive source buckets.
  4. Ensure the CloudTrail log bucket has NO access logging enabled to prevent loops.
Audit and Configure Loggingbash
# ==============================================================================
# 1. IDENTIFY SENSITIVE BUCKETS MISSING LOGGING
# ==============================================================================
# Safely loop through every bucket name returned by the AWS API
for bucket in $(aws s3api list-buckets --query "Buckets[].Name" --output text); do
  
  # 1. Fetch the sensitivity tag, hiding errors if the bucket has no tags at all
  TAG=$(aws s3api get-bucket-tagging --bucket "$bucket" --query "TagSet[?Key==\`SecuritySensitivity\`].Value" --output text 2>/dev/null)
  
  # 2. If the tag matches "High", check its logging status
  if [ "$TAG" = "High" ]; then
    LOG=$(aws s3api get-bucket-logging --bucket "$bucket" --query "LoggingEnabled" --output text 2>/dev/null)
    
    # 3. Flag the bucket if logging is completely absent or returned as "None"
    if [ "$LOG" = "None" ] || [ -z "$LOG" ]; then
      echo "NON_COMPLIANT: $bucket"
    fi
  fi
done

# ==============================================================================
# 2. ENABLE LOGGING ON A SENSITIVE BUCKET
# ==============================================================================
aws s3api put-bucket-logging \
  --bucket <SENSITIVE_BUCKET> \
  --bucket-logging-status '{"LoggingEnabled": {"TargetBucket": "central-logs-bucket", "TargetPrefix": "s3-access-logs/<SENSITIVE_BUCKET>/"}}'

# ==============================================================================
# 3. DISABLE LOGGING ON CLOUDTRAIL BUCKET (SAFETY REMEDIATION)
# ==============================================================================
aws s3api put-bucket-logging \
  --bucket <CLOUDTRAIL_LOG_BUCKET> \
  --bucket-logging-status '{}'
Audit Baselinehcl
# Sensitive bucket with logging
resource "aws_s3_bucket_logging" "sensitive" {
  bucket = aws_s3_bucket.sensitive.id
  target_bucket = "central-logs-${data.aws_caller_identity.current.account_id}"
  target_prefix = "s3-access-logs/${aws_s3_bucket.sensitive.id}/"
}

# CloudTrail bucket (explicitly NO logging block)
resource "aws_s3_bucket" "cloudtrail_logs" {
  bucket = "org-cloudtrail-logs-${data.aws_caller_identity.current.account_id}"
  # Do NOT add aws_s3_bucket_logging resource for this bucket
}

We value your privacy

We use analytics cookies to understand how visitors interact with our site and to improve the user experience. You can choose to accept or decline these cookies.