IT Knowledge/Security/images/32-보안-자동화-venn.svg
보안 자동화 (Security Automation)
보안 자동화(SOAR)과 자동화된 보안 운영을 이해합니다.
📌 학습 목표
- SOAR(Security Orchestration, Automation, Response) 이해
- 자동화 플레이북 작성 능력 습득
- 보안 자동화 도구 사용 능력 습득
- DevSecOps 이해
- IaC (Infrastructure as Code) 보안 통합
1. SOAR 개요
정의
SOAR는 보안 사건의 탐지, 조사, 대응을 자동화하는 플랫폼입니다.
SOAR 구성 요소
┌─────────────────────────────────────────────┐
│ SOAR 플랫폼 │
├─────────────────────────────────────────────┤
│ 1. 오케스트레이션 (Orchestration) │
│ - 워크플로우 디자인 │
│ - 툴 통합 │
│ - 조건부 로직 │
├─────────────────────────────────────────────┤
│ 2. 자동화 (Automation) │
│ - 반복 작업 자동화 │
│ - API 통합 │
│ - 스크립트 실행 │
├─────────────────────────────────────────────┤
│ 3. 대응 (Response) │
│ - 사건 자동 분류 │
│ - 자동 대응 조치 │
│ - 인력 개입 지점 │
└─────────────────────────────────────────────┘
SOAR 솔루션 비교
| 솔루션 | 설명 | 특징 |
|---|---|---|
| Cortex XSOAR | Palo Alto SOAR | 강력한 통합, 다양한 앱 |
| Splunk SOAR | Splunk SOAR | Splunk 통합 |
| IBM Security QRadar SOAR | IBM SOAR | QRadar 통합 |
| Microsoft Sentinel | Azure SOAR | Microsoft 365 통합 |
| FortiSOAR | Fortinet SOAR | Fortinet 제품군 통합 |
2. 플레이북 (Playbook)
정의
보안 사건 대응 절차를 자동화하는 워크플로우입니다.
플레이북 구조
플레이북 구조:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1. 트리거 (Trigger)
- 사건 유형
- 심각도
- 필드 값
2. 조건부 로직 (Conditional Logic)
- if/else
- switch/case
- 반복문
3. 작업 (Tasks)
- 데이터 수집
- 분석
- 대응 조치
- 알림 전송
4. 통합 (Integrations)
- SIEM
- 방화벽
- EDR
- 위협 인텔리전스
5. 사람 개입 (Human Intervention)
- 승인 필요 지점
- 수동 분석 요청
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━3. Cortex XSOAR
기본 개념
컴포넌트
| 컴포넌트 | 설명 |
|---|---|
| 인시던트 | 보안 사건 데이터 |
| 인디케이터 | IOC (IP, 도메인 등) |
| 워크플로우 | 자동화 플레이북 |
| 통합 | 외부 툴/API 연결 |
| 자동화 | API 호출, 스크립트 실행 |
워크플로우 예시
# Cortex XSOAR 스크립트 예시
# 이벤트 컨텍스트에서 IP 추출
ip = demisto.get('ip')
# 위협 인텔리전스 조회
url = "https://api.virustotal.com/vtapi/v2/ip-address/reports"
params = {'apikey': api_key, 'ip': ip}
response = requests.get(url, params=params)
result = response.json()
# 결과 저장
demisto.results({
'ContentsFormat': formats['json'],
'Type': entryTypes['note'],
'Contents': json.dumps(result),
'ReadableContentsFormat': formats['markdown'],
'HumanReadable': f'IP {ip} 분석 완료: {result.get("data", {}).get("attributes", {}).get("last_analysis_stats", {})}'
})플레이북 예시
# 악성 IP 차단 플레이북
version: -1
name: Block Malicious IP
description: 위협 인텔리전스에서 탐지된 악성 IP 차단
triggers:
- name: Malicious IP Detected
description: 악성 IP 탐지
type: event
playbook:
tasks:
# 1. IP 추출
- name: Extract IP
script: |
return demisto.get('ip')
# 2. 위협 인텔리전스 조회
- name: Query Threat Intel
script: |
ip = results['Extract IP']
# VT API 호출
# 결과 반환
# 3. 방화벽 차단
- name: Block in Firewall
script: |
ip = results['Extract IP']
# 방화벽 API 호출
# 결과 반환
# 4. 인시던트 업데이트
- name: Update Incident
script: |
demisto.executeCommand("setIncident", {'closeNotes': 'IP 차단 완료'})4. Splunk SOAR
기본 개념
플레이북 구조
# Splunk SOAR Python 스크립트
import phantom
def handle_asset_start(container, param):
phantom.debug("Starting asset investigation")
# 자산 정보 수집
asset = phantom.get_asset(container['id'])
phantom.debug(f"Asset: {asset}")
# 위협 인텔리전스 조회
ti_url = "https://api.virustotal.com/vtapi/v2/ip-address/reports"
params = {'apikey': api_key, 'ip': asset['ip']}
response = requests.get(ti_url, params=params)
# 결과 저장
phantom.save_run_data({'result': response.json()})
return
if __name__ == '__main__':
handle_asset_start(*phantom.args[2:])플레이북 JSON 예시
{
"playbook_name": "Malicious IP Response",
"playbook_id": "playbook_uuid",
"description": "악성 IP 대응 플레이북",
"tags": ["ip", "malware", "firewall"],
"start_playbook": "asset_info",
"playbook_variables": [
{
"name": "ip_address",
"type": "ip",
"required": true
}
],
"playbook_variables_order": [],
"playbook_tasks": [
{
"id": "task_1",
"name": "Threat Intel Lookup",
"type": "action",
"app": "virustotal",
"action": "file reputation",
"parameters": {
"ip": "\"{{playbook_variables.ip_address}}\""
}
},
{
"id": "task_2",
"name": "Block in Firewall",
"type": "action",
"app": "firewall",
"action": "block_ip",
"parameters": {
"ip": "\"{{playbook_variables.ip_address}}\"",
"duration": "24h"
}
}
]
}5. 보안 자동화 도구
Ansible
보안 자동화 예시
# 방화벽 규칙 자동 추가
---
- name: Configure Firewall
hosts: firewalls
become: yes
tasks:
- name: Block Malicious IP
fortios_firewall_policy:
name: "Block {{ malicious_ip }}"
action: deny
srcaddr: "{{ malicious_ip }}"
dstaddr: "all"
service: "all"
schedule: "always"
register: result
- name: Display Result
debug:
var: resultTerraform
보안 구성 IaC
# 방화벽 구성
resource "aws_security_group" "web_server" {
name = "web_server_sg"
description = "Web Server Security Group"
vpc_id = aws_vpc.main.id
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
# WAF 설정
resource "aws_wafv2_web_acl" "main" {
name = "main_web_acl"
description = "Main WAF"
scope = "REGIONAL"
default_action {
allow {}
}
}GitHub Actions
자동화된 보안 스캔
name: Security Scan
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
security-scan:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'sarif'
output: 'trivy-results.sarif'
- name: Upload Trivy results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: 'trivy-results.sarif'6. DevSecOps
정의
개발(Dev), 운영(Ops), 보안(Sec)을 통합한 개발 및 운영 방법론입니다.
DevSecOps 파이프라인
graph TD A[코드 작성] --> B[보안 스캔(SAST/DAST)] B --> C[단위 테스트] C --> D[CI/CD 파이프라인] D --> E[보안 승인] E --> F[배포] F --> G[보안 모니터링] G --> H[피드백 → A]
GitOps 보안
# Kubernetes 보안 정책 (OPA Gatekeeper)
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: K8sRequiredLabels
metadata:
name: ns-must-have-team
spec:
match:
kinds:
- Namespace
parameters:
labels:
- team시프트 레프트(Shift Left)
┌─────────────────────────────────────────┐
│ 전통적인 보안 │
│ ┌─────────────────────────────┐ │
│ │ 배포 후 │ │
│ │ ↓ │ │
│ │ 보안 테스트 │ │
│ │ ↓ │ │
│ │ 취약점 발견 │ │
│ │ ↓ │ │
│ │ 수정 및 재배포 │ │
│ └─────────────────────────────┘ │
└─────────────────────────────────────────┘
┌─────────────────────────────────────────┐
│ Shift Left │
│ ┌─────────────────────────────┐ │
│ │ 코드 작성 │ │
│ │ ↓ │ │
│ │ IDE 보안 플러그인 │ │
│ │ ↓ │ │
│ │ 커밋 전 보안 스캔 │ │
│ │ ↓ │ │
│ │ 단위 테스트(보안 포함) │ │
│ │ ↓ │ │
│ │ 통합 테스트 │ │
│ └─────────────────────────────┘ │
└─────────────────────────────────────────┘
7. 자동화된 보안 작업
1. 악성 IP 차단
# 플레이북 작업: 악성 IP 차단
def block_malicious_ip(event):
ip = event.get('ip')
# 위협 인텔리전스 조회
if is_malicious(ip):
# 방화벽 차단
block_ip_in_firewall(ip)
# 인시던트 업데이트
update_incident(event['id'], 'IP 차단 완료')
# 알림 전송
send_notification(f'Malicious IP {ip} blocked')
return True2. 손상된 계정 비활성화
# 플레이북 작업: 손상된 계정 비활성화
def disable_compromised_account(event):
username = event.get('username')
# AD/LDAP에서 계정 비활성화
disable_ad_account(username)
# 패스워드 리셋
reset_password(username)
# 인시던트 업데이트
update_incident(event['id'], '계정 비활성화 완료')
return True3. 악성코드 격리
# 플레이북 작업: 악성코드 격리
def quarantine_malicious_file(event):
file_hash = event.get('file_hash')
# EDR에서 파일 격리
quarantine_file(file_hash)
# 호스트 격리
isolate_host(event['host_id'])
# 인시던트 업데이트
update_incident(event['id'], '파일/호스트 격리 완료')
return True8. 자동화 측정 지표
KPI (Key Performance Indicators)
| 지표 | 설명 | 목표 |
|---|---|---|
| MTTR (Mean Time to Response) | 평균 대응 시간 | ≤ 15분 |
| MTTD (Mean Time to Detect) | 평균 탐지 시간 | ≤ 5분 |
| 자동화율 | 자동화된 작업 비율 | ≥ 80% |
| 사건 해결률 | 자동 해결된 사건 비율 | ≥ 70% |
🎯 실습 과제
1. Cortex XSOAR 플레이북 작성
# 플레이북: 파일 해시 탐지
name: File Hash Detection
tasks:
- name: Extract File Hash
script: |
return demisto.get('file_hash')
- name: Query VirusTotal
type: python
script: |
file_hash = results['Extract File Hash']
# VT API 호출
# 결과 반환
- name: Update Incident
script: |
demisto.executeCommand("setIncident", {'closeNotes': '파일 검사 완료'})2. Ansible 보안 자동화
# 패치 자동화
---
- name: Patch Management Automation
hosts: all
become: yes
tasks:
- name: Update all packages
apt:
update_cache: yes
upgrade: dist
register: result
- name: Reboot if required
reboot:
when: result.changed3. GitHub Actions 보안 스캔
# OWASP ZAP 스캔
name: OWASP ZAP Scan
on: [push]
jobs:
zap-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: ZAP Full Scan
uses: zaproxy/action-full-scan@v0.4.0
with:
target: 'http://localhost:8080'
rules_file_name: '.zap/rules.tsv'✅ 학습 체크리스트
- SOAR 개념 이해
- 플레이북 구조 이해
- Cortex XSOAR 사용 능력 습득
- Splunk SOAR 사용 능력 습득
- Ansible 보안 자동화 구현
- Terraform IaC 보안 통합
- DevSecOps 파이프라인 구축
- Shift Left 개념 이해
- 자동화 측정 지표 이해
🔗 관련 노트
📚 참고 자료
다음 학습: 프로젝트 1: 홈랩 네트워크 구성