S3 bucket allows put action from all principals 이 페이지는 아직 한국어로 제공되지 않습니다. 번역 작업 중입니다.
현재 번역 프로젝트에 대한 질문이나 피드백이 있으신 경우
언제든지 연락주시기 바랍니다. Id: terraform-aws-s3-bucket-allows-put-action-from-all-principals
Provider: AWS
Platform: Terraform
Severity: Critical
Category: Access Control
Learn More Description When an S3 bucket policy allows PUT actions from all principals (*), it creates a significant security risk by permitting anyone on the internet to upload files to your bucket. This vulnerability can lead to data tampering, malicious file uploads, increased storage costs, and potentially serve as an attack vector for distributing malware or other harmful content through your infrastructure. To secure your S3 bucket, explicitly deny open PUT permissions, as shown below, or restrict access to specific principals:
// Insecure configuration
Statement : [
{
"Effect": "Allow" ,
"Principal": "*" ,
"Action": "s3:PutObject"
}
]
// Secure configuration
Statement : [
{
"Effect": "Deny" ,
"Action": "s3:*"
}
]
Compliant Code Examples resource "aws_s3_bucket_policy" "negative1" {
bucket = aws_s3_bucket . b . id
policy = < < POLICY
{
"Version" : "2012-10-17" ,
"Id" : "MYBUCKETPOLICY" ,
"Statement" : [
{
"Sid" : "IPAllow" ,
"Effect" : "Deny" ,
"Action" : "s3:*" ,
"Resource" : "arn:aws:s3:::my_tf_test_bucket/*" ,
"Condition" : {
"IpAddress" : { "aws:SourceIp" : "8.8.8.8/32" }
}
}
]
}
POLICY
}
module "s3_bucket" {
source = "terraform-aws-modules/s3-bucket/aws"
version = "3.7.0"
bucket = "my-s3-bucket"
acl = "private"
versioning = {
enabled = true
}
policy = < < POLICY
{
"Version" : "2012-10-17" ,
"Id" : "MYBUCKETPOLICY" ,
"Statement" : [
{
"Sid" : "IPAllow" ,
"Effect" : "Deny" ,
"Action" : "s3:*" ,
"Resource" : "arn:aws:s3:::my_tf_test_bucket/*" ,
"Condition" : {
"IpAddress" : { "aws:SourceIp" : "8.8.8.8/32" }
}
}
]
}
POLICY
}
Non-Compliant Code Examples resource "aws_s3_bucket_policy" "positive1" {
bucket = aws_s3_bucket . b . id
policy = < < POLICY
{
"Version" : "2012-10-17" ,
"Id" : "MYBUCKETPOLICY" ,
"Statement" : [
{
"Sid" : "IPAllow" ,
"Effect" : "Allow" ,
"Principal" : "*" ,
"Action" : "s3:PutObject" ,
"Resource" : "arn:aws:s3:::my_tf_test_bucket/*" ,
"Condition" : {
"IpAddress" : { "aws:SourceIp" : "8.8.8.8/32" }
}
}
]
}
POLICY
}
resource "aws_s3_bucket_policy" "positive2" {
bucket = aws_s3_bucket . b . id
policy = < < POLICY
{
"Version" : "2012-10-17" ,
"Id" : "MYBUCKETPOLICY" ,
"Statement" : [
{
"Sid" : "IPAllow" ,
"Effect" : "Allow" ,
"Principal" : {
"AWS" : "*"
},
"Action" : "s3:PutObject" ,
"Resource" : "arn:aws:s3:::my_tf_test_bucket/*" ,
"Condition" : {
"IpAddress" : { "aws:SourceIp" : "8.8.8.8/32" }
}
}
]
}
POLICY
}
module "s3_bucket" {
source = "terraform-aws-modules/s3-bucket/aws"
version = "3.7.0"
bucket = "my-s3-bucket"
acl = "private"
versioning = {
enabled = true
}
policy = < < POLICY
{
"Version" : "2012-10-17" ,
"Id" : "MYBUCKETPOLICY" ,
"Statement" : [
{
"Sid" : "IPAllow" ,
"Effect" : "Allow" ,
"Principal" : {
"AWS" : "*"
},
"Action" : "s3:PutObject" ,
"Resource" : "arn:aws:s3:::my_tf_test_bucket/*" ,
"Condition" : {
"IpAddress" : { "aws:SourceIp" : "8.8.8.8/32" }
}
}
]
}
POLICY
}