Post

AWS S3(3) - 보안

1. Amazon S3 – Object Encryption

  • You can encrypt objects in S3 buckets using one of 4 methods

    ⇒ 총 4가지 방식으로 S3 object 암호화가 가능하다

  • Server-Side Encryption (SSE)

    1) Server-Side Encryption with Amazon S3-Managed Keys (SSE-S3) – Enabled by Default

    • Encrypts S3 objects using keys handled, managed, and owned by AWS

      ⇒ SSE-S3 : key를 이용한 조작, 관리를 진행하고 AWS의 소유이다

    2) Server-Side Encryption with KMS Keys stored in AWS KMS (SSE-KMS)

    • Leverage AWS Key Management Service (AWS KMS) to manage encryption keys

      ⇒ AWS KMS를 이용해서 암호화 키를 다룬다

    3) Server-Side Encryption with Customer-Provided Keys (SSE-C)

    • When you want to manage your own encryption keys

      ⇒ 본인 소유의 암호화 key를 관리하고 싶을 때 사용한다

  • Client-Side Encryption

    ⇒ 클라이언트 사이드에서의 암호화

  • It’s important to understand which ones are for which situation for the exam

    ⇒ 시험 때 나오므로 꼭 기억할 것

2. Amazon S3 Encryption – SSE-S3

  • Encryption using keys handled, managed, and owned by AWS

    ⇒ AWS 소유의 key를 이용한 암호화 방식

  • Object is encrypted server-side

    ⇒ 서버사이드 에서의 object

  • Encryption type is AES-256

    ⇒ AES-256으로 암호화

  • Must set header “x-amz-server-side-encryption”: “AES256”

    ⇒ x-amz-server-side-encryption 헤더값을 “AES256”으로 줄 것

  • Enabled by default for new buckets & new objects

    ⇒ 새로운 buckets과 새로운 object에 대해 기본값으로 암호화가 된다

Untitled

3. Amazon S3 Encryption – SSE-KMS

  • Encryption using keys handled and managed by AWS KMS (Key Management Service)

    ⇒ AWS KMS key를 이용한 암호화 방식

  • KMS advantages: user control + audit key usage using CloudTrail

    ⇒ 사용자 제어 + CloudTrail을 이용한 audit key

  • Object is encrypted server side

    ⇒ object가 서버사이드에서 암호화 된다

  • Must set header “x-amz-server-side-encryption”: “aws:kms”

    ⇒ x-amz-server-side-encryption 헤더값을 “aws:kms”으로 줄 것

Untitled 1

4, SSE-KMS Limitation (SSE-KMS 한계점)

  • If you use SSE-KMS, you may be impacted by the KMS limits

    ⇒ SSE-KMS를 사용할 경우, KMS의 제한선 안에서 진행되게 된다

  • When you upload, it calls the GenerateDataKey KMS API

    ⇒ 업로드 시, 이를 “GenerateData Key KMS API”라 부른다

  • When you download, it calls the Decrypt KMS API

    ⇒ 다운로드 시, 이를 “Decrypt KMS API”라 부른다

  • Count towards the KMS quota per second (5500, 10000, 30000 req/s based on region)
  • You can request a quota increase using the Service Quotas Console

    사용자는 Service Quota Console을 이용해서 quota 요청을 늘릴 수 있다

Untitled 2

5. Amazon S3 Encryption – SSE-C

  • Server-Side Encryption using keys fully managed by the customer outside of AWS

    ⇒ AWS 외부의 고객에 의해 암호화 되는 Server-side에서의 key

  • Amazon S3 does NOT store the encryption key you provide

    ⇒ Amazon S3는 당신이 직접 제공하는 암호화 키를 저장하지 않는다

  • HTTPS must be used

    ⇒ HTTPS 필수

  • Encryption key must provided in HTTP headers, for every HTTP request made

    ⇒ 암호화 키는 매 HTTP Request 생성 시, 반드시 HTTP 헤더에 명시되어 있어야한다

Untitled 3

6. Amazon S3 Encryption – Client-Side Encryption

  • Use client libraries such as Amazon S3 Client-Side Encryption Library

    ⇒ AWS S3 Client-Side Encryption 라이브러리와 같은 클라이언트 라이브러리를 사용한다

  • Clients must encrypt data themselves before sending to Amazon S3

    ⇒ 클라이언트는 AWS S3에 전송 전, 데이터들을 암호화 시켜야 한다

  • Clients must decrypt data themselves when retrieving from Amazon S3

    ⇒ 클라이언트는 AWS S3로부터 검색 시, 데이터들을 복호화 시켜야한다

  • Customer fully manages the keys and encryption cycle

    ⇒ 고객은 key와 암호화 사이클에 대한 모든것을 관리한다

Untitled 4

7. Amazon S3 – Encryption in transit (SSL/TLS)

  • Encryption in flight is also called SSL/TLS

    ⇒ 전송 중의 암호화상태를 SSL/TLS라 부른다

  • Amazon S3 exposes two endpoints:
    • HTTP Endpoint – non encrypted

      ⇒ HTTP 엔드포인트는 암호화되어있지 않는다

    • HTTPS Endpoint – encryption in flight

      ⇒ HTTPS 엔드포인트는 암호화 되어있다

  • HTTPS is recommended

    ⇒ HTTPS가 권장된다

  • HTTPS is mandatory for SSE-C

    ⇒ HTTPS는 SSE-C가 필수이다

  • Most clients would use the HTTPS endpoint by default

    ⇒ 대부분 클라이언트는 기본적으로 HTTPS엔드포인트를 사용한다

8. Amazon S3 – Force Encryption in Transit aws:SecureTransport

Untitled 5

9. Amazon S3 – Default Encryption vs. Bucket Policies

  • SSE-S3 encryption is automatically applied to new objects stored in S3 bucket

    ⇒ SSE-S3 암호화는 S3에 저장된 새로운 object에 자동적으로 적용된다

  • Optionally, you can “force encryption” using a bucket policy and refuse any API call to PUT an S3 object without encryption headers (SSE-KMS or SSE-C)

    ⇒ 선택적으로, Bucket 정책을 이용하여 강제 암호화를 할 수 있고, encryption header 없이 PUT요청이 들어왔을때 이를 거부할수 있다

Untitled 6

  • Note: Bucket Policies are evaluated before “Default Encryption”

    ⇒ Bucket 정책은 모두 “Default Encryption”이 적용된 상태이다

10. What is CORS?

  • Cross-Origin Resource Sharing (CORS)
  • Origin = scheme (protocol) + host (domain) + port
  • Web Browser based mechanism to allow requests to other origins while visiting the main origin

    ⇒ 웹브라우저는 main origin을 방문하는중, 다른 origin을 향한 request에 대한 허용을 베이스로 한다

  • Same origin: http://example.com/app1 & http://example.com/app2
  • Different origins: http://www.example.com/ & http://other.example.com/
  • The requests won’t be fulfilled unless the other origin allows for the requests, using CORS Headers (example: Access-Control-Allow-Origin)

Untitled 7

11. Amazon S3 – CORS

Untitled 8

  • If a client makes a cross-origin request on our S3 bucket, we need to enable the correct CORS headers

    ⇒ 만약, 클라이언트가 cross-origin 리퀘스트를 S3 버켓에 요청할 경우, CORS header가 올바른지 확인할 필요가 있다

  • It’s a popular exam question (가장 유명한 시험문제)
  • You can allow for a specific origin or for * (all origins)

    ⇒ 특정 origin을 지정하거나, 또는 *표시를 통해 모든 origin 지정이 가능하다

12. Amazon S3 – MFA Delete

  • MFA (Multi-Factor Authentication) – force users to generate a code on a device (usually a mobile phone or hardware) before doing important operations on S3

    ⇒ MFA를 통해 S3내의 기능 시연 전, 폰이나 하드같은 디바이스를 통한 코드 생성이 가능하다

  • MFA will be required to:
    • Permanently delete an object version

      ⇒ 영구적으로 오래된 버전의 object 삭제가 가능하다

    • Suspend Versioning on the bucket

      ⇒ 버켓 내의 versioning을 더 유예할 수 있다

  • MFA won’t be required to:
    • Enable Versioning

      ⇒ Versioning 활성화 가능

    • List deleted versions

      ⇒ 삭제된 version 리스트

  • To use MFA Delete, Versioning must be enabled on the bucket

    ⇒ MFA Delete를 사용하여, Versioning을 bucket내에서 활성화 하도록 해야한다

  • Only the bucket owner (root account) can enable/disable MFA Delete

    ⇒ 오직 bucket 소유주만 MFA delete를 활성화/비활성화 가능

13. S3 Access Logs

Untitled 9

  • For audit purpose, you may want to log all access to S3 buckets

    ⇒ S3 버켓에 접근한 모든 로그들이 필요할지도 모른다

  • Any request made to S3, from any account, authorized or denied, will be logged into another S3 bucket

    ⇒ S3에 만든 request, 다양한 계정, 인가되거나 비인가된, 다른 S3 bucket에 로깅될것이다

  • That data can be analyzed using data analysis tools…

    ⇒ 데이터 분석 툴을 이용해 데이터 분석이 가능하다

  • The target logging bucket must be in the same AWS region

    ⇒ 로깅된 타겟 버켓은 오로지 같은 AWS region 내에서 진행되어야만 한다

  • The log format is at: https://docs.aws.amazon.com/AmazonS3/latest/dev/LogFormat.html

14. S3 Access Logs: Warning

Untitled 10

  • Do not set your logging bucket to be the monitored bucket

    ⇒ logging bucket을 설정하지 말 것

  • It will create a logging loop, and your bucket will grow exponentially

    ⇒ 이는 무한반복 루프를 부를 것이고, bucket이 걷잡을수없이 증가할 것이다

15. Amazon S3 – Pre-Signed URLs

Untitled 11

  • Generate pre-signed URLs using the S3 Console, AWS CLI or SDK

    ⇒ S3 콘솔, AWS CLI 또는 SDK를 이용해서 pre-signed URL을 생성한다

  • URL Expiration
    • S3 Console – 1 min up to 720 mins (12 hours)
    • AWS CLI – configure expiration with –expires-in parameter in seconds (default 3600 secs, max. 604800 secs ~ 168 hours)
  • Users given a pre-signed URL inherit the permissions of the user that generated the URL for GET / PUT

    ⇒ pre-signed URL은 GET이나 PUT에 대한 URL로 인해 생성된 사용자의 권한을 인계받는다

  • Examples:
    • Allow only logged-in users to download a premium video from your S3 bucket

      ⇒ 오로지 로그인한 유저에 대해서만 S3 bucket에서 프리미엄 비디오 다운이 가능토록 함

    • Allow an ever-changing list of users to download files by generating URLs dynamically

      ⇒ 끊임없이 변화하는 사용자 리스트에 대해 동적으로 생성되는 URL에 의해 파일을 다운로드 한다

    • Allow temporarily a user to upload a file to a precise location in your S3 ⇒ 임시적으로 S3의 정밀한 위치에 파일 업로드가 허용되도록 한다

16. Glacier Vault Lock

Untitled 12

  • Adopt a WORM (Write Once Read Many) model

    ⇒ WORM 모델을 적용

  • Create a Vault Lock Policy

    ⇒ Vault Lock 정책 생성

  • Lock the policy for future edits (can no longer be chagned or deleted)

    ⇒ 정책 잠금

  • Helpful for compliance and data retention

    ⇒ 정책 준수 및 데이터 유지에 도움이 된다

17. S3 Object Lock (versioning이 반드시 적용되어야 한다)

  • Adopt a WORM (Write Once Read Many) model

    ⇒ WORM 모델이 적용됨

  • Block an object version deletion for a specified amount of time

    ⇒ 특정 시간동안 object version 삭제를 막는다

  • Retention mode - Compliance
    • Object versions can’t be overwritten or deleted by any user, including the root user

      ⇒ object 버전은 root유저가 아니면, 수정이나 삭제가 불가하다

    • Objects retention modes can’t be changed, and retention periods can’t be shortened

      ⇒ object 유지기간은 변경, 단축될 수 없다

  • Retention mode - Governance
    • Most users can’t overwrite or delete an object version or alter its lock settings

      ⇒ 대부분 사용자들은 object 버전에 대한 수정 또는 삭제가 불가능하거나 또는 lock 설정 불가하다

    • Some users have special permissions to change the retention or delete the object

      ⇒ 몇몇 사용자들은 object 삭제나 보유기간 변경에 대한 권한을 가진다

  • Retention Period: protect the object for a fixed period, it can be extended

    ⇒ 유지기간 : 고정된 기간 내에 object를 보호하고, 기간은 더 늘어날 수 있다

  • Legal Hold
    • protect the object indefinitely, independent from retention period

      ⇒ 보유기간 동안 object를 무기한, 독립적으로 보호한다

    • can be freely placed and removed using the s3:PutObjectLegalHold IAM permission

      s3:PutObjectLegalHold IAM 권한을 이용해서 설정 및 삭제를 자유롭게 할 수 있다

18. S3 – Access Points

Untitled 13

  • Access Points simplify security management for S3 Buckets

    ⇒ Access Point는 S3 Bucket에 대한 보안 관리를 단순화 시킨다

  • Each Access Point has:

    • its own DNS name (Internet Origin or VPC Origin)

      ⇒ 본인 소유 DNS

    • an access point policy (similar to bucket policy) – manage security at scale

      ⇒ access point 정책 (bucket policy랑 비슷)

19. S3 – Access Points – VPC Origin

Untitled 14

  • We can define the access point to be accessible only from within the VPC

    ⇒ VPC를 통해서만 접근 가능한 access point 정의가 가능하다

  • You must create a VPC Endpoint to access the Access Point (Gateway or Interface Endpoint)

    ⇒ 사용자는 VPC Endpoint를 만들어서 Access Point에 접근 되도록 해야한다

  • The VPC Endpoint Policy must allow access to the target bucket and Access Point

    ⇒ VPC Endpoint 정책은 타겟이될 bucket과 Access Point에 대한 접근 허용을 지정해야만 한다

20. S3 Object Lambda

Untitled 15

  • Use AWS Lambda Functions to change the object before it is retrieved by the caller application

    ⇒ 콜을 하는 application에 의해 검색 되어기기 전에 AWS lambda function를 활용하여 object를 변경해야한다

  • Only one S3 bucket is needed, on top of which we create S3 Access Point and S3 Object Lambda Access Points.

    ⇒ 오직 1개의 S3 bucket이 필요하고, 그 위에 S3 Access Point와 S3 Object 람다 Access point를 만든다

  • Use Cases

    • Redacting personally identifiable information for analytics or nonproduction environments.
    • Converting across data formats, such as converting XML to JSON.

      ⇒ XML이나 JSON과 같이 데이터 포맷을 변경할 때 사용

    • Resizing and watermarking images on the fly using caller-specific details, such as the user who requested the object.

      ⇒ object를 요청하는 user처럼 호출자를 특정하여 image의 크기를 재조절하고 워터마킹한다

This post is licensed under CC BY 4.0 by the author.