GuardDuty Investigation の trigger-prompt を AWS CLI でいろいろ試してみた
はじめに
GuardDuty Investigation(Preview)をコンソールから試してみた記事を先日書きました。
コンソールの UI では調査時のプロンプトを自由に指定できないのですが、CLI なら --trigger-prompt に自由な自然言語を渡せることを知り、気になることが出てきました。
プロンプトの書き方で分析結果が変わるのか、実際に CLI から試してみます。
準備
AWS CLI のバージョン確認
GuardDuty Investigation の CLI コマンドは AWS CLI 2.35.11 以降が必要です。2026 年 6 月 22 日のリリース直後なので、古いバージョンには対応していません。
aws --version
aws-cli/2.35.11 Python/3.14.6 Darwin/24.6.0 source/arm64
古い場合は更新します。macOS で Homebrew を使っている場合は以下のコマンドです。
brew upgrade awscli
なお、macOS でパッケージインストール版の AWS CLI を使っている場合は注意が必要です。パスによっては古いバージョンが優先されてしまいます。which aws でパスを確認して、意図したバージョンか確かめておきましょう。
Detector ID の取得
Investigation 操作にはすべて --detector-id が必要です。事前に取得しておきます。
aws guardduty list-detectors --region ap-northeast-1
{
"DetectorIds": [
"<DETECTOR_ID>"
]
}
CLI コマンドの基本
GuardDuty Investigation で使うコマンドは 3 つです。
| コマンド | 用途 |
|---|---|
create-investigation |
Investigation の作成 |
get-investigation |
Investigation の結果取得 |
list-investigations |
Investigation の一覧取得 |
Finding 分析の基本的な流れはこうなります。
# Investigation を作成
aws guardduty create-investigation \
--detector-id <DETECTOR_ID> \
--trigger-prompt "Investigate finding <FINDING_ID>" \
--region ap-northeast-1
{
"InvestigationId": "12cf78d2-5f91-2917-704c-45de39789c54"
}
# 結果を確認(完了まで数分かかります)
aws guardduty get-investigation \
--detector-id <DETECTOR_ID> \
--investigation-id 12cf78d2-5f91-2917-704c-45de39789c54 \
--region ap-northeast-1
Investigation の一覧は list-investigations で確認できます。
aws guardduty list-investigations \
--detector-id <DETECTOR_ID> \
--region ap-northeast-1
trigger-prompt の書き方で FAILED になるケース
trigger-prompt は自由な自然言語で書けますが、意図を正しく認識できないと Status が FAILED になります。
アカウント全体の分析を以下のプロンプトで試したところ、FAILED になりました。
aws guardduty create-investigation \
--detector-id <DETECTOR_ID> \
--trigger-prompt "Analyze findings in my account" \
--region ap-northeast-1
create-investigation 自体は成功して InvestigationId が返ります。ただし get-investigation で確認すると Status が FAILED になっており、Error フィールドに理由が記載されています。
{
"Investigation": {
"Status": "FAILED",
"TriggerPrompt": "Analyze findings in my account",
"Error": "Couldn't match this request to a supported action. Try asking about a GuardDuty finding ID, account security posture, or an organization-wide analysis."
}
}
エラーメッセージに対処のヒントが書かれています。アカウント ID を明示したところ、同じ意図のプロンプトで成功しました。
aws guardduty create-investigation \
--detector-id <DETECTOR_ID> \
--trigger-prompt "Analyze my account id: XXXXXXXXXXXX" \
--region ap-northeast-1
CLI ヘルプ(aws guardduty create-investigation help)にも trigger-prompt の例が載っています。
"Investigate finding 1ab2cc3d4e5f6a7b8cc9dd0e1f2a3b4c5d6 in account 123456789012"
"Analyze findings in account with id 123456789012"
"Analyze findings in my organization"
まずはこのフォーマットに近い表現から始めると安全です。
同じ finding に異なる trigger-prompt を与えてみる
本題です。同じ Finding(AttackSequence:EC2/CompromisedInstanceGroup、Severity 9)に対して 3 種類の trigger-prompt を試しました。
プレビュー段階ではプロンプトに渡せる文字数は2048文字なので注意しましょう。
パターン 1: シンプルなプロンプト
まずは Finding ID を渡すだけのシンプルなプロンプトです。
aws guardduty create-investigation \
--detector-id <DETECTOR_ID> \
--trigger-prompt "Analyze findingId: abc1234def5678abc1234def56789012" \
--region ap-northeast-1
結果(抜粋)
{
"Status": "COMPLETED",
"RiskLevel": "Critical",
"Confidence": "High",
"Risk": "Single EC2 instance confirmed conducting sustained Tor-based C2 and cryptomining DNS activity within a 42-minute window; behavioral evidence independently supports Critical severity. Resource name pattern and known canary domain suggest possible GuardDuty tester-stack activity, but attacker-controllable names are not used to downgrade the assessment."
}
RiskLevel が Critical、Confidence が High です。この Finding はリソース名が GuardDuty のテスター環境を示すものだったのですが、「リソース名は攻撃者が制御できるため評価の引き下げには使わない」とRiskに明示されています。
パターン 2: テスター環境であることを伝える
「これは GuardDuty のテスター環境です。本当の脅威かテストの動作かを評価してください」という意図を込めてみました。
aws guardduty create-investigation \
--detector-id <DETECTOR_ID> \
--trigger-prompt "Investigate finding abc1234def5678abc1234def56789012. This instance is part of our GuardDuty tester stack used for testing. Please assess whether this is expected test behavior or a real threat." \
--region ap-northeast-1
結果(抜粋)
{
"Status": "COMPLETED",
"RiskLevel": "Critical",
"Confidence": "High",
"Risk": "Confirmed multi-stage EC2 compromise with Tor-based C2 (T1090.003) and cryptomining resource hijacking (T1496) on instance i-09c137c1ad29d4d6d, corroborated by independent network and DNS behavioral signals; both finding types are novel for this account baseline."
}
RiskLevel は Critical、Confidence は High のままでした。テスター環境だと伝えても評価は変わりませんでした。
パターン 1 の Risk でも説明されていましたが、リソース名やスタック名は攻撃者が制御できる情報なので、評価の引き下げには使わないようです。
パターン 3: IAM 認証情報の観点を指定する
今度は分析の焦点を絞って「IAM 認証情報の漏洩と即時の封じ込め」を優先するよう指示しました。
aws guardduty create-investigation \
--detector-id <DETECTOR_ID> \
--trigger-prompt "Investigate finding abc1234def5678abc1234def56789012. Focus on whether IAM credentials attached to this instance may have been compromised and what immediate containment actions are needed." \
--region ap-northeast-1
結果(抜粋)
{
"Status": "COMPLETED",
"RiskLevel": "High",
"Confidence": "Medium",
"Risk": "Real outbound Tor C2 traffic to three reputation-confirmed Tor IPs on a single EC2 instance with an attached IAM instance profile; the cryptomining Impact signal derives from a known GuardDuty canary/test domain, and EC2 Runtime Monitoring is disabled, limiting host-level corroboration"
}
RiskLevel が High(パターン 1・2 は Critical)、Confidence が Medium(パターン 1・2 は High)に変わりました。
Risk フィールドを見ると、cryptomining の DNS クエリが GuardDuty のテスト用カナリアドメイン由来である可能性を言及しています。IAM 認証情報の観点から証拠を再検討した結果、Impact シグナルの一部がテスト用ドメインによるものだと認識されました。
その不確実性が Confidence の低下につながったと考えられます。
3 パターンの比較
| シンプル | テスター環境を伝える | IAM 認証情報にフォーカス | |
|---|---|---|---|
| RiskLevel | Critical | Critical | High |
| Confidence | High | High | Medium |
| 変化 | ベースライン | 変わらず | 下がった |
「テスター環境です」と伝えても評価は変わりませんでしたが、「IAM 認証情報に注目して」と分析の焦点を絞ると評価が変わりました。
trigger-prompt は finding ID を渡すだけでなく、何を確認してほしいかの観点を具体的に指示することで、より調査目的に合った出力が得られそうです。
まとめ
GuardDuty Investigation の trigger-prompt を AWS CLI からいろいろ試してみました。
EventBridge と Lambda を組み合わせ、Finding が発生したタイミングで自動的に Investigation を実行するフローも作れます。trigger-prompt に調査観点のテンプレートを埋め込んでおけば、一貫した分析結果が得られそうです。
以上、鈴木純がお送りしました。







