이번 글에서는 AWS CloudTrail 로그에 특화된 Sigma 규칙 작성법을 실전 중심으로 정리해드리겠습니다.

SigmaHQ 저장소에는 aws_cloudtrail_disable_logging.yml, aws_cloudtrail_bucket_deleted.yml 같은 CloudTrail 전용 규칙이 이미 존재하며, Invictus-IR의 Athena 기반 Sigma 프로젝트도 CloudTrail 탐지의 실전 사례를 보여줍니다.

Recorded Future 연구도 CloudTrail에서 Stratus Red Team, Pacu 같은 공격 도구의 행위를 탐지하는 데 Sigma를 활용했다고 설명합니다.

 

◎ CloudTrail이 왜 중요한가

  • AWS CloudTrail은 관리 이벤트와 데이터 이벤트를 기록하는 핵심 감사 로그입니다.
  • AWS 공식 문서에 따르면, IAM, S3, EC2, VPC 등 모든 서비스의 API 호출을 추적하며, 공격자의 계정 조작, 로깅 무력화, 권한 상승을 가장 먼저 잡을 수 있습니다.
  • SigmaHQ 규칙도 logsource: product: aws, service: cloudtrail로 표준화되어 있어, SIEM 변환도 간단합니다.

 

 - 탐지 우선순위:

  • 로깅 무력화: DeleteTrail, StopLogging, UpdateTrail.
  • 권한 상승: CreateAccessKey, AttachUserPolicy.
  • 보안 그룹 개방: AuthorizeSecurityGroupIngress.
  • S3 버킷 조작: DeleteBucket.

 

◎ CloudTrail 필드 구조 이해

 - CloudTrail JSON 로그의 핵심 필드는 다음과 같습니다.

  • eventName: API 호출명 (CreateAccessKey, DeleteTrail).
  • eventSource: 서비스명 (iahttp://m.amazonaws.com, cloudtrail.amazonaws.com).
  • userIdentity.type: 사용자 타입 (Root, AssumedRole).
  • requestParameters: 요청 파라미터 (중첩 JSON).
  • responseElements: 응답 결과.
  • errorCode, errorMessage: 실패 시 에러.

 - Sigma에서 중첩 필드는 requestParameters.* 또는 responseElements.*로 표현하거나, 파이프라인에서 평탄화합니다.

 

◎ 기본 CloudTrail Sigma 규칙

1. CloudTrail 로깅 무력화 탐지 (SigmaHQ 공식)

title: AWS CloudTrail Disable Logging
id: aws-cloudtrail-disable-logging
status: stable
description: Detects disabling, deleting, updating of CloudTrail
logsource:
  product: aws
  service: cloudtrail
detection:
  selection:
    eventSource: cloudtrail.amazonaws.com
    eventName:
      - StopLogging
      - UpdateTrail  
      - DeleteTrail
  condition: selection
level: high
tags:
  - attack.defense_evasion
  - attack.t1562.008
falsepositives:
  - Valid Trail changes

 

 - Splunk 변환 결과

index=* source=*cloudtrail* eventSource="cloudtrail.amazonaws.com" (eventName="StopLogging" OR eventName="UpdateTrail" OR eventName="DeleteTrail")

 

2. 루트 계정 액세스 키 생성

title: AWS Root Access Key Creation
id: aws-root-access-key
logsource:
  product: aws
  service: cloudtrail
detection:
  selection:
    eventSource: iahttp://m.amazonaws.com
    eventName: CreateAccessKey
    userIdentity.type: Root
  condition: selection
level: critical
tags:
  - attack.persistence
  - attack.t1098

 

3. 보안 그룹 SSH 개방

title: AWS Security Group SSH Open
id: aws-sg-ssh-open
logsource:
  product: aws
  service: cloudtrail
detection:
  selection:
    eventSource: ec2.amazonaws.com
    eventName: AuthorizeSecurityGroupIngress
    requestParameters.toPort: 22
  condition: selection
level: medium
tags:
  - attack.lateral_movement
  - attack.t1021.006
falsepositives:
  - Legitimate bastion host setup

 

 

 

 고급 탐지 기법

1. 요청 파라미터 중첩 해석

detection:
  s3_bucket_delete:
    eventName: DeleteBucket
    eventSource: s3.amazonaws.com
  filter_legit:
    requestParameters.bucketName|startswith: 'backup-'
  condition: s3_bucket_delete and not filter_legit
  • requestParameters.bucketName처럼 중첩 필드 접근.

 

2. 실패 이벤트 포함 (Gist 예시)

detection:
  ec2_export:
    eventName: CreateInstanceExportTask
    eventSource: ec2.amazonaws.com
  failure:
    errorCode: '*' | errorMessage: '*'
  condition: ec2_export and failure
  • 실패한 VM Export도 탐지.

 

3. Meta Rule로 상관분석

correlation:
  type: temporal_ordered
  rules:
    - aws-root-access-key
    - aws-sg-ssh-open
  timespan: 1h
  condition: all
  • 루트 키 생성 → SSH 개방 흐름 탐지.

 

 CloudTrail 로그 온보딩

 - S3 → Athena 변환 (Invictus-IR 방식)

1. CloudTrail → S3 버킷
2. Glue Crawler → 테이블 생성  
3. Athena → Sigma 변환 쿼리 실행
4. Lambda → 알람 전송

 

 - SIEM 연동

# Splunk
aws:cloudtrail → sourcetype=aws:cloudtrail → Sigma 변환

# Elastic
aws-cloudtrail → ECS 매핑 → Sigma 파이프라인

 

 실전 운영 워크플로

1. CloudTrail 활성화

aws cloudtrail create-trail --name security-trail --s3-bucket-name ct-bucket
aws cloudtrail start-logging --name security-trail

 

2. 필수 이벤트 로깅

Management Events: Read/Write
Data Events: S3, Lambda, DynamoDB

 

3. Sigma 규칙 배포

sigma convert --target athena cloudtrail_rules/ --pipeline aws-cloudtrail

 

4. Athena 쿼리 예시

SELECT * FROM cloudtrail_logs 
WHERE eventSource = 'cloudtrail.amazonaws.com' 
AND eventName IN ('StopLogging', 'DeleteTrail')
오탐 튜닝 팁

 

 - Whitelist 필터

filter_legit:
  userIdentity.arn|startswith: 'arn:aws:iam::123:role/backup-role'
  requestParameters.bucketName|startswith: 'temp-backup-'

 

 - 시간 기반

timespan: 30m
condition: value_count(selection, 1, 30m) > 1



 마무리

AWS CloudTrail은 클라우드 공격의 첫 번째 전선입니다. 

Sigma로 DeleteTrail, CreateAccessKey, AuthorizeSecurityGroupIngress 같은 핵심 이벤트를 표준화하면, 공격자의 초반 행보를 놓치지 않을 수 있습니다.

 

 

 

반응형

+ Recent posts