Sigmaによる検知ルールの構築 は何をしますか?
使用すべき場面
以下の場合にこのスキルを使用してください:
- SOCエンジニアが複数のSIEMプラットフォームで移植可能な検知ルールを作成する必要がある場合
- 脅威インテリジェンスレポートが新たな検知カバレッジを必要とするTTPを説明している場合
- 既存のベンダー固有ルールを共有可能な形式に標準化する必要がある場合
- チームがCI/CDパイプラインにおける検知-as-aコードの標準としてSigmaを採用する場合
使用すべきでない場合: リアルタイムストリーミング検知(Sigmaはバッチ/スケジュール検索向け)や、ターゲットSIEMがSigmaで表現できないネイティブ検知機能(例:Splunk RBAリスクスコアリング)を持つ場合。
前提条件
- Python 3.8+と
pySigma、および適切なバックエンド(pySigma-backend-splunk、pySigma-backend-elasticsearch、pySigma-backend-microsoft365defender) - Sigmaルールリポジトリのクローン:
git clone https://github.com/SigmaHQ/sigma.git - テクニックマッピングのためのMITRE ATT&CKフレームワークの知識
- ターゲットSIEMのログソースフィールドマッピングの理解
ワークフロー
ステップ 1: 脅威インテリジェンスから検知ロジックを定義する
脅威レポートまたはATT&CKテクニックから始めます。例:Mimikatz資格情報ダンピング(T1003.001 — LSASSメモリ)の検知:
title: Mimikatz Credential Dumping via LSASS Access
id: 0d894093-71bc-43c3-8d63-bf520e73a7c5
status: stable
level: high
description: Detects process accessing lsass.exe memory, indicative of credential dumping tools like Mimikatz
references:
- https://attack.mitre.org/techniques/T1003/001/
- https://github.com/gentilkiwi/mimikatz
author: mahipal
date: 2024/03/15
modified: 2024/03/15
tags:
- attack.credential_access
- attack.t1003.001
logsource:
category: process_access
product: windows
detection:
selection:
TargetImage|endswith: '\lsass.exe'
GrantedAccess|contains:
- '0x1010'
- '0x1038'
- '0x1fffff'
- '0x40'
filter_main_svchost:
SourceImage|endswith: '\svchost.exe'
filter_main_csrss:
SourceImage|endswith: '\csrss.exe'
filter_main_wininit:
SourceImage|endswith: '\wininit.exe'
condition: selection and not 1 of filter_main_*
falsepositives:
- Legitimate security tools accessing LSASS
- Windows Defender scanning
- CrowdStrike Falcon sensor
ステップ 2: Sigmaルールの構文を検証する
sigma checkを使用してルールを検証します:
# pySigmaとバリデータをインストール
pip install pySigma pySigma-validators-sigmaHQ
# ルールを検証
sigma check rule.yml
または、Pythonで検証:
from sigma.rule import SigmaRule
from sigma.validators.core import SigmaValidator
rule = SigmaRule.from_yaml(open("rule.yml").read())
validator = SigmaValidator()
issues = validator.validate_rule(rule)
for issue in issues:
print(f"{issue.severity}: {issue.message}")
ステップ 3: ターゲットSIEMクエリに変換する
Splunk SPLに変換:
from sigma.rule import SigmaRule
from sigma.backends.splunk import SplunkBackend
from sigma.pipelines.splunk import splunk_windows_pipeline
pipeline = splunk_windows_pipeline()
backend = SplunkBackend(pipeline)
rule = SigmaRule.from_yaml(open("rule.yml").read())
splunk_query = backend.convert_rule(rule)
print(splunk_query[0])
出力:
TargetImage="*\\lsass.exe" (GrantedAccess="*0x1010*" OR GrantedAccess="*0x1038*"
OR GrantedAccess="*0x1fffff*" OR GrantedAccess="*0x40*")
NOT (SourceImage="*\\svchost.exe") NOT (SourceImage="*\\csrss.exe")
NOT (SourceImage="*\\wininit.exe")
Elasticクエリ(Lucene)に変換:
from sigma.backends.elasticsearch import LuceneBackend
from sigma.pipelines.elasticsearch import ecs_windows_pipeline
pipeline = ecs_windows_pipeline()
backend = LuceneBackend(pipeline)
elastic_query = backend.convert_rule(rule)
print(elastic_query[0])
Microsoft Sentinel KQLに変換:
from sigma.backends.microsoft365defender import Microsoft365DefenderBackend
backend = Microsoft365DefenderBackend()
kql_query = backend.convert_rule(rule)
print(kql_query[0])
ステップ 4: MITRE ATT&CKにマッピングし、カバレッジメタデータを追加する
すべてのルールにATT&CKテクニックIDをtagsフィールドでタグ付けします:
tags:
- attack.credential_access # 戦術
- attack.t1003.001 # サブテクニック
- attack.t1003 # 親テクニック
ATT&CKナビゲーターを使用して検知カバレッジを追跡します:
import json
# SigmaルールからATT&CKナビゲーターレイヤーを生成
layer = {
"name": "SOC検知カバレッジ",
"versions": {"attack": "14", "navigator": "4.9", "layer": "4.5"},
"domain": "enterprise-attack",
"techniques": []
}
# テクニックタグについてSigmaルールディレクトリを解析
import os
from sigma.rule import SigmaRule
for root, dirs, files in os.walk("sigma/rules/windows/"):
for f in files:
if f.endswith(".yml"):
rule = SigmaRule.from_yaml(open(os.path.join(root, f)).read())
for tag in rule.tags:
if str(tag).startswith("attack.t"):
technique_id = str(tag).replace("attack.", "").upper()
layer["techniques"].append({
"techniqueID": technique_id,
"color": "#31a354",
"score": 1
})
with open("coverage_layer.json", "w") as f:
json.dump(layer, f, indent=2)
ステップ 5: サンプルデータに対してルールをテストする
テストデータを作成し、ルールが期待されるイベントをキャッチすることを検証します:
# sigmaテストフレームワークを使用
sigma test rule.yml --target splunk --pipeline splunk_windows
# または、サンプルデータを使用してSplunkで手動テスト
# 既知のMimikatzシグネチャを持つSysmon process_accessログをアップロード
アラートを発生させない保存検索で、7日間の本番データに対して偽陽性率を検証します。
ステップ 6: 本番SIEMにデプロイする
変換されたクエリをスケジュール検索または相関ルールとしてデプロイします:
Splunk ES相関検索:
| tstats summariesonly=true count from datamodel=Endpoint.Processes
where Processes.process_name="*\\lsass.exe"
by Processes.src, Processes.user, Processes.process_name, Processes.parent_process_name
| `drop_dm_object_name(Processes)`
| where count > 0
Elastic Securityルール(TOML形式):
[rule]
name = "LSASSメモリアクセス - 資格情報ダンピング"
description = "LSASSプロセスメモリへの不審なアクセスを検出します"
risk_score = 73
severity = "high"
type = "eql"
query = '''
process where event.action == "access" and
process.name == "lsass.exe" and
not process.executable : ("*\\svchost.exe", "*\\csrss.exe")
'''
[rule.threat]
framework = "MITRE ATT&CK"
[[rule.threat.technique]]
id = "T1003"
name = "OS資格情報ダンピング"
ステップ 7: バージョン管理とCI/CD統合
自動テスト付きでGitにルールを保存します:
# .github/workflows/sigma-ci.yml
name: SigmaルールCI
on: [push, pull_request]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- run: pip install pySigma pySigma-validators-sigmaHQ
- run: sigma check rules/
- run: sigma convert -t splunk -p splunk_windows rules/ > /dev/null
主要な概念
| 用語 | 定義 |
|---|---|
| Sigma | ベンダー非依存の検知ルール形式(YAMLベース)。バックエンドを介してSIEM固有のクエリにコンパイルされます |
| pySigma | レガシーなsigmacに代わるPythonライブラリ。ルール変換、検証、パイプラインレンダリングを行います |
| バックエンド | Sigma検知ロジックをターゲットプラットフォームのクエリ言語(SPL、KQL、Lucene)に変換するpySigmaプラグイン |
| パイプライン | 汎用的なSigmaフィールド名をSIEM固有のフィールド名に変換するフィールドマッピング設定 |
| ログソース | ターゲットデータのカテゴリ(process_creation、network_connection)と製品(windows、linux)を定義するSigmaルールセクション |
| 検知-as-a-Code | CI/CDテストと自動デプロイによってバージョン管理下で検知ルールを管理するプラクティス |
ツールとシステム
- SigmaHQ: GitHub上の公式Sigmaルールリポジトリ。コミュニティメンテナンスによる3,000以上の検知ルールを収録
- pySigma: モジュール式バックエンドとパイプラインを備えたPythonベースのSigmaルール処理フレームワーク
- ATT&CKナビゲーター: ATT&CKテクニックにマッピングされた検知カバレッジを可視化するMITREツール
- Uncoder.IO: クイックトランスレーションのために30以上のSIEMプラットフォームをサポートするWebベースのSigmaルールコンバーター
一般的なシナリオ
- 新しいCVE検知: エクスプロイト指標(例:WebログにおけるLog4Shell JNDIルックアップパターン)に対するSigmaルールを作成
- ハンティングルールのプロモーション: アドホックなSplunkハンティングクエリを、継続的な自動検知のためのSigmaルールに変換
- マルチSIEM移行: 500以上のSplunk相関検索をSigmaに変換し、Elastic Securityに移行
- パープルチームの成果: レッドチームの調査結果をSigmaルールに変換し、即座に防御カバレッジを展開
- 脅威インテリジェンスの運用化: IOCベースの脅威レポートを行動ベースのSigmaルールに変換
出力形式
SIGMAルールデプロイメントレポート
━━━━━━━━━━━━━━━━━━━━━━━━━━━
ルールID: 0d894093-71bc-43c3-8d63-bf520e73a7c5
タイトル: Mimikatz LSASSアクセス経由の資格情報ダンピング
ATT&CK: T1003.001 - LSASSメモリ
深刻度: 高
ステータス: 本番環境にデプロイ済み
変換:
Splunk SPL: 成功 — 保存検索「sigma_lsass_access」を作成
Elastic EQL: 成功 — 検知ルールID elastic-0d894093を有効化
Sentinel KQL: 成功 — ARMテンプレートを介してAnalyticsルールをデプロイ
テスト:
真陽性: 4/4のテストケースに一致
偽陽性: 7日間のバックテストで2件(svchostエッジケース — フィルター追加)
パフォーマンス: 50Mイベント/日の環境で平均実行時間3.2秒