63 lines
1.4 KiB
Plaintext
Raw Normal View History

2021-05-21 18:34:30 +02:00
include::../description.adoc[]
include::../ask-yourself.adoc[]
include::../recommended.adoc[]
== Sensitive Code Example
This policy allows all users, including anonymous ones, to access an S3 bucket:
2021-05-21 18:34:30 +02:00
[source,yaml]
2021-05-21 18:34:30 +02:00
----
AWSTemplateFormatVersion: 2010-09-09
Resources:
S3BucketPolicy:
Type: 'AWS::S3::BucketPolicy' # Sensitive
Properties:
Bucket: !Ref S3Bucket
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
AWS: "*" # all principals / anonymous access
Action: "s3:PutObject" # can put object
Resource: arn:aws:s3:::mybucket/*
----
== Compliant Solution
This policy allows only the authorized users:
[source,yaml]
2021-05-21 18:34:30 +02:00
----
AWSTemplateFormatVersion: 2010-09-09
Resources:
S3BucketPolicy:
Type: 'AWS::S3::BucketPolicy' # Compliant
Properties:
Bucket: !Ref S3Bucket
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
AWS:
- !Sub 'arn:aws:iam::${AWS::AccountId}:root' # only this principal
Action: "s3:PutObject" # can put object
Resource: arn:aws:s3:::mybucket/*
----
include::../see.adoc[]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
endif::env-github,rspecator-view[]