본문 바로가기

Security

[실습] Amazon Macie 구성하기 (Security Hub, EventBridge, SNS, CloudWatch 구성)

반응형

안녕하세요 서후아빠입니다. ^_^

이번 세션은 Maice에 EventBridge와 SNS, CloudWatch를 연결하여 관리자에게 알림을 보내고 Logging하는 내용과 Security Hub로 연결하는 실습을 해보겠습니다. Security Hub로 전달된 내용을 처리하는 것에 대해서는 추후 Security Hub 내용에서 다루도록 하겠습니다. 


구성도

사용자가 S3 bucket(mybucket)에 민감한 정보가 담긴 파일을 업로드하면 Macie에서 이를 탐지하면 탐지 결과를 EventBridge, Security Hub로 전달합니다. 또한, Macie의 job 로그는 CloudWatch(...classificationjobs)로 전달하고, 탐지 결과에 대해서 사용자는 S3 bucket(maciebucket)에 샘플을 저장할 수 있습니다.
EventBridge(ebRule)는 Macie의 탐지 결과를 SNS로 호출합니다.
SNS(mytopic)는 구독(user01@gtek.com)과 Publish에 연결된 Lambda(mytopicfunction)를 호출합니다.
Lambda는 event 내용을 CloudWatch Log group(/aws/lambda/mytopicfuntion)로 호출합니다.

1단계 : SNS 설정

SNS 설정에 대한 설명은 생략합니다. (아래 링크에서 2~4단계만 진행하시기 바랍니다.)

2022.08.17 - [Management] - [실습] Amazon SNS(Simple Notification Service) 실습하기

 

[실습] Amazon SNS(Simple Notification Service) 실습하기

안녕하세요 서후아빠입니다. ^_^ 이번 세션은 Amazon SNS에 대해서 실습 해보겠습니다. 구성도 1단계 : Topic (주제) 생성 Amazon SNS > Topics > Creat topic Details Encryption(옵션) Access policy(옵션) Del..

sh-t.tistory.com

2단계 : EventBridge Rule 설정

Amazon EventBridge > Rules > Create rule

Define rule detail Build event pattern Selct target(s)
Name : ebRule
Event bus : default
Enable the rule on the selected event bus : Enable
Rule type : Rule with an event pattern (or Schedule)
Event source : AWS events or EventBridge partner events (or Other or All events)
Sample event(옵션) 
- Select : AWS events (or EventBridge prtner events or Enter my own)
- Sample events : Macie Finding (여러 서비스 중 선택)
Event pattern
- Event source : AWS services (or EventBridge partners)
- AWS service : Macie (여러 서비스 중 선택)
- Event type : Macie Finding (or All Events or API Call vid CloudTrail)
Target types : AWS service (or EventBridge event bus or EventBridge API destination)
Select a target : SNS topic (여러 서비스 중 선택)
Topic : mytopic
Additional settings(추가 옵션) : -
pattern과 일치하는 event 발생 시 select target(SNS)을 호출합니다.

3단계 : Macie 활성화(Region별) 및 Security Hub 연결

Amazon Macie > Get started > View role permissions > Enable Macie (최초 활성화 시 30일 무료)

Amazon Macie > Settings

Publication of findings
Destinations 
- Publish policy findings to: Security Hub
- Publish sensitive data findings to: Security Hub
Update frequency for policy findings : 15 minutes (or 1H or 6H)

4단계 : 테스트용 File 업로드

File 생성 : 아래 내용 외 전화번호나 신용카드, 이름 등을 엑셀에 입력하여 테스트해도 됩니다.

구분 파일명 파일 내용
HTTP BASIC 인증 헤더 auth_header.txt Authorization: Basic bm9uLTk3d293d293
Proxy-Authorization: Basic bm9uLTk3cGllbnBpZW4=
HTTP 쿠키 cookie.txt Set-Cookie: id=non-97
Cookie: session=8888; lang=ja
JSON Web Token(JWT) token.txt eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6Im5vbi05NyIsImlhdCI6MTUxNjIzOTAyMn0.AqLcYeBto0xNa-4aOVtYws-UIgBbVUG2snrSWPBpxYI

Amazon S3 > Buckets > mybucket > Upload : 위의 파일 3개 업로드

5단계 : Job 만들기 (테스트)

Amazon Macie > Jobs > Create job

Choose S3 buckets Review S3 buckets Refine the scope Select managed data identifiers Select custom data identifiers Enter general settings
Select S3 buckets : mybucket - Sensitive data discovery options : One-time job (or Scheduled job) Selection type : All (or Exclude or Include or None) - Job name : maciejob
주기적으로 동작시킬 경우는 Scheduled job으로 Job을 생성하시면 됩니다.
Exclude : 제외할 민감한 정보 (ex : AWS_CREDENTIALS), Include는 반대 개념
처리하는 데이터량에 따라 비용이 청구되므로 Exclude or Include를 잘 사용할 필요가 있습니다. 

Amazon Macie > Jobs > maciejob > Status “Active(Running)” > 10분 후 > Status “Complete

6단계 : Job 동작 결과 확인

Amazon Macie > By job : 3개의 파일 검출되었음을 확인할 수 있음, 자세한 내용은 Findings에서 확인 가능
Amazon Macie > Findings : 검출된 내용을 선택하여 상세 내용 확인

구분 검출 항목 검출 내용
HTTP BASIC 인증 헤더 Credentials Http basic auth header : 2
HTTP 쿠키 Credentials Http cookie 2
JSON Web Token(JWT) Credentials Json web token 1

CloudWatch > Log groups > /aws/macie/classificationjobs (자동 생성) > 3개의 로그 확인 (job 생성/실행/완료)
CloudWatch > Log groups > /aws/lambda/mytopicfunction : 로깅 확인

수신 메일(aws에서 user01@gtek.com로 발송된 메일) 확인

별첨 : 탐지 결과 S3로 내보내기

탐지된 민감한 데이터에 대해서 S3로 저장하여 샘플 데이터로 사용할 수 있습니다.

Amazon Macie > Discovery results

Select Create a bucket Advanced
Create bucket (or Existing bucket) maciebucket Data discovery result prefix : 
Block all public access : Yes (or No) 
Encryption settings : mykey

별첨 : 정규식으로 사용자 지정 데이터 생성

오탐지 및 미탐지 내용에 대해서 정규식으로 만들 수 있는 기능입니다. 

Amazon Macie > Custom data identifiers > Create

New custom data identifier Evaluate
Name : 이름
Regular expression : 일치하는 패턴 정의하는 정규식
Keywords (옵션) : 일치하는 단어, 최대 50개, ‘,’로 구분
Ignore words (옵션) : 결과에서 제외할 단어, 최대 10개, ‘,’로 구분
Maximum match distance (옵션) : 정규식 패턴과 일치하는 단어와 키워드 사이 허용 거리, 기본값 50
Severity : Use Medium severity for any number of matches (default)
(or Use custom settings to determine severity)
샘플 데이터 입력하여 
좌측의 설정에 대해서 
테스트하는 곳

별첨 : Etc

Amazon Macie > Summary : S3 버킷 정보(공개 액세스, 암호화 여부, 공유), 검출 수 상위 S3 버킷, 상위 발견 항목 유형, 정책 결과

  - 공개 액세스 : 최소 공개에 대한 검토 시 참조

  - 암호화 : 최대 암호화에 대한  검토 시 참조

  - 공유 : 최소 공유에 대한  검토 시 참조

Amazon Macie > By bucket : 개인 (or 조직) 계정의 bucket 검출 수 확인 
Amazon Macie > By type : 개인 (or 조직) 계정의 bucket의 공개 액세스, 암호화 여부, 공유 등 확인

Amazon Macie > S3 buckets : 개인 (or 조직) 계정의 bucket 정보 확인
Amazon Macie > Usage : 예상 비용(월간 누계) 확인
Amazon Macie > Settings

  - Permissions : 권한 확인

  - Delegated administrator : Organizations 연계해서 Macie 관리자 지정

  - Publication of findings : Policy or Sensitive data 발견 시 Security Hub로 전달하는 빈도(기본 15분, 1시간, 6시간) 설정

  - Sample findings : 결과 예제를 생성하여 사용자가 참조하도록 하는 기능, 생성하면 "Amazon Macie > Findings"에서 확인 가능

  - Suspend Macie :  서비스 일시 중단

  - Disable Macie : 서비스 중지
Amazon Macie > Account : 조직 계정 추가 및 목록 확인

Amazon Macie > Reveal samples : 검출된 결과를 토대로 민감한 데이터 샘플을 만드는 기능으로 “Amazon Macie > Discovery results”에서 S3를 활성화해야 하며, Custom KMS key도 필요

Sample findings을 생성하여 Macie가 탐지하는 Log 내용(형식과 정보)가 담겨 있는지 알아보시기 바랍니다.
반응형