Skip to main content

AWS S3

This plugin collects read-only Amazon S3 bucket configuration, evaluates CCF Rego policy bundles, and emits evidence back through the CCF agent.

This page is for operators who run the plugin-aws-s3 plugin with the CCF Agent, and for developers who write policies for it. It documents v0.1.3 and is generated from the plugin's README at v0.1.3.

How it works​

How it fits in CCF​

The CCF agent starts this binary through HashiCorp go-plugin, passes configuration and policy paths over gRPC, and receives generated evidence through the runner callback. This repository does not call the CCF API directly.

During plugin initialisation, subject templates and risk templates declared by the configured policy bundle are registered through the agent API helper.

Configuration​

The plugin expects:

  • AWS credentials through the default AWS SDK credential chain
  • target regions from config.regions or config.region
  • AWS_REGION as a fallback when plugin config does not provide a region

Any agent-supplied policy_data is passed through to Rego as data.*.

Evidence collected​

Supported resource families​

The collector can evaluate policies for:

  • S3 buckets

Data collected​

For each in-scope bucket, the plugin collects and normalises:

  • bucket name, ARN, creation date, and home region
  • bucket tags
  • server-side encryption settings
  • public access block settings
  • bucket policy document, policy hash, and public policy status
  • ownership controls
  • versioning and MFA delete status
  • object lock configuration
  • lifecycle rules and retention summary
  • replication configuration
  • server access logging configuration
  • static website hosting configuration

The policy input contains both the raw bucket resource under input.bucket and the evaluated context under input.bucket_context.

Policy input​

The plugin evaluates one kind of resource, an S3 bucket, and a policy receives one document per bucket as input. The document has two top-level keys: bucket, the identity of the bucket, and bucket_context, everything the plugin read about it. A bundle is matched by its name, aws-s3-policies. Fields are listed by their path inside the document; a field marked as left out is missing from the document, not null, so test for it with object.get or a default. The bucket_context object always has current, bucket_home_region and one object for each setting below (encryption, public_access_block, policy, policy_status, ownership_controls, versioning, object_lock, lifecycle, replication, logging, website), but a setting the bucket does not have is an empty object, or has its fields left out.

FieldTypeDescription
bucketobjectThe bucket itself.
bucket.namestringBucket name.
bucket.arnstringBucket ARN, arn:aws:s3:::<name>.
bucket.regionstringRegion the bucket lives in. us-east-1 when S3 reports no location, and eu-west-1 for the legacy EU location.
bucket.creation_datestring (RFC 3339 time)When the bucket was created. Left out when S3 returns no date.
bucket_contextobjectWhat the plugin read about the bucket. The fields below are all inside it.
bucket_context.bucket_home_regionstringRegion the bucket lives in, same as bucket.region.
bucket_context.tagsobject (string to string)The bucket's tags. Left out when the bucket has none.
bucket_context.policy_hashstringSHA-256 hex digest of the bucket policy text. Left out when there is no bucket policy.
bucket_context.currentobjectSummary flags computed from the rest of the context, the easiest thing for a policy to test. Fields:
bucket_context.current.bucket_namestringBucket name.
bucket_context.current.bucket_arnstringBucket ARN.
bucket_context.current.regionstringBucket region.
bucket_context.current.tags_presentbooleanTrue when the bucket has at least one tag.
bucket_context.current.is_publicbooleanTrue when S3 reports the bucket policy as public. False when there is no bucket policy.
bucket_context.current.encryption_enabledbooleanTrue when the bucket has at least one default encryption rule.
bucket_context.current.uses_kmsbooleanTrue when a default encryption rule uses aws:kms.
bucket_context.current.ownership_enforcedbooleanTrue when object ownership is BucketOwnerEnforced.
bucket_context.current.is_versionedbooleanTrue when versioning status is Enabled.
bucket_context.current.mfa_delete_enabledbooleanTrue when MFA delete is Enabled.
bucket_context.current.object_lock_enabledbooleanTrue when Object Lock is enabled.
bucket_context.current.has_lifecycle_rulesbooleanTrue when the bucket has at least one lifecycle rule.
bucket_context.current.lifecycle_min_expiration_daysintegerSmallest expiration_days across lifecycle rules that set one. 0 when none does.
bucket_context.current.has_noncurrent_version_expirationbooleanTrue when any lifecycle rule expires noncurrent versions.
bucket_context.current.logging_enabledbooleanTrue when server access logging has a target bucket.
bucket_context.current.replication_enabledbooleanTrue when at least one replication rule has status Enabled.
bucket_context.current.website_hosting_enabledbooleanTrue when static website hosting is configured.
bucket_context.encryption.rulesarray of objectsDefault encryption rules. Left out when the bucket has no default encryption (encryption is then an empty object).
bucket_context.encryption.rules[].algorithmstringAES256, aws:kms or aws:kms:dsse.
bucket_context.encryption.rules[].kms_key_arnstringKMS key the rule names. Left out when none is named.
bucket_context.encryption.rules[].bucket_key_enabledbooleanWhether S3 Bucket Keys are on.
bucket_context.public_access_block.block_public_aclsbooleanBlock public ACLs. All four are false when the bucket has no public access block.
bucket_context.public_access_block.ignore_public_aclsbooleanIgnore public ACLs. All four are false when the bucket has no public access block.
bucket_context.public_access_block.block_public_policybooleanBlock public bucket policies. All four are false when the bucket has no public access block.
bucket_context.public_access_block.restrict_public_bucketsbooleanRestrict access to buckets with public policies. All four are false when the bucket has no public access block.
bucket_context.policy.rawstringThe bucket policy as the JSON string S3 returns. Left out when there is no bucket policy.
bucket_context.policy_status.is_publicbooleanWhether S3 evaluates the bucket policy as public.
bucket_context.ownership_controls.object_ownershipstringBucketOwnerEnforced, BucketOwnerPreferred or ObjectWriter. Left out when no ownership controls are set.
bucket_context.versioning.statusstringEnabled or Suspended. Left out when versioning was never turned on.
bucket_context.versioning.mfa_deletestringEnabled or Disabled. Left out when S3 returns none.
bucket_context.object_lock.enabledbooleanWhether Object Lock is enabled.
bucket_context.object_lock.default_retention_modestringGOVERNANCE or COMPLIANCE. Left out when there is no default retention.
bucket_context.object_lock.default_retention_daysintegerDefault retention in days. Left out when 0.
bucket_context.object_lock.default_retention_yearsintegerDefault retention in years. Left out when 0.
bucket_context.lifecycle.rulesarray of objectsLifecycle rules. Left out when the bucket has none. Each rule has the fields below.
bucket_context.lifecycle.rules[].idstringRule ID. Left out when empty.
bucket_context.lifecycle.rules[].statusstringEnabled or Disabled.
bucket_context.lifecycle.rules[].expiration_daysintegerDays until current objects expire. Left out when 0.
bucket_context.lifecycle.rules[].noncurrent_version_expiration_daysintegerDays until noncurrent versions expire. Left out when 0.
bucket_context.lifecycle.rules[].abort_incomplete_multipart_upload_after_daysintegerDays after which incomplete multipart uploads are aborted. Left out when 0.
bucket_context.lifecycle.rules[].expired_object_delete_markerbooleanWhether expired object delete markers are removed.
bucket_context.replication.rolestringIAM role ARN used for replication. Left out when there is no replication.
bucket_context.replication.rulesarray of objectsReplication rules that have a destination. Left out when there are none.
bucket_context.replication.rules[].idstringRule ID. Left out when empty.
bucket_context.replication.rules[].statusstringEnabled or Disabled.
bucket_context.replication.rules[].destination_bucket_arnstringARN of the destination bucket.
bucket_context.logging.target_bucketstringBucket that receives access logs. Left out when logging is off.
bucket_context.logging.target_prefixstringPrefix of the log objects. Left out when empty.
bucket_context.website.hosting_enabledbooleanWhether static website hosting is configured.
bucket_context.website.index_suffixstringIndex document suffix. Left out when empty.

An example input:

{
"bucket": {
"name": "acme-payments-audit-logs",
"arn": "arn:aws:s3:::acme-payments-audit-logs",
"region": "eu-west-1",
"creation_date": "2025-03-14T08:22:41Z"
},
"bucket_context": {
"current": {
"bucket_name": "acme-payments-audit-logs",
"bucket_arn": "arn:aws:s3:::acme-payments-audit-logs",
"region": "eu-west-1",
"tags_present": true,
"is_public": false,
"encryption_enabled": true,
"uses_kms": true,
"ownership_enforced": true,
"is_versioned": true,
"mfa_delete_enabled": false,
"object_lock_enabled": true,
"has_lifecycle_rules": true,
"lifecycle_min_expiration_days": 365,
"has_noncurrent_version_expiration": true,
"logging_enabled": true,
"replication_enabled": false,
"website_hosting_enabled": false
},
"bucket_home_region": "eu-west-1",
"tags": {
"Environment": "production"
},
"encryption": {
"rules": [
{
"algorithm": "aws:kms",
"kms_key_arn": "arn:aws:kms:eu-west-1:111122223333:key/1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"bucket_key_enabled": true
}
]
},
"public_access_block": {
"block_public_acls": true,
"ignore_public_acls": true,
"block_public_policy": true,
"restrict_public_buckets": true
},
"policy": {
"raw": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"DenyInsecureTransport\",\"Effect\":\"Deny\",\"Principal\":\"*\",\"Action\":\"s3:*\",\"Resource\":[\"arn:aws:s3:::acme-payments-audit-logs\",\"arn:aws:s3:::acme-payments-audit-logs/*\"],\"Condition\":{\"Bool\":{\"aws:SecureTransport\":\"false\"}}}]}"
},
"policy_hash": "9f2b6c1e0d4a7385b1c3e8f4a60d2c57e91b3a8d4f6c0e2a7b5d9138c4e6f0a2",
"policy_status": {
"is_public": false
},
"ownership_controls": {
"object_ownership": "BucketOwnerEnforced"
},
"versioning": {
"status": "Enabled",
"mfa_delete": "Disabled"
},
"object_lock": {
"enabled": true,
"default_retention_mode": "COMPLIANCE",
"default_retention_days": 365
},
"lifecycle": {
"rules": [
{
"id": "expire-old-logs",
"status": "Enabled",
"expiration_days": 365,
"noncurrent_version_expiration_days": 30,
"abort_incomplete_multipart_upload_after_days": 7,
"expired_object_delete_marker": false
}
]
},
"replication": {},
"logging": {
"target_bucket": "acme-access-logs",
"target_prefix": "s3/acme-payments-audit-logs/"
},
"website": {
"hosting_enabled": false
}
}
}

Subject templates​

The subject templates this plugin registers. Each example is built from sample data.

aws-s3-bucket​

An Amazon S3 bucket. Title: AWS S3 bucket {{ .bucket_name }} in {{ .region }}. The evidence also carries type (bucket) and resource_arn labels that are not part of the identity.

Identity keyDescription
providerCloud provider, always aws.
regionRegion the bucket lives in.
bucket_nameName of the bucket.

Example:

{
"name": "aws-s3-bucket",
"type": "component",
"title": "AWS S3 bucket acme-payments-audit-logs in eu-west-1",
"description": "Amazon S3 bucket acme-payments-audit-logs in AWS region eu-west-1.",
"purpose": "Represents an Amazon S3 bucket evaluated for storage compliance posture.",
"identityLabels": {
"provider": "aws",
"region": "eu-west-1",
"bucket_name": "acme-payments-audit-logs"
}
}

Policies​

The policy bundles that work with this plugin, at their newest releases. The controls are the ones the bundle's policies list in their metadata.

BundleLatest versionControls coveredCompatible plugin lines
plugin-aws-s3-policiesv0.1.1none listedlatest

Default policy bundle mapping​

RepositoryBehaviorPrimary input
plugin-aws-s3-policiesbucketinput.bucket + input.bucket_context