We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Security

Click to play video

Cloud security is a giant can of worms. This isn't a security course, but I do want to give you a few pointers to keep you safe with a simple setup while using S3. A few things to think about:

  1. Who can access your bucket, and which parts of your bucket can they access?
  2. What actions can they take?
  3. How are they authenticated? And from where can they authenticate?

At the moment, in your Tubely app:

  1. Your bucket is publicly accessible. Anyone can get any individual object in your bucket.
  2. Anyone can get the objects in your bucket, but only Tubely (and you) can change them or list them.
  3. Public readers aren't authenticated, but your code is authenticated with your AWS IAM access key.

Keys Aren't Enough

While it's great that an attacker would need to steal your AWS credentials to be able to maliciously change the contents of your bucket, relying only on the secrecy of keys is often not enough.

Keys and passwords are compromised all the time.

One way to add an additional layer of security is to ensure that your keys can only be used from certain (virtual) locations. Then an attacker would need your keys and to be on your network to gain access.

Assignment

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "VisualEditor0",
      "Effect": "Allow",
      "Action": "*",
      "Resource": "*",
      "Condition": {
        "IpAddress": {
          "aws:SourceIp": "0.0.0.0/32"
        }
      }
    }
  ]
}

AWS will warn about the wildcard actions and resources. That's expected here: the IP condition is the temporary restriction. We'll scope permissions down later.

aws s3 cp <local_file_path> s3://<bucket_name>

You should get denied because your IP address is not allowed (your address isn't 0.0.0.0)

Run and submit the CLI tests.

Your IP address can change, e.g. from switching networks or dynamic IP addresses. Whenever that happens, you'll need to update the policy.