Weitere ähnliche Inhalte Ähnlich wie IAM 정책을 잘 알아야 AWS 보안도 쉬워진다. 이것은 꼭 알고 가자! - 신은수 솔루션즈 아키텍트, AWS :: AWS Summit Seoul 2019 Ähnlich wie IAM 정책을 잘 알아야 AWS 보안도 쉬워진다. 이것은 꼭 알고 가자! - 신은수 솔루션즈 아키텍트, AWS :: AWS Summit Seoul 2019 (20) Mehr von Amazon Web Services Korea Mehr von Amazon Web Services Korea (20) IAM 정책을 잘 알아야 AWS 보안도 쉬워진다. 이것은 꼭 알고 가자! - 신은수 솔루션즈 아키텍트, AWS :: AWS Summit Seoul 20191. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
IAM 을 잘 알아야 보안도
쉬워진다.
이것은 꼭 알고 가자!신은수
Security Specialist Solutions Architect
2. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
3. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
• 구독한 모든 서비스에 대한 접근
• 과금 정보에 대한 접근
• 콘솔 및 API 사용
• 기술 지원 계약 변경
Account Owner ID (Root Account)
AWS 서비스 사용 – 계정 생성
• 지정된 일부 서비스에 대한 접근
• 콘솔 및 API 사용
• 기술지원 요청
IAM 사용자, 역할, Federated 사용자
• 지정된 일부 서비스에 대한 접근
• 콘솔 및 API 사용
어플리케이션을 위한 임시 보안 자격 증명
4. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS 서비스 사용 – Console 기반 작업
! 쉽게 시작할 수 있다.
" 반복작업에 적합하지 않다.
" 시간이 오래 걸린다. 수작업
High
level
Low
level
5. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS 서비스 사용 – Script 기반 작업
Script 기반
수작업
! 반복 작업에 적합하다.
! 원하는 항목에 대한 수정이 용이하다.
" 리소스의 준비 상태 확인이 어렵다.
" 문제 발생 시 복원이 어렵다.
High
level
Low
level
6. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS 서비스 사용 – 프로비저닝 엔진 사용
AWS CloudFormation
template
(JSON/YAML)
HashiCorp Configuration
Language (HCL)
원하는 형상에 대한 정의
Declarative 방식
Script 기반
수작업
High
level
Low
level
! 자동화 구현에 용이하다.
! 반복작업에 적합하다.
! 에러 발생 시 원복이 쉽다.
" 최초 구현이 복잡하다.
7. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Troposphere Python
SparkleFormation Ruby
GoFormation Go
…
AWS
CloudFormation
Template
! 코드 기반♥
! 원하는 형상에 대한 정의
# 초기 코딩의 복잡성
DOM 모델
Declarative 방식
Script 기반
수작업
High
level
Low
level
AWS 서비스 사용 – DOM 모델 적용
8. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS
CloudFormation
template
AWS CDK application
Stack(s)
Construct Construct
Component 화
DOM 기반
Declarative 기반
Script 기반
수작업
High
level
Low
level
리소스 생성
AWS 서비스 사용 – CDK 사용 Developer preview
9. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Cloud
결국 중요한 건 - API
VPC
CloudWatch Cloud Formation CloudTrail Event
ELB
사용자 요청
Command Line Interface
SDK
Management Console
API
API API
10. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
SigV4 를 사용한 API 호출 예제
POST /API-Request HTTP/1.1
Host: any-aws-services.us-east-1.amazonaws.com
Content-Type: application/x-www-form-urlencoded
Authorization: AWS4-HMAC-SHA256
Credential=AccessKeyIDEXAMPLE/20181126/us-east-1/sqs/aws4_request,
SignedHeaders=content-type;host;x-amz-date,
Signature=b97dfa904a5beffSecretKey를포함한16진수
61c982a1b6f458b799221646efd99d3219ec94cdf2500
X-Amz-Date: 20190418T123600Z
def sign(key, msg):
return hmac.new(key, msg.encode("utf-8"), hashlib.sha256).digest()
def getSignatureKey(key, dateStamp, regionName, serviceName):
kDate = sign(("AWS4" + key).encode("utf-8"), dateStamp)
kRegion = sign(kDate, regionName)
kService = sign(kRegion, serviceName)
kSigning = sign(kService, "aws4_request")
return kSigning
11. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
I A M
12. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
IAM Policy 란?
Policy 는 AWS 서비스와 리소스에 대한 인가 기능을 제공합니다.
Policy 를 정의할 때는 어떤 IAM Principal 이 어떤 Condition 에서 AWS 의 어떤
Resource 에 대해 어떤 Action 을 허용 혹은 차단할 것인지를 지정합니다.
IAM 은 여러분이 정의한 Policy 를 기반으로 API 요청을 검사/평가 하게되며
최종적으로 허용 혹은 차단을 결정합니다.
13. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
IAM Policy 의 종류와 사용 목적
AWS Organizations
Service Control Policies (SCPs)
Specific AWS ser vices
Resource-based Policies
AWS Identity and Access Management (IAM)
Permission Policies, Permission Boundaries
AWS Security Token Ser vice (AWS STS)
Session Policies
VPC Endpoints
Endpoint Policies
어카운트 내의 특정 Principal 에 대한
서비스 제어
역할 전환이나 Federation 시 권한을
제어
다수 계정 접속이나 서비스로부터의
접근을 제어
VPC Endpoint 에서 서비스로의 접근을
제어
IAM Principal(Users, Roles)에 대한 상세
권한 설정 및 사용 가능한 권한 경계
모든 Policy 는 동일한 문법을 사용(S3 ACL
예외)
14. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
IAM Policy 의 종류와 사용 목적
15. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
IAM Policy 의 구조
{
"Statement":[{
"Effect":”Allow or
Deny",
"Principal":"principal",
"Action":"action",
"Resource":"arn",
"Condition":{
"condition":{
"key":"value" }
}
}
]
}
Principal – 접근을 허용 혹은 차단하고자 하는 대상
"Principal":"AWS":"arn:aws:iam::123456789012:user/username"
Action – 허용 혹은 차단하고자하는 접근 타입
"Action":"s3:GetObject"
Resource – 요청의 목적지가 되는 서비스
"Resource":"arn:aws:sqs:us-west-2:123456789012:queue1"
Condition – 명시된 조건 유효하다고 판단될 수 있는 조건
"StringEqualsIfExists": {"aws:RequestTag/project": [“Pickles“]}
Effect – 명시된 정책에 대한 허용 혹은 차단
16. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
IAM 권한 할당 원리의 이해
17. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Permission
Policy
명시적
Deny
API
요청
Permission
Boundary
묵시적
Deny
명시적
Deny
Allow
묵시적
Deny
Allow
권한 할당 원칙 #1 – 명시적 Deny, 묵시적 Deny
Deny Deny
18. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
권한 할당 원칙 #2 – 명시적 허용
Permission
Policy
명시적
Deny
API 요청
Permission
Boundary
Allow Allow
요청 허용
19. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
권한 할당 예제
Permission PolicyPermission Boundary
API 요청: s3:GetObject / 버킷명: KoreaSummit
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream”,
"logs:PutLogEvents”
],
"Resource": "arn:aws:logs:*:*:*"
}
}
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"s3:*"
],
"Resource": "*"
}
]
}
20. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
적용된 권한 결과
Permission
Policy
명시적
Deny
API
요청:
s3:getobject
Permission
Boundary
Allow
요청 차단
묵시적
Deny
21. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Permission PolicyPermission Boundary
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream”,
"logs:PutLogEvents”
],
"Resource": "arn:aws:logs:*:*:*"
},
{
"Effect": "Allow",
"Action": ["s3:GetObject"],
"Resource”:"arn:aws:s3:::KoreaSummit/*"
}
}
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"s3:*"
],
"Resource": "*"
}
]
}
권한 할당 예제
API 요청: s3:GetObject / 버킷명: KoreaSummit
22. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Permission
Policy
명시적
Deny
API
요청:
s3:getobject
Permission
Boundary
Allow
요청 허용
Allow
적용된 권한 결과
23. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Permission PolicyPermission Boundary
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream”,
"logs:PutLogEvents”
],
"Resource": "arn:aws:logs:*:*:*"
},
{
"Effect": "Allow",
"Action": ["s3:GetObject"],
"Resource”:"arn:aws:s3:::KoreaSummit/*"
}
}
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
],
"Resource": "*"
}
]
}
API 요청: s3:GetObject / 버킷명: KoreaSummit
권한 할당 예제
24. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Permission
Policy
명시적
Deny
API
요청:
s3:getobject
Permission
Boundary
묵시적
Deny
Allow
적용된 권한 결과
요청 차단
25. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
명시적
Deny
API
요청 Permission
Boundary
SCP
Permission
Policy
Resource
Policy
허용 권한 획득 조건 – 동일 계정
26. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
API
요청
허용 권한 획득 조건 – 다른 계정
Resource
Policy
명시적
Deny
Permission
Boundary
SCP
Permission
Policy
목적지 계정출발지 계정
27. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
허용 권한 획득 조건 – 단일 계정
Permission
Policy Resource Policy
최종 획득 권한
s3:*, ec2:*
"Action":["ec2:*"] "Action":["s3:*"]
28. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
허용 권한 획득 조건 – 교차 조건
Permission
Boundary
Permission
Policy
최종 획득
권한
29. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
허용 권한 획득 조건
Permission
Boundary
Permission
Policy
Service control
policy
Session
Policy
Resource Policy
최종 획득
권한
30. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
IAM 사용 TIP
31. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
IAM Role 의 활용
보안성
임시 보안 자격
증명의 사용
편리성
다수의 사용자나
어플리케이션이 사용할 수
있으므로 권한 관리가 편리
무료
별도의 과금 없음
32. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
IAM Role 활용 – IAM 사용자 권한 최소화
User: UserA
IAM Policy:
Allow: sts:AssumeRole
Deny: *(AssumeRole 을 제외)
Group: AccessOnly
할당된 정책
Role: EC2
Administrator
Policy:
EC2AdminPolicy
IAM Policy:
Allow: ec2:*
Deny: *(AssumeRole 을 제외)
Role 로 전환
적용된 정책
Action: EC2 Create
Instance
실행
Logs:
“userIdentity”: {
“type”:“AssumedRole”,
…
“username”:“UserA”
로그
개별 사용자에게
할당되는 권한을 최소화
특정 역할에 할당되는
권한을 최적화
33. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
IAM Role – EC2 상의 어플리케이션
"Code" : "Success",
"LastUpdated" : "2019-04-12T02:11:34Z",
"Type" : "AWS-HMAC",
"AccessKeyId" : "ASIA4M5UW2CW5EHAWFAN",
"SecretAccessKey" : "v1dmbdKpv4lB94VhU8ku+c4e2hOexfhNf4nbod9+",
“Token”:"AgoJb3JpZ2luX2VjENL///////////aYUOtiSb6VVpWdTsa8XUt4Ug9VEvXX6MmE7nk1bc9ipcnlLrCrVMvSVXHNsuzNPaZsR9LOIoOQ5gHh4bImVZrUqWQahmPmQcCGKBp1+XuCaoDJ
r8QjM8rau2/fhT1JLplNJ3J5U9KS+iHQAA6jGgnW5QVZO+=",
"Expiration" : "2019-04-12T08:28:32Z"
EC2
S3 Bucket
Token 기반 API 호출
어플리케이션
Role 이 할당된 EC2 인스턴스의 자격증명 정보 확인 – Session Timeout 에 유의
(IMDS) URL: http://169.254.169.254/latest/meta-data/iam/security-credentials/role-name
34. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
멀티 계정 환경에서의 자원 공유
Prod1GWaMPLG.EoM
2EES 740 1111(((())))
ddD-roLG
dGU1GWaMPLG.EoM
2EES 740 1()45,-./01(
ddD-roLG p sh 보안
u격 xfo 이m{l
2@S 2P7 호출
72: TRGr0 3oD
ddD-roLG k a한
sh 보안 u격 xf
획c
3oD p 2EEGRR 8Gy
e 이m{l rx
ddD-roLG n 2@S aEEoTnS dGU1GWaMPLG.EoM
1()45,-./01() p 72: URGr e id
{ "SSaSGMGnS"0 A
{
"5ffGES"0"2LLow""
"PrinEiPaL"0{"2@S"0"1()45,-./01("}"
"2ESion"0"RSR02RRTMGRoLG"
}B}
2EEoTnS 3 k t는 ddD-roLG k a한 v근o 허m{는 보안 wyo 3oD k[ }당
{ "SSaSGMGnS"0 A
{
"5ffGES"0 "2LLow""
"2ESion"0 "RSR02RRTMGRoLG""
"RGRoTrEG"0 "arn0awR0iaM001111(((())))0roLG/ddD-roLG"
}B}
ddD-roLG k }당b ]한
{ "SSaSGMGnS"0 A
{ "2ESion"0
A
"dynaModD06GS7SGM""
"dynaModD03aSEI6GS7SGM""
"dynaModD04GREriDGTaDLG""
"dynaModD09iRSTaDLGR"
B"
"5ffGES"0 "2LLow""
"RGRoTrEG"0"arn0awR0dynaModD0TR-GaRS-10
1()45,-./01(0SaDLG/DooKR"
}B}
DooKR
35. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "ec2:*",
"Resource": "*",
"Condition": {
"StringEquals": {
"ec2:ResourceTag/Project" : "Blue"
}
}
}
]
}
Project=Blue
VPC
Project=Green
TAG 를 활용한 접근 권한 제어
36. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
IAM 정책 생성 자동화
Product 계정 보안 계정
개발 팀 테스트 계정 Sandbox
1. 업로드된 IAM Policy
유효성 검증
2. 필수 ”명시적 Deny”
추가
3. 사용자 계정 내 최종
Policy 생성
37. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Access Advisor 를 활용한 미사용 권한 탐지
"ServicesLastAccessed": [
{
"LastAuthenticated": "2018-11-21T17:41:15Z",
"LastAuthenticatedEntity": "arn:aws:iam::123456789012:role
"ServiceName": "Amazon EC2",
"ServiceNamespace": "ec2", "TotalAuthenticatedEntities": 1
},
38. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
오픈 소스를 활용한 IAM 관리
Aardvark Repokid
미사용 서비스 삭제
Policy 사용 체크
90일 이상?
미사용 서비스?
커스텀 정책
Yes
Yes
Yes
No
No
No
반복 체크
IAM 의 Access Advisor 정보를 조회 불필요한 권한 삭제
39. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
끝내기 전에 잠깐!!
40. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS WAF, Shield Advanced 서울 리전 지원!!