chore(ec2): IMDSv2 강제로 IMDSv1 차단#5
Merged
Merged
Conversation
- 토큰 없는 IMDSv1 접근을 막아 SSRF를 통한 IAM 역할 임시 자격증명 탈취를 방지 - 앱이 host 네트워크로 동작하므로 hop_limit=1이면 IMDS 접근에 충분
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
개요
EC2 인스턴스 메타데이터 서비스를 IMDSv2(토큰 필수)로 강제합니다.
배경
런타임 점검 중 현재 dev 인스턴스에서 IMDSv1이 활성(토큰 없이
http://169.254.169.254/latest/meta-data/접근 가능)인 것을 확인했습니다. 앱에 SSRF 취약점이 하나라도 존재하면 IMDS를 통해 인스턴스에 연결된 IAM 역할(sw-hub-dev-app-role)의 임시 자격증명이 탈취될 수 있습니다.변경 사항
aws_instance에metadata_options추가http_tokens = "required"— IMDSv2 강제(토큰 없는 IMDSv1 차단)http_endpoint = "enabled",http_put_response_hop_limit = 1영향
적용
terraform apply로 반영. (또는 즉시 차단이 필요하면 아래 CLI 후 apply 시 drift 없음)비고 (후속 참고)
0.0.0.0:8080바인딩을127.0.0.1로 좁히는 건 앱(BE) 설정이며, cloudflared가 host 네트워크로localhost:8080에 접속하므로 안전하게 적용 가능.