iT邦幫忙

2025 iThome 鐵人賽

DAY 29
0
Build on AWS

AWS 雲原生,學起來比泡咖啡還快系列 第 29

DAY29 - 小李的安全指揮中心:AWS Security Hub 統一管理平台

  • 分享至 

  • xImage
  •  

前情提要

經過了 Inspector 的安全漏洞掃描和 GuardDuty 的威脅檢測部署,小李的餐廳帝國現在擁有了強大的安全防護能力。Inspector 就像專業的「建築安全檢查員」,定期檢查系統漏洞;GuardDuty 則像 24 小時的「AI 智能保全」,監控各種威脅攻擊。

但隨著安全工具越來越多,小李發現了一個新問題:每個工具都有自己的介面、自己的告警、自己的報告格式。他需要在不同的系統間切換,才能了解完整的安全狀況。

「我們需要一個統一的安全指揮中心,」小李對小張說,「就像機場的航管塔台一樣,能夠統籌所有的安全資訊。」

這就是 AWS Security Hub 要解決的問題...

第一章:安全資訊的混亂

多頭馬車的困擾

2024年5月的一個週一早晨,小李正在進行例行的安全檢查。他需要:

  1. 打開 Inspector Console 查看漏洞掃描結果
  2. 切換到 GuardDuty Console 檢查威脅檢測狀況
  3. 登入 CloudTrail 查看 API 呼叫日誌
  4. 檢查 Config 確認配置合規性
  5. 查看 CloudWatch 監控安全指標

「這太麻煩了,」小李抱怨,「我要開 5 個不同的頁面才能了解完整的安全狀況。而且每個系統的報告格式都不一樣,很難比較和分析。」

小張點頭:「這就像管理一家大型餐廳,廚房有廚房的報告、服務生有服務生的報告、收銀台有收銀台的報告,但沒有一個統一的管理儀表板。」

資訊孤島的問題

更糟的是,小李發現這些安全工具之間缺乏協調:

問題一:重複告警
同一個安全問題,Inspector 和 GuardDuty 可能都會發出告警,但格式不同,很難識別是同一個問題。

問題二:優先順序混亂
Inspector 說有個 HIGH 風險漏洞,GuardDuty 說有個 MEDIUM 威脅,但哪個更緊急?

問題三:缺乏全局視野
無法快速了解整體安全狀況,不知道安全防護是在改善還是惡化。

問題四:報告分散
要向董事會報告安全狀況時,需要整合多個系統的資料,費時費力。

小張的解決方案

「你需要的是 AWS Security Hub,」小張說,「它就像安全領域的『聯合國總部』,把所有安全服務的資訊統一管理。」

她在白板上畫了一個圖:

傳統方式:分散管理
Inspector → 漏洞報告 A
GuardDuty → 威脅報告 B  
Config → 合規報告 C
CloudTrail → 審計報告 D

Security Hub 方式:統一管理
Inspector ↘
GuardDuty → Security Hub → 統一儀表板
Config ↗              → 標準化報告
CloudTrail ↗           → 自動化工作流程

「Security Hub 就像一個翻譯官加指揮官,」小張解釋,「它把所有安全服務的『方言』翻譯成統一的『標準語言』,然後統一指揮協調。」

第二章:認識 AWS Security Hub - 「安全聯合國總部」

什麼是 Security Hub?

「Security Hub 是 AWS 的安全管理中樞,」小張開始詳細解釋,「它有三個主要功能:收集、標準化、協調。」

收集(Aggregation)
「就像新聞中心收集各地記者的報導,Security Hub 收集所有 AWS 安全服務的發現。」

標準化(Standardization)
「把不同格式的安全資訊轉換成統一的格式,就像把不同語言翻譯成英文。」

協調(Orchestration)
「根據統一的資訊做出協調決策,就像聯合國協調各國行動。」

Security Hub 的核心概念

小張介紹了幾個重要概念:

1. Findings(發現)
「這是 Security Hub 的基本單位,每個安全問題都是一個 Finding。」

{
  "SchemaVersion": "2018-10-08",
  "Id": "arn:aws:guardduty:us-east-1:123456789012:detector/12abc34d567e8f90g1h234i5j6k7890l/finding/16b0c1e4f1g234h5i6j7k890l1m2n3o4",
  "ProductArn": "arn:aws:securityhub:us-east-1::product/aws/guardduty",
  "GeneratorId": "guardduty",
  "AwsAccountId": "123456789012",
  "Types": ["Sensitive Data Identifications/Personal Information"],
  "Title": "Suspicious API call from malicious IP",
  "Description": "An API call was made from a known malicious IP address",
  "Severity": {
    "Label": "HIGH",
    "Normalized": 70
  },
  "Resources": [
    {
      "Type": "AwsEc2Instance",
      "Id": "arn:aws:ec2:us-east-1:123456789012:instance/i-1234567890abcdef0"
    }
  ]
}

2. Insights(洞察)
「這是對多個 Findings 的分析和總結,幫助識別模式和趨勢。」

3. Standards(標準)
「預定義的安全標準和最佳實踐,比如 AWS Foundational Security Standard。」

4. Custom Actions(自訂動作)
「當發現特定問題時,可以觸發的自動化回應動作。」

Security Hub 支援的服務

小張展示了 Security Hub 整合的服務清單:

AWS 原生安全服務:

  • GuardDuty(威脅檢測)
  • Inspector(漏洞掃描)
  • Macie(資料安全)
  • Config(配置合規)
  • Systems Manager(補丁管理)
  • Firewall Manager(防火牆管理)
  • Access Analyzer(存取分析)

第三方安全工具:

  • Splunk
  • Qualys
  • Rapid7
  • Tenable
  • CrowdStrike
  • Palo Alto Networks

「這就像聯合國有各個會員國一樣,」小張比喻,「每個服務都是會員,Security Hub 是總部。」

第三章:Security Hub 的實際部署

啟用 Security Hub

小張開始實際操作:「讓我們來啟用 Security Hub,看看它如何整合我們現有的 Inspector 和 GuardDuty。」

步驟一:進入 Security Hub Console
「在 AWS Console 中搜尋 'Security Hub',點擊進入。」

步驟二:啟用 Security Hub
「點擊 'Enable Security Hub' 按鈕。」

步驟三:選擇安全標準
小張解釋各個標準的用途:

  • AWS Foundational Security Standard:AWS 基礎安全最佳實踐
  • PCI DSS:支付卡行業資料安全標準
  • CIS AWS Foundations Benchmark:網路安全中心基準

「我建議先啟用 AWS Foundational Security Standard,」小張說,「這是最基本也最重要的。」

步驟四:整合現有服務
「Security Hub 會自動檢測並整合已啟用的安全服務。」
https://ithelp.ithome.com.tw/upload/images/20251001/20145462UeujqIekmD.png

第一次登入 Security Hub

啟用完成後,小李看到了全新的統一儀表板:

「哇!這比我想像的直觀多了,」小李驚嘆,「一眼就能看出我們的安全狀況。」
https://ithelp.ithome.com.tw/upload/images/20251001/20145462flZJ2wOmbZ.png

統一的發現管理

小張展示了統一發現管理的威力:

「以前你需要在 GuardDuty 和 Inspector 之間切換,現在所有發現都在一個地方。」

發現列表範例:

最新安全發現

1. [CRITICAL] 惡意 IP 攻擊檢測
   來源:GuardDuty
   資源:EC2 實例 i-1234567890abcdef0
   時間:2024-05-15 14:30:25
   狀態:NEW
   
2. [HIGH] OpenSSL 高風險漏洞
   來源:Inspector
   資源:容器映像 payment-service:v2.1
   時間:2024-05-15 12:15:10
   狀態:NEW
   
3. [MEDIUM] S3 儲存桶公開存取
   來源:Config
   資源:S3 儲存桶 backup-data
   時間:2024-05-15 10:45:33
   狀態:SUPPRESSED

「你看,現在所有發現都用統一的格式顯示,」小張指出,「而且可以統一管理狀態:NEW、NOTIFIED、SUPPRESSED、RESOLVED。」
https://ithelp.ithome.com.tw/upload/images/20251001/20145462lAh1eO8sYj.png

第四章:自動化工作流程和回應

Custom Actions - 自訂動作

「Security Hub 的強大之處在於可以觸發自動化回應,」小張說,「當發現特定問題時,可以自動執行修復動作。」

設定自訂動作範例:

動作一:隔離受感染的 EC2 實例

{
  "Name": "Isolate Compromised Instance",
  "Description": "Isolate EC2 instance by modifying security group",
  "Id": "isolate-instance",
  "EventBridgeRule": {
    "EventPattern": {
      "source": ["aws.securityhub"],
      "detail-type": ["Security Hub Findings - Custom Action"],
      "detail": {
        "actionName": ["Isolate Compromised Instance"],
        "findings": {
          "Types": ["TTPs/Command and Control/Backdoor"]
        }
      }
    },
    "Targets": [
      {
        "Id": "1",
        "Arn": "arn:aws:lambda:region:account:function:IsolateInstance"
      }
    ]
  }
}

動作二:自動修復 S3 儲存桶權限

# Lambda 函數:自動修復 S3 公開存取
import boto3
import json

def lambda_handler(event, context):
    s3 = boto3.client('s3')
    
    # 從 Security Hub 發現中提取 S3 儲存桶名稱
    findings = event['detail']['findings']
    
    for finding in findings:
        if 'S3' in finding['Types'][0]:
            bucket_name = extract_bucket_name(finding)
            
            # 移除公開存取權限
            s3.put_public_access_block(
                Bucket=bucket_name,
                PublicAccessBlockConfiguration={
                    'BlockPublicAcls': True,
                    'IgnorePublicAcls': True,
                    'BlockPublicPolicy': True,
                    'RestrictPublicBuckets': True
                }
            )
            
            # 更新 Security Hub 發現狀態
            update_finding_status(finding['Id'], 'RESOLVED')
    
    return {'statusCode': 200}

EventBridge 整合

「Security Hub 與 EventBridge 深度整合,可以建立複雜的自動化工作流程,」小張展示。

工作流程範例:高風險發現自動處理

WorkflowName: HighRiskFindingResponse

Trigger:
  Source: aws.securityhub
  DetailType: Security Hub Findings - Imported
  Detail:
    findings:
      Severity:
        Label: [HIGH, CRITICAL]

Steps:
  1. SendSlackNotification:
     Type: Lambda
     Function: SendSlackAlert
     
  2. CreateJiraTicket:
     Type: Lambda  
     Function: CreateJiraIssue
     
  3. NotifySecurityTeam:
     Type: SNS
     Topic: SecurityAlerts
     
  4. WaitForResponse:
     Type: Wait
     Seconds: 3600  # 1 hour
     
  5. EscalateIfNotResolved:
     Type: Choice
     Choices:
       - Variable: $.findingStatus
         StringEquals: NEW
         Next: EscalateToManager
       - Variable: $.findingStatus
         StringEquals: RESOLVED
         Next: CloseWorkflow

自動修復範例

小張展示了幾個實際的自動修復範例:

1. 自動修復過於寬鬆的安全群組

def fix_overly_permissive_sg(security_group_id):
    ec2 = boto3.client('ec2')
    
    # 移除 0.0.0.0/0 的入站規則
    response = ec2.describe_security_groups(
        GroupIds=[security_group_id]
    )
    
    sg = response['SecurityGroups'][0]
    
    for rule in sg['IpPermissions']:
        for ip_range in rule.get('IpRanges', []):
            if ip_range.get('CidrIp') == '0.0.0.0/0':
                ec2.revoke_security_group_ingress(
                    GroupId=security_group_id,
                    IpPermissions=[rule]
                )
                
                # 記錄修復動作
                log_remediation_action(
                    resource_id=security_group_id,
                    action='Removed overly permissive rule',
                    rule=rule
                )

結語:統一安全管理的新時代

小李的安全轉型完成

經過這次 Security Hub 的部署,小李終於實現了統一安全管理的夢想。

「現在我只需要打開一個頁面,就能了解整個系統的安全狀況,」小李滿意地說,「Inspector 的漏洞掃描、GuardDuty 的威脅檢測、Config 的合規檢查,所有資訊都統一在 Security Hub 中。」

小張點頭:「這就是現代安全管理的趨勢 - 統一、標準化、自動化。」

安全管理的演進

回顧整個安全建設過程,小李感慨良多:

第一階段:被動應對

  • 出了問題才知道
  • 手動處理和修復
  • 缺乏全局視野

第二階段:主動監控

  • Inspector 檢查漏洞
  • GuardDuty 檢測威脅
  • 但資訊分散

第三階段:統一管理

  • Security Hub 統一所有安全資訊
  • 標準化的發現格式
  • 自動化的工作流程

給讀者的建議

如果你也想建立統一的安全管理平台,記住這些要點:

  1. 統一勝過分散:集中管理比分散管理更有效
  2. 標準化很重要:統一的格式和流程提高效率
  3. 自動化是趨勢:減少人工操作,提高回應速度
  4. 持續改進:安全管理是一個持續優化的過程
  5. 團隊協作:讓所有相關人員都能使用統一平台

「Security Hub 不只是一個工具,」小張最後說,「它代表了一種新的安全管理哲學 - 統一、協調、智能。有了它,我們終於可以說我們有了真正的『安全指揮中心』。」

小李深有感觸地說:「從分散的安全工具到統一的管理平台,我們的安全防護體系終於成熟了。現在我可以自信地說,我們的數位帝國有了最強大的安全防護。」


這個故事告訴我們,在現代的雲端環境中,統一安全管理是必然趨勢。AWS Security Hub 提供了強大的統一管理能力,將分散的安全工具整合成協調一致的防護體系。記住,最好的安全策略不是擁有最多的工具,而是讓所有工具協調工作,形成統一的防護網。


上一篇
DAY28 - 小李的威脅防護:AWS GuardDuty 智能保全系統
系列文
AWS 雲原生,學起來比泡咖啡還快29
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言