mcpField
T
threat-modeling-with-aws-security-agent

threat-modeling-with-aws-security-agent

github.com/awsセキュリティ3.3k1.6k 回インストール1 日前に更新
リポジトリ

threat-modeling-with-aws-security-agent について

要件・設計ドキュメントとソースコードを STRIDE に基づいて照合し、セキュリティ態勢の変化を特定するスキルです。AWS Security Agent で脅威モデルをレビューするチーム向けで、事前スキャンは不要です。

主な機能

  1. 01仕様書とソースコードの照合
  2. 02STRIDE による脅威の分類
  3. 03脅威モデルジョブの作成と確認
  4. 04影響と推奨策を含むレポート

活用シーン

  1. 01設計変更によるセキュリティリスクの評価
  2. 02要件・設計に基づく脅威の特定

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/aws/agent-toolkit-for-aws --skill threat-modeling-with-aws-security-agent

インストール後、Claude Code で/threat-modeling-with-aws-security-agentを入力して読み込まれたか確認します。

詳細

AWS Security Agent — 脅威モデルレビュー

STRIDE 手法を使用して、仕様書(requirements.md、design.md)をソースコードと照合し、セキュリティ態勢の変化を特定します。事前のスキャンは不要です。

ローカルの状態

.security-agent/config.json を読み込み、agent_space_id と region を確認します。値がない場合は、先に setup-security-agent ワークフローをインラインで実行してください。

必要な値の解決方法
プレースホルダー解決方法
<id>(エージェントスペース)config.agent_space_id
<region>config.region(デフォルトは us-east-1)
<account>aws sts get-caller-identity --query Account --output text
<role-arn>arn:aws:iam::<account>:role/SecurityAgentScanRole
<bucket>security-agent-scans-<account>-<region>

ワークフロー

  1. 事前確認。 設定を読み込み、エージェントスペースを検証し、値を解決します。

  2. 仕様ファイルを収集。 ユーザーが作業中の requirements.md および/または design.md を特定します。絶対パスを使用してください。レビュー対象のファイルが不明な場合は、ユーザーに確認してください。

  3. ワークスペースを ZIP 化します(コードスキャンと同じ除外設定を使用)。

    cd <absolute-workspace-path>
    zip -r /tmp/source.zip . \
      -x ".git/*" -x ".security-agent/*" -x "node_modules/*" \
      -x "__pycache__/*" -x ".venv/*" -x "venv/*" \
      -x "dist/*" -x "build/*" -x "target/*" \
      -x ".mypy_cache/*" -x ".pytest_cache/*" -x ".tox/*" \
      -x ".next/*" -x "cdk.out/*" -x ".DS_Store" -x "*.pyc"
    
  4. ソース ZIP をアップロード:

    SCAN_ID="tm-$(date +%s)-$(openssl rand -hex 3)"
    WORKSPACE_ID=$(printf '%s' "$(pwd)" | md5sum | cut -c1-12)
    aws s3 cp /tmp/source.zip s3://<bucket>/security-scans/source/${WORKSPACE_ID}/source.zip --expected-bucket-owner <account>
    
  5. 仕様ファイルをアップロード:

    aws s3 cp /path/to/requirements.md s3://<bucket>/security-scans/threat-models/${SCAN_ID}/specs/requirements.md --expected-bucket-owner <account>
    aws s3 cp /path/to/design.md s3://<bucket>/security-scans/threat-models/${SCAN_ID}/specs/design.md --expected-bucket-owner <account>
    
  6. 脅威モデルを作成:

    aws securityagent create-threat-model --agent-space-id <id> --title <title> \
      --service-role <role-arn> \
      --assets sourceCode=[{s3Location=s3://<bucket>/security-scans/source/${WORKSPACE_ID}/source.zip}] \
      --scope-docs '[{"s3Location":"s3://<bucket>/security-scans/threat-models/'${SCAN_ID}'/specs/requirements.md"},{"s3Location":"s3://<bucket>/security-scans/threat-models/'${SCAN_ID}'/specs/design.md"}]'
    

    threatModelId を記録します。

  7. 脅威モデルジョブを開始:

    aws securityagent start-threat-model-job --agent-space-id <id> --threat-model-id <tm-id>
    

    threatJobId を記録します。

  8. scan_type: "THREAT_MODEL" を指定して scans.json に保存します。

  9. ユーザーに次のように伝えます:「脅威モデルレビューを開始しました。所要時間はワークスペースのサイズによって異なります。2 分ごとに確認します。確認を中止する場合は「stop polling」と入力してください。」

  10. 2 分ごとにポーリングします。

    aws securityagent batch-get-threat-model-jobs --agent-space-id <id> --threat-model-job-ids <tj-id>
    

    ステータスが変化した場合にのみ応答します。

  11. COMPLETED の場合 → 脅威を取得します。

    aws securityagent list-threats --agent-space-id <id> --threat-job-id <tj-id>
    

    nextToken がある場合は、--next-token を指定してページネーションします。

検出結果の提示

各脅威には、statement、severity、stride カテゴリ、threatImpact、recommendation、impactedAssets が含まれます。

🟣 CRITICAL: {statement}
   STRIDE: {stride}
   Impact: {threatImpact}
   Assets: {impactedAssets}
   Recommendation: {recommendation}

🔴 HIGH: {statement}
   ...

レポート全文を .security-agent/findings-{scan_id}.md に書き込みます。以前の設計からの後退にあたる脅威があれば、明記してください。


ルール

  • 脅威モデルレビューは単独で実施でき、事前のスキャンは不要です
  • ポーリングは 2 分ごとに行い、それより短い間隔では行いません
  • 仕様ファイルが少なくとも 1 つ必要です
  • ワークスペースと仕様ファイルには絶対パスを使用します
  • タイトル:threat-model-<feature-name>(スペースなし)

コメント