Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CheckBucketsHavePublicAccessBlocks = rules.Register( rules.Rule{ AVDID: "AVD-AWS-0094", Provider: provider.AWSProvider, Service: "s3", ShortCode: "specify-public-access-block", Summary: "S3 buckets should each define an aws_s3_bucket_public_access_block", Explanation: `The "block public access" settings in S3 override individual policies that apply to a given bucket, meaning that all public access can be controlled in one central types for that bucket. It is therefore good practice to define these settings for each bucket in order to clearly define the public access that can be allowed for it.`, Impact: "Public access policies may be applied to sensitive data buckets", Resolution: "Define a aws_s3_bucket_public_access_block for the given bucket to control public access policies", Links: []string{ "https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-control-block-public-access.html", }, Terraform: &rules.EngineMetadata{ GoodExamples: terraformSpecifyPublicAccessBlockGoodExamples, BadExamples: terraformSpecifyPublicAccessBlockBadExamples, Links: terraformSpecifyPublicAccessBlockLinks, RemediationMarkdown: terraformSpecifyPublicAccessBlockRemediationMarkdown, }, CloudFormation: &rules.EngineMetadata{ GoodExamples: cloudFormationSpecifyPublicAccessBlockGoodExamples, BadExamples: cloudFormationSpecifyPublicAccessBlockBadExamples, Links: cloudFormationSpecifyPublicAccessBlockLinks, RemediationMarkdown: cloudFormationSpecifyPublicAccessBlockRemediationMarkdown, }, Severity: severity.Low, }, func(s *state.State) (results rules.Results) { for _, bucket := range s.AWS.S3.Buckets { if bucket.PublicAccessBlock == nil { results.Add( "Bucket does not have a corresponding public access block.", &bucket, ) } else { results.AddPassed(&bucket) } } return results }, )
View Source
var CheckEncryptionIsEnabled = rules.Register( rules.Rule{ AVDID: "AVD-AWS-0088", Provider: provider.AWSProvider, Service: "s3", ShortCode: "enable-bucket-encryption", Summary: "Unencrypted S3 bucket.", Impact: "The bucket objects could be read if compromised", Resolution: "Configure bucket encryption", Explanation: ` S3 Buckets should be encrypted with customer managed KMS keys and not default AWS managed keys, in order to allow granular control over access to specific buckets. `, Links: []string{ "https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-encryption.html", }, Terraform: &rules.EngineMetadata{ GoodExamples: terraformEnableBucketEncryptionGoodExamples, BadExamples: terraformEnableBucketEncryptionBadExamples, Links: terraformEnableBucketEncryptionLinks, RemediationMarkdown: terraformEnableBucketEncryptionRemediationMarkdown, }, CloudFormation: &rules.EngineMetadata{ GoodExamples: cloudFormationEnableBucketEncryptionGoodExamples, BadExamples: cloudFormationEnableBucketEncryptionBadExamples, Links: cloudFormationEnableBucketEncryptionLinks, RemediationMarkdown: cloudFormationEnableBucketEncryptionRemediationMarkdown, }, Severity: severity.High, }, func(s *state.State) (results rules.Results) { for _, bucket := range s.AWS.S3.Buckets { if bucket.Encryption.Enabled.IsFalse() { results.Add( "Bucket does not have encryption enabled", &bucket, bucket.Encryption.Enabled, ) } else { results.AddPassed(&bucket, "Bucket encryption correctly configured") } } return results }, )
View Source
var CheckForPublicACL = rules.Register( rules.Rule{ AVDID: "AVD-AWS-0092", Provider: provider.AWSProvider, Service: "s3", ShortCode: "no-public-access-with-acl", Summary: "S3 Bucket does not have logging enabled.", Explanation: ` Buckets should have logging enabled so that access can be audited. `, Impact: "There is no way to determine the access to this bucket", Resolution: "Add a logging block to the resource to enable access logging", Links: []string{ "https://docs.aws.amazon.com/AmazonS3/latest/dev/ServerLogs.html", }, Terraform: &rules.EngineMetadata{ GoodExamples: terraformNoPublicAccessWithAclGoodExamples, BadExamples: terraformNoPublicAccessWithAclBadExamples, Links: terraformNoPublicAccessWithAclLinks, RemediationMarkdown: terraformNoPublicAccessWithAclRemediationMarkdown, }, CloudFormation: &rules.EngineMetadata{ GoodExamples: cloudFormationNoPublicAccessWithAclGoodExamples, BadExamples: cloudFormationNoPublicAccessWithAclBadExamples, Links: cloudFormationNoPublicAccessWithAclLinks, RemediationMarkdown: cloudFormationNoPublicAccessWithAclRemediationMarkdown, }, Severity: severity.High, }, func(s *state.State) (results rules.Results) { for _, bucket := range s.AWS.S3.Buckets { if bucket.HasPublicExposureACL() { if bucket.ACL.EqualTo("authenticated-read") { results.Add( "Bucket is exposed to all AWS accounts via ACL.", &bucket, bucket.ACL, ) } else { results.Add( fmt.Sprintf("Bucket has a public ACL: '%s'.", bucket.ACL.Value()), &bucket, bucket.ACL, ) } } else { results.AddPassed(&bucket) } } return results }, )
View Source
var CheckLoggingIsEnabled = rules.Register( rules.Rule{ AVDID: "AVD-AWS-0089", Provider: provider.AWSProvider, Service: "s3", ShortCode: "enable-bucket-logging", Summary: "S3 Bucket does not have logging enabled.", Explanation: "Buckets should have logging enabled so that access can be audited.", Impact: "There is no way to determine the access to this bucket", Resolution: "Add a logging block to the resource to enable access logging", Links: []string{ "https://docs.aws.amazon.com/AmazonS3/latest/dev/ServerLogs.html", }, Terraform: &rules.EngineMetadata{ GoodExamples: terraformEnableBucketLoggingGoodExamples, BadExamples: terraformEnableBucketLoggingBadExamples, Links: terraformEnableBucketLoggingLinks, RemediationMarkdown: terraformEnableBucketLoggingRemediationMarkdown, }, CloudFormation: &rules.EngineMetadata{ GoodExamples: cloudFormationEnableBucketLoggingGoodExamples, BadExamples: cloudFormationEnableBucketLoggingBadExamples, Links: cloudFormationEnableBucketLoggingLinks, RemediationMarkdown: cloudFormationEnableBucketLoggingRemediationMarkdown, }, Severity: severity.Medium, }, func(s *state.State) (results rules.Results) { for _, bucket := range s.AWS.S3.Buckets { if !bucket.Logging.Enabled.IsTrue() && bucket.ACL.NotEqualTo("log-delivery-write") { results.Add( "Bucket does not have logging enabled", &bucket, bucket.Logging.Enabled, ) } else { results.AddPassed(&bucket) } } return results }, )
View Source
var CheckPublicACLsAreBlocked = rules.Register( rules.Rule{ AVDID: "AVD-AWS-0086", Provider: provider.AWSProvider, Service: "s3", ShortCode: "block-public-acls", Summary: "S3 Access block should block public ACL", Impact: "PUT calls with public ACLs specified can make objects public", Resolution: "Enable blocking any PUT calls with a public ACL specified", Explanation: ` S3 buckets should block public ACLs on buckets and any objects they contain. By blocking, PUTs with fail if the object has any public ACL a. `, Links: []string{ "https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-control-block-public-access.html", }, Terraform: &rules.EngineMetadata{ GoodExamples: terraformBlockPublicAclsGoodExamples, BadExamples: terraformBlockPublicAclsBadExamples, Links: terraformBlockPublicAclsLinks, RemediationMarkdown: terraformBlockPublicAclsRemediationMarkdown, }, CloudFormation: &rules.EngineMetadata{ GoodExamples: cloudFormationBlockPublicAclsGoodExamples, BadExamples: cloudFormationBlockPublicAclsBadExamples, Links: cloudFormationBlockPublicAclsLinks, RemediationMarkdown: cloudFormationBlockPublicAclsRemediationMarkdown, }, Severity: severity.High, }, func(s *state.State) (results rules.Results) { for _, bucket := range s.AWS.S3.Buckets { if bucket.PublicAccessBlock == nil { results.Add("No public access block so not blocking public acls", &bucket) } else if bucket.PublicAccessBlock.BlockPublicACLs.IsFalse() { results.Add( "Public access block does not block public ACLs", &bucket, bucket.PublicAccessBlock.BlockPublicACLs, ) } else { results.AddPassed(&bucket) } } return results }, )
View Source
var CheckPublicACLsAreIgnored = rules.Register( rules.Rule{ AVDID: "AVD-AWS-0091", Provider: provider.AWSProvider, Service: "s3", ShortCode: "ignore-public-acls", Summary: "S3 Access Block should Ignore Public Acl", Impact: "PUT calls with public ACLs specified can make objects public", Resolution: "Enable ignoring the application of public ACLs in PUT calls", Explanation: ` S3 buckets should ignore public ACLs on buckets and any objects they contain. By ignoring rather than blocking, PUT calls with public ACLs will still be applied but the ACL will be ignored. `, Links: []string{ "https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-control-block-public-access.html", }, Terraform: &rules.EngineMetadata{ GoodExamples: terraformIgnorePublicAclsGoodExamples, BadExamples: terraformIgnorePublicAclsBadExamples, Links: terraformIgnorePublicAclsLinks, RemediationMarkdown: terraformIgnorePublicAclsRemediationMarkdown, }, CloudFormation: &rules.EngineMetadata{ GoodExamples: cloudFormationIgnorePublicAclsGoodExamples, BadExamples: cloudFormationIgnorePublicAclsBadExamples, Links: cloudFormationIgnorePublicAclsLinks, RemediationMarkdown: cloudFormationIgnorePublicAclsRemediationMarkdown, }, Severity: severity.High, }, func(s *state.State) (results rules.Results) { for _, bucket := range s.AWS.S3.Buckets { if bucket.PublicAccessBlock == nil { results.Add("No public access block so not ignoring public acls", &bucket) } else if bucket.PublicAccessBlock.IgnorePublicACLs.IsFalse() { results.Add( "Public access block does not ignore public ACLs", &bucket, bucket.PublicAccessBlock.IgnorePublicACLs, ) } else { results.AddPassed(&bucket) } } return results }, )
View Source
var CheckPublicBucketsAreRestricted = rules.Register( rules.Rule{ AVDID: "AVD-AWS-0093", Provider: provider.AWSProvider, Service: "s3", ShortCode: "no-public-buckets", Summary: "S3 Access block should restrict public bucket to limit access", Impact: "Public buckets can be accessed by anyone", Resolution: "Limit the access to public buckets to only the owner or AWS Services (eg; CloudFront)", Explanation: `S3 buckets should restrict public policies for the bucket. By enabling, the restrict_public_buckets, only the bucket owner and AWS Services can access if it has a public policy.`, Links: []string{ "https://docs.aws.amazon.com/AmazonS3/latest/dev-retired/access-control-block-public-access.html", }, Terraform: &rules.EngineMetadata{ GoodExamples: terraformNoPublicBucketsGoodExamples, BadExamples: terraformNoPublicBucketsBadExamples, Links: terraformNoPublicBucketsLinks, RemediationMarkdown: terraformNoPublicBucketsRemediationMarkdown, }, CloudFormation: &rules.EngineMetadata{ GoodExamples: cloudFormationNoPublicBucketsGoodExamples, BadExamples: cloudFormationNoPublicBucketsBadExamples, Links: cloudFormationNoPublicBucketsLinks, RemediationMarkdown: cloudFormationNoPublicBucketsRemediationMarkdown, }, Severity: severity.High, }, func(s *state.State) (results rules.Results) { for _, bucket := range s.AWS.S3.Buckets { if bucket.PublicAccessBlock == nil { results.Add("No public access block so not restricting public buckets", &bucket) } else if bucket.PublicAccessBlock.RestrictPublicBuckets.IsFalse() { results.Add( "Public access block does not restrict public buckets", &bucket, bucket.PublicAccessBlock.RestrictPublicBuckets, ) } else { results.AddPassed(&bucket) } } return results }, )
View Source
var CheckPublicPoliciesAreBlocked = rules.Register( rules.Rule{ AVDID: "AVD-AWS-0087", Provider: provider.AWSProvider, Service: "s3", ShortCode: "block-public-policy", Summary: "S3 Access block should block public policy", Impact: "Users could put a policy that allows public access", Resolution: "Prevent policies that allow public access being PUT", Explanation: ` S3 bucket policy should have block public policy to prevent users from putting a policy that enable public access. `, Links: []string{ "https://docs.aws.amazon.com/AmazonS3/latest/dev-retired/access-control-block-public-access.html", }, Terraform: &rules.EngineMetadata{ GoodExamples: terraformBlockPublicPolicyGoodExamples, BadExamples: terraformBlockPublicPolicyBadExamples, Links: terraformBlockPublicPolicyLinks, RemediationMarkdown: terraformBlockPublicPolicyRemediationMarkdown, }, CloudFormation: &rules.EngineMetadata{ GoodExamples: cloudFormationBlockPublicPolicyGoodExamples, BadExamples: cloudFormationBlockPublicPolicyBadExamples, Links: cloudFormationBlockPublicPolicyLinks, RemediationMarkdown: cloudFormationBlockPublicPolicyRemediationMarkdown, }, Severity: severity.High, }, func(s *state.State) (results rules.Results) { for _, bucket := range s.AWS.S3.Buckets { if bucket.PublicAccessBlock == nil { results.Add("No public access block so not blocking public policies", &bucket) } else if bucket.PublicAccessBlock.BlockPublicPolicy.IsFalse() { results.Add( "Public access block does not block public policies", &bucket, bucket.PublicAccessBlock.BlockPublicPolicy, ) } else { results.AddPassed(&bucket) } } return results }, )
View Source
var CheckVersioningIsEnabled = rules.Register( rules.Rule{ AVDID: "AVD-AWS-0090", Provider: provider.AWSProvider, Service: "s3", ShortCode: "enable-versioning", Summary: "S3 Data should be versioned", Impact: "Deleted or modified data would not be recoverable", Resolution: "Enable versioning to protect against accidental/malicious removal or modification", Explanation: ` Versioning in Amazon S3 is a means of keeping multiple variants of an object in the same bucket. You can use the S3 Versioning feature to preserve, retrieve, and restore every version of every object stored in your buckets. With versioning you can recover more easily from both unintended user actions and application failures. `, Links: []string{ "https://docs.aws.amazon.com/AmazonS3/latest/userguide/Versioning.html", }, Terraform: &rules.EngineMetadata{ GoodExamples: terraformEnableVersioningGoodExamples, BadExamples: terraformEnableVersioningBadExamples, Links: terraformEnableVersioningLinks, RemediationMarkdown: terraformEnableVersioningRemediationMarkdown, }, CloudFormation: &rules.EngineMetadata{ GoodExamples: cloudFormationEnableVersioningGoodExamples, BadExamples: cloudFormationEnableVersioningBadExamples, Links: cloudFormationEnableVersioningLinks, RemediationMarkdown: cloudFormationEnableVersioningRemediationMarkdown, }, Severity: severity.Medium, }, func(s *state.State) (results rules.Results) { for _, bucket := range s.AWS.S3.Buckets { if !bucket.Versioning.Enabled.IsTrue() { results.Add( "Bucket does not have versioning enabled", &bucket, bucket.Versioning.Enabled, ) } else { results.AddPassed(&bucket) } } return results }, )
Functions ¶
This section is empty.
Types ¶
This section is empty.
Source Files ¶
- block_public_acls.cf.go
- block_public_acls.go
- block_public_acls.tf.go
- block_public_policy.cf.go
- block_public_policy.go
- block_public_policy.tf.go
- enable_bucket_encryption.cf.go
- enable_bucket_encryption.go
- enable_bucket_encryption.tf.go
- enable_bucket_logging.cf.go
- enable_bucket_logging.go
- enable_bucket_logging.tf.go
- enable_versioning.cf.go
- enable_versioning.go
- enable_versioning.tf.go
- ignore_public_acls.cf.go
- ignore_public_acls.go
- ignore_public_acls.tf.go
- no_public_access_with_acl.cf.go
- no_public_access_with_acl.go
- no_public_access_with_acl.tf.go
- no_public_buckets.cf.go
- no_public_buckets.go
- no_public_buckets.tf.go
- specify_public_access_block.cf.go
- specify_public_access_block.go
- specify_public_access_block.tf.go
Click to show internal directories.
Click to hide internal directories.