Site icon Big Data Demystified

AWS S3 Security Introduction and Access management

General Security Concepts | Good to know!

 

S3 Encryption Types  

 

Client side master key

Server Side Encryption (SSE)

3 methods for SSE

S3-Managed Keys (SSE-S3)

 

AWS KMS-Managed Keys (SSE-KMS)

Limited in velocity : http://docs.aws.amazon.com/kms/latest/developerguide/limits.html

 

Client Side KMS–Managed Customer Master Key (CMK)

Additional AWS s3 Safeguards

  1. VPN (site to site)
  2. Identity based policy (IAM)
  3. IP
  4. resource based policy , e.g. :Write Only permissions.

 

Resource Based Policy on s3 

Adding Bucket level permission (not object level) policy example

{

     “Effect”: “Allow”,

     “Principal”: {

               “AWS”: “arn:aws:iam::21111111:root”

           },

     “Action”: [“s3:ListBucket“],

     “Resource”: [“arn:aws:s3:::bucketName“]

   },

Deny Headers of unencrypted objects policy example

{
               “Sid”: “DenyUnEncryptedObjectUploads“,
               “Effect”: “Deny“,
               “Principal”: “*”,
               “Action”: “s3:PutObject“,
               “Resource”: “arn:aws:s3:::<bucket_name>/*”,
               “Condition”: {
                       “Null”: {
                              “s3:x-amz-server-side-encryption“: true
                       }
              }
          }

Deny non AWS s3 SSE encryption policy example

{
               “Sid”: “DenyIncorrectEncryptionHeader”,
               “Effect”: “Deny“,
               “Principal”: “*”,
               “Action”: “s3:PutObject“,
               “Resource”: “arn:aws:s3:::<bucket_name>/*”,
               “Condition”: {
                       “StringNotEquals”: {
                              “s3:x-amz-server-side-encryption”: “AES256
                        }
               }
          },

Deny non KMS objects policy example

{
               “Sid”: “DenyIncorrectEncryptionHeader“,
               “Effect”: “Deny“,
               “Principal”: “*”,
               “Action”: “s3:PutObject“,
               “Resource”: “arn:aws:s3:::<bucket_name>/*”,
               “Condition”: {
                   “StringNotEquals”: {
                         “s3:x-amz-server-side-encryption”: “aws:kms
                            }
                  }
          },

 

Identity based policy via IAM on s3

allow s3 read only on all buckets

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "s3:Get*",
        "s3:List*"
      ],
      "Resource": "*"
    }
  ]
}

allow s3 write only on spesific buckets

 {
 "Version": "2012-10-17",
 "Statement": [
 {
 "Effect": "Allow",
 "Action": "s3:*",
 "Resource": [
 "arn:aws:s3:::myBucekt1",
 "arn:aws:s3:::myBucekt1/*",
 "arn:aws:s3:::myBucekt2",
 "arn:aws:s3:::myBucekt2/*",
 ]
 }
 ]
}

Protecting s3 bucket from accidental delete (protect bucket delete, and policy delete)

{

    “Version”: “2012-10-17”,

    “Statement”: [

        {

            “Sid”: “Stmt1503850588772”,

            “Effect”: “Deny”,

            “Principal”: “*”,

            “Action”: “s3:DeleteBucket”,

            “Resource”: “arn:aws:s3:::walla-mail-bigfiles-eu-west-1-sse”,

            “Condition”: {

                “StringNotLike”: {

                    “aws:userId”: [

                        “xxxxxx:*”,

                        “12345”

                    ]

                }

            }

        },

        {

            “Effect”: “Deny”,

            “Principal”: “*”,

            “Action”: “s3:PutBucketPolicy”,

            “Resource”: “arn:aws:s3:::walla-mail-bigfiles-eu-west-1-sse”,

            “Condition”: {

                “StringNotLike”: {

                    “aws:userId”: [

                        “xxxxxxxx:*”,

                        “12345”

                    ]

                }

            }

        }

    ]

}

Policy to Deny put / delete of s3 policy from anyone but the admin

{
“Sid”: “Stmt1503999310000”,
“Effect”: “Deny”,
“NotPrincipal”: {
“AWS”: “arn:aws:iam::506754145427:user/omid”
},
“Action”: [
“s3:PutBucketPolicy”,
“s3:DeleteBucketPolicy”
],
“Resource”: “arn:aws:s3:::walla-anagog-eu-west-1”
}

Note : json validator to help debug syntax errors in jso

https://jsonformatter.curiousconcept.com/

 

A quick note about  life cycle policy + no delete bucket policy

I would like to confirm that if you have a policy that denies any user/principle the ability to delete an object or it’s version, you can still have a lifecycle rule to expire these objects and the policy will not prevent the lifecycle rule to execute. Lifecycle policy works from backend to process objects and will not engage API calls. So that it is not affected by bucket policy. In your scenario, even if bucket policy is defined to deny all delete operations, lifecycle policy will delete objects after it expires in 120 days and not before the set lifecycle time of 120days

 

Conclusion

 

Need to learn more about aws big data (demystified)?



——————————————————————————————————————————

I put a lot of thoughts into these blogs, so I could share the information in a clear and useful way. If you have any comments, thoughts, questions, or you need someone to consult with, feel free to contact me:

https://www.linkedin.com/in/omid-vahdaty/



Exit mobile version