Google、コーディングエージェント向けセキュリティツール「Mantis Skills」公開
Mantis Skills は、コーディングエージェントを用いたセキュリティレビューを自動化するためのポータブルツールキットであり、ハードウェアからクラウド構成まで多様な環境での自律的な脆弱性検出と検証を可能にする。
キーポイント
自律型コード生成と実行のリスク管理
本ツールは不安定なコードを自動的に生成・実行する機能を有しており、生産環境や機密データへのアクセスを厳禁し、隔離された環境での使用のみが許可されている。
多様な技術スタックへの対応
汎用的なセキュリティ問題の検出に加え、ハードウェア(RTL)、インフラストラクチャコード(IaC)、データ/ML パイプライン、コンパイル済みバイナリなど、幅広い分野でのレビューが可能。
AI 生成結果の人的検証の必要性
AI モデルは幻覚や誤ったパッチを生成する可能性があるため、すべての発見事項はセキュリティ専門家による手動検証が必須であり、未検証な報告の自動提出は禁止されている。
柔軟なスキルベースのアプローチ
rigid な指示セットではなく、組織固有のソフトウェアやハードウェアスタックに合わせて適応・調整・拡張可能な「Skills」の集合体として設計されている。
反復的なセキュリティレビューループ
Mantis は脅威モデリングから始まり、調査、重複排除、検証、修正、そして再攻撃のバイパスを試みるまでの一連のプロセスを継続的にループさせる設計になっています。
構造化された知識と成果物の管理
各ステップで学習履歴や発見結果が JSONL や Markdown 形式でファイルに保存され、後続の工程(特にアーキテクチャ分析やレポート生成)で参照・更新される仕組みを持っています。
修正と再検証の自動フィードバック
パッチ適用後に「再攻撃バイパスループ」が設定されており、修正が有効かどうかを自動的に再検証し、必要に応じて調整を加えることでレビューの精度を高めます。
重要な引用
[!CAUTION] USE AT YOUR OWN RISK. BE EXTREMELY CAREFUL.
All findings must be manually verified by a security expert before being reported.
Mantis Skills is a decoupled, sequential, and security-focused set of Skills designed for use with Coding Agents.
Pat -.->|Re-attack Bypass Loop| Rep
Rpt -.->|Next Loop Iteration| Arch
AI agents are non-deterministic. They may occasionally attempt unsafe actions or bypass intended constraints if the local environment allows it.
影響分析・編集コメントを表示
影響分析
このツールは、AI エージェントをセキュリティ運用に組み込む際の「実装フレームワーク」として重要な役割を果たす可能性があり、従来の静的解析ツールではカバーしきれない論理欠陥やビジネスロジックの脆弱性検出を自動化する新たな基準を示唆しています。しかし、その自律実行能力ゆえに、組織が導入する際には厳格なガバナンスと人的検証プロセスの確立が不可欠であることを強く示しています。
編集コメント
Mantis Skills は、AI を単なるチャットボットとしてではなく、自律的なセキュリティ調査員として機能させるための具体的な実装例を提供しており、DevSecOps の未来像を形作る重要な一歩と言えます。ただし、その強力な自動化能力は「二刃の剣」であり、導入組織には高度なリスク管理と人的監督体制が求められることを念頭に置く必要があります。
Mantis Skills:セキュリティレビュー環境構築のためのポータブルツールキット
**
[!CAUTION] 自己責任で使用してください。極めて注意深く扱ってください。 このスイートは、不安定な動作や予期せぬ行動を引き起こす可能性のあるコードを自律的に生成・実行するために設計されています。隔離され制限された環境でのみ使用してください。** 本番システム、機密データ、または社内ネットワークにアクセス可能なマシンでこのスイートを実行しないでください。必須のハードニング要件については、「無人クラウドデプロイ」セクションをご覧ください。
**
[!IMPORTANT] 責任ある利用について AI モデルは非決定論的であり、誤った発見を報告したり、不適切なパッチを生成する可能性があります。すべての発見結果は、セキュリティ専門家による手動検証を経るまで報告しないでください。** 未検証の AI 生成レポートをオープンソースプロジェクトのメンテナに大量送信することは避けてください。脆弱性の再現に失敗したからといって必ずしも偽陽性とは限らず、逆に再現に成功しても、すべての文脈でそのバグが実際に悪用可能である保証はありません。これらのスキルは責任を持って利用してください。
Mantis Skills は、コーディングエージェントとの併用に設計された、分離型かつ逐次的なセキュリティ特化型のスキルセットです。これは厳格な指示の羅列というよりも、柔軟な基盤および出発点として機能することを意図しています。組織固有のソフトウェアまたはハードウェアスタックに合わせて、これらのスキルを適応させ、調整し、拡張していく必要があります。
例えば、デフォルトのスキルは一般的なセキュリティ問題やビジネスロジック上の欠陥、権限管理の脆弱性を検出するように設計されていますが、以下のような用途にも適応可能です。
- ハードウェア/RTL レビュー:SystemVerilog や VHDL などのレジスタ転送レベル(RTL)設計を監査し、セキュリティ特性や論理的なバグを検証します。
- Infrastructure-as-Code (IaC):クラウドのデプロイ境界、Terraform の状態管理、または Kubernetes の RBAC 設定を分析して、権限昇格の経路を特定します。
- データ & ML パイプライン:学習データの取り込み、モデルのシリアライズ形式(例:Pickle 関連の脆弱性)、データサイエンス用ノートブックと本番環境の間の境界制約などを監査します。
- コンパイル済みバイナリおよびファームウェア(グレーボックス監査):ソースコードを提供せず、unblob、Ghidra、radare2、qemu、unicorn などのツールを使用してコンパイルされたリリースアーティファクトを分析対象とします。このモードの目的は、第三者のセキュリティ研究者になりすまして、公開されたバイナリしか入手できない攻撃者が実際に発見できる脆弱性が何であるかを明確に把握することです。
- カスタムテスト環境:デフォルトのコンテナ再現ステージを置き換え、孤立した仮想マシン(VM)、USB/シリアル経由での物理ハードウェアテストベッド、または独自のカスタムシミュレーターを利用します。
これらのスキルを AI を活用して反復的に改善し、社内ドキュメントやコーディング規約、ビルドシステムを活用して脅威モデルを補強することを強く推奨します。また、環境やリスク許容度に合わせてリスクの較正(キャリブレーション)も適応させるようお勧めします。
AI システムのセキュリティに関する詳細は、Google の Secure AI Framework (SAIF) をご覧ください。
このスイートを使えば、エージェント型コーディングツールを持つ人なら誰でも、あらゆる規模のコードベースに対して体系的なレビュー、重複排除、検証、批判、再現、パッチ適用を行うことができます。また、反復的な実行を通じてスイート自体が適応し、冗長な分析を避けるための継続的な学習ループも備えています。
何より重要なのは、オーケストレーションされた脆弱性発見の能力が非常に強力かつ有用である一方で、本番環境への影響を防ぐために、必ず適切に隔離された環境で利用することです。このガイドの後半にある「無人でのクラウドデプロイメント」に関する注意事項も併せてご確認ください。
アーキテクチャとシーケンシャルフロー
パイプラインは 16 の個別コンポーネント(スーパーバイザー 1 つと実行ステージ 15)で構成され、workspace/findings/*.json ディレクトリ内の発見ファイル群の状態を維持します。この一連のプロセス全体は、上位の /mantis_meta_agent が自律的に監督・制御できます。
graph TD
Meta["/mantis_meta_agent (Supervisor)"]
「継続的なレビューループ」のサブグラフには、以下の要素が含まれます。
/mantis_history(オプション)/mantis_summarize(オプション)/mantis_architecture/mantis_threat_model/mantis_plan/mantis_researcher/mantis_dedupe/mantis_review/mantis_critic/mantis_reproduce/mantis_chain/mantis_patch/mantis_calibrate/mantis_reflect/mantis_report
また、関連するファイルも定義されています。
historical_learnings.jsonlmantis_summary.mdworkspace/kb/(Markdown 形式の知識ベース)plan.jsonworkspace/findings/*.jsonlearnings.jsonlworkspace/report/review_packet.md
これらの要素間の関係は以下の通りです。
メタデータ(Meta)から履歴(Hist)へ、さらに要約(Sum)、アーキテクチャ(Arch)、脅威モデル(TM)、計画(Plan)、調査(Res)、重複排除(Ded)、レビュー(Rev)、批評(Cri)、再現(Rep)、連鎖(Cha)、パッチ(Pat)へと流れが進みます。ここで重要な点は、パッチ適用後に再攻撃回避ループ(Re-attack Bypass Loop)が形成され、再び再現プロセスへ戻る点です。その後、キャリブレーション(Cal)、反射(Ref)、レポート作成(Rpt)へと続き、最終的に次のループの開始としてアーキテクチャ(Arch)へ戻ります。
各ステップでは、特定のファイルへの読み書きが行われます。例えば、履歴は historical_learnings.jsonl を生成し、要約は mantis_summary.md を生成します。また、アーキテクチャプロセスは知識ベース(KB)を生成・更新し、脅威モデルや計画プロセスも KB や要約ファイルを参照して情報を統合します。最終的に、レビューパケットとして review_packet.md が出力されます。
このフローにより、セキュリティレビューの継続的な改善と自動化が実現されています。
Res は FilePlan を読み取り、FileKB も読み取り、さらに FileFind を作成します。Ded は FileLearn を読み取り、その結果を FileFind にマージします。Rev、Cri、Rep の各プロセスは FileFind を更新します。Cha は FileKB を読み取り、FileFind を作成し、Pat と Cal はそれぞれ FileFind を更新します。
Ref はトラジェクトリ(経路)を解析して FileLearn に追加し、Cri と Pat も同様に FileLearn へデータを追加します。
Rpt は FileFind を読み取り、FileRpt を生成します。
- /mantis_meta_agent (スーパーバイザー): 継続的なループを開始・監視し、実行状況を把握してエラーを処理し、発見事項を報告する永続型のオーバリングエージェントです。また、各ループの間にワークスペースや findings ディレクトリ、archive ディレクトリのアーカイブ管理も担当します。
- /mantis_history (履歴抽出器): オプションの前処理ステップで、リポジトリのバージョン管理システム(VCS)の履歴を分析し、過去の脆弱性やセキュリティ修正、脆弱性のパターンを抽出して findings を historical_learnings.jsonl に保存します。
- /mantis_summarize (要約器): オプションの前処理ステップで、各ディレクトリごとに mantis_summary.md を生成します。historical_learnings.jsonl から過去の脆弱性情報を読み込んで要約内容を充実させ、下流の計画策定や調査を最適化するためのクイックリファレンスマップを提供します。
/mantis_architecture(知識ベースアーキテクト):コードベースを分析し、learnings.jsonlの受信トレイをクリアして、エンティティ、データフロー、過去の脆弱性クラスを詳細に記述した永続的で相互リンクされた Markdown 形式の知識ベース(workspace/kb/)を構築します。
/mantis_threat_model(脅威モデラー):知識ベースで定義されたエンティティとアーキテクチャを評価し、信頼境界や攻撃者のプロファイルに焦点を当てて、生きている状態のworkspace/kb/THREAT_MODEL.mdを作成または更新します。
/mantis_plan(戦略立案者):ワークスペースの境界をスキャンし、知識ベースのインデックスを読み込んで、文脈となる特定の kb_references ファイルパスを注入したターゲット型のレビュー戦略をplan.jsonとして出力します。
/mantis_researcher(マントリス・リサーチャー):ファイル単位でトリアージを実行し、深刻なセキュリティ欠陥の深掘りレビューを行い、ホットスポットを個別の JSON ファイルとしてworkspace/findings/に出力します。
/mantis_dedupe(重複排除):インデックスベースの重複した発見事項をグループ化し、レコードを統合してworkspace/findings/内の冗長性を削除します。
/mantis_review(検証者):厳格な実用的な制約を用いて偽陽性をフィルタリングし、workspace/findings/<id>.jsonのステータスを更新します。
/mantis_critic(批評家):リリースビルドでのクラッシュ再現性(デバッグやアサートチェックは無視)を検証し、プロダクション環境での実用性をworkspace/findings/<id>.jsonに反映させます。また、偽陽性や実用性の低いパスをlearnings.jsonlへ追加します。
- /mantis_reproduce (Proof-of-Concept Developer): Proof-of-Concept の再現スクリプト(Repros)や生ペイロードを作成し、gVisor や仮想マシンなどの隔離環境で実行します。その後、workspace/findings/<id>.json 内の再現ステータスを更新します。
- /mantis_chain (Vulnerability Chainer): 個別に検証された脆弱性情報とナレッジベースの要素を分析し、複雑な多段階の攻撃チェーンを特定・構築します。これにより、workspace/findings/ 内に新たな「スーパー発見(Super Findings)」が生成されます。
- /mantis_patch (Patcher): コード修正を自動生成して適用し、サンドボックス内で事後検証テストを実行します。修正ステータスは workspace/findings/<id>.json に更新され、ログは learnings.jsonl へ追加されます。
- /mantis_calibrate (Risk Calibrator): 各発見事項について、影響度、証拠の確実性、実行可能性を基に最終的な数値リスクスコア(1〜10)である「Mantis Risk Score」を算出します。その結果は、workspace/findings/<id>.json ファイルに直接追加されます。
- /mantis_reflect (Reflector): 現在のラウンドにおけるエージェントの実行軌跡を解析し、誤った前提条件やツールの失敗・成功事例を抽出します。これらの構造化された知見は learnings.jsonl のインボックスへ追加されます。
- /mantis_report (Reporter): 検証済みまたは再現された発見事項、証拠、リスク判断の根拠、修正情報を盛り込んだ人間が読みやすいセキュリティレビューパケットを生成します。出力先は workspace/report/review_packet.md です。
Prerequisites and Setup
どのスキルを実行する前に、ローカル CLI 環境が完全に設定されていることを確認してください:
- Gemini CLI または Antigravity CLI がインストールされていること(他のツールでも動作する可能性があります)。
- Docker のインストールと起動(ローカル環境で「サンドボックス化」された実行を行うために必須)。
- gVisor (runsc) のインストールと Docker への登録(推奨):信頼できない AI 生成のクラッシュ再現コードを実行する際のセキュリティ強化のために、Docker デーモンの設定ファイル (/etc/docker/daemon.json) に runsc ランタイムを登録してください。以下の JSON を使用します。
{
"runtimes": {
"runsc": {
"path": "runsc"
}
}
}
設定適用には Docker の再起動が必要です:sudo systemctl restart docker。
- 関連する Cloud SDKs:ローカルのコンテナではなく、リモートクラウドのサンドボックス環境で実行する場合に必要です。
スキルのインストール方法
これらのスキルは、全プロジェクトで利用可能な「グローバル」設定か、特定のワークスペースに限定した「ローカル」設定のどちらかでインストールできます。また、コーディングエージェントにヘルプを依頼することも可能です。
初心者向けガイドとベストプラクティス
自動化された AI 支援による防御的セキュリティレビューが初めてという方は、以下の推奨事項を心に留めておいてください:
1. 「インタラクティブモード」 (Human-in-the-Loop)
- 概要: 完全に無人で長時間稼働するパイプラインの導入にまだ踏み切れないユーザーや組織向けです。このような場合は、パイプラインを「インタラクティブモード」で実行してください。
- 使い方: 通常通り CLI を起動します(ターミナルで
agyまたはgeminiと入力)。その後、インタラクティブなチャット UI の中で、スラッシュコマンド(例:/mantis_plan)を一つずつ手動で実行してください。CLI 起動時に--yoloや--dangerously-skip-permissionsといったフラグは使用しないでください。
- なぜ重要か:CLI は、特に
/mantis_reproduceや/mantis_patchエージェントが Docker サンドボックスの実行やファイルへの書き込みを試みる際など、機密性の高いコマンドを実行する前に一時停止し、人間の承認を求めます。これにより、AI が何を実行しようとしているかを確認できます。人間の承認なしで実行するには、エージェントを確実に閉じ込めるためのより強力な境界設定が必要です。
2. 強化されたセキュリティと「ホストでの直接実行禁止」ルール
- なぜ重要か:AI モデルは、ホスト環境を破損させるようなコードペイロードを生成することがあります。スクリプトの内容を確認しない限り、必ずサンドボックス内で実行してください。
- Mantis の保護策:
/mantis_reproduceと/mantis_patchスキルには、明示的にネットワーク機能を無効化した(例:--network none)隔離されたコンテナ環境内でペイロードを実行するよう指示されています。
- 免責事項:これらの指示は分離状態の維持を目的としていますが、AI エージェントは非決定論的な性質を持っています。ローカル環境の条件次第では、意図しない不安全な行動をとったり、設定された制約を回避しようとする可能性がゼロではありません。この指示だけで絶対的な安全性が保証されるわけではありません。必ず、後述する GCE セクションで詳述されているように、専用の隔離 VM 上でこのスイートを実行し、AI が脱出できない合理的なセキュリティ境界を確保してください。
3. モデルの選定と段階的な効率化
自動化パイプラインの速度と効率を最大化するには、タスクごとに適切な AI モデルクラスを戦略的に組み合わせることが重要です。すべての工程で最も重く高度な最先端モデルを使う必要はありません。
- Tier 1(トリアージと重複排除): Wave 1 の/mantis_researcherのような高速な分類スキャンや、/mantis_dedupe で類似するテキストパターンをクラスタリングする場合などには、高速な「flash」または「lite」ティアのモデルを選びましょう。これらのタスクに深い論理処理は不要で、単なるテキストの高速解析で十分です。これにより、大量のファイルスキャンを並列化してもボトルネックになりません。基本的な指示すら理解できないほど低性能なモデルを選ぶのは避けるべきですが、一方で知能を過剰に投入してパイプラインを遅くさせることも避けましょう。プランナーが研究タスクごとに難易度を指定できるようにし、単純な質問は高速モデルで処理しつつ、より複雑な脆弱性発見タスクには最先端の高性能モデルを活用する仕組みも検討してください。
- Tier 2(深層推論): 深い文脈理解とゼロショット問題解決が求められる極めて複雑な工程には、最も強力な重厚な推論型フラッグシップモデルを割り当てましょう。具体的には、機能的なクラッシュ再現コードを書く/mantis_reproduce や、副作用のないコードベースの修正を行う/mantis_patch です。
- ポイント: 非常に大規模なリポジトリを扱う場合は、/mantis_plan を設定して src/crypto/や api/など特定のリスクが高いサブフォルダに焦点を絞り込み、スキャンの集中と効率性を保ってください。
パイプラインの異なる部分で、さまざまなモデルの階層を試して、何がうまく機能し、何がそうでないかを確認しましょう。
4. 偽陽性の理解(「ネガティブフィルター」ルール)
- 期待すべきこと:AI スキャナは過剰に反応することがあります。これを防ぐため、/mantis_review ステージでは 12 のネガティブルールを適用する厳格なバリデーターが動作します。なお、この 12 ルールは絶対的なものではなく、ユースケースに合わせて適応、再定義、あるいは独自のステージとして独立させる必要もあります。
- 低リスクやハードニング関連の検出は偽陽性ではない:脆弱性のトリアージにおける最初の段階として、リスクの適切な調整が極めて重要です。パイプラインを調整する際は、偽陽性と「現在の許容リスク水準未満の事象」の違いを見極め、脆弱性の検知能力に悪影響が出ないよう注意してください。
- 実用主義:AI を活用した脆弱性スキャンは、従来の SAST(静的アプリケーションセキュリティテスト)と同様に、多くの偽陽性を生む可能性があります。しかし、従来の SAST と異なり、複雑なルールを作成することなく調整する方法があります。試行錯誤して何が機能し、何が機能しないかを確認し、それに応じて柔軟に対応しましょう。
- 一度にすべてを流し込まない:実用主義の推奨事項と同様に、まずは小規模なスキャンを実行し、いくつかの結果をトリアージした上で、そのフィードバックを元にスキャンパイプラインを構築する方がはるかに効率的です。すべての対象をスキャンして潜在的な脆弱性をすべて報告するのは一見有効に見えますが、私たちの経験では、この新しい技術を導入する際の最も成功する手法とはなりにくいでしょう。
パイプラインの実行(手動モード)
レビューの各工程は、アクティブな CLI ターミナル内から順次実行できます。
ターミナルから CLI を起動します。
インタラクティブな UI プロンプトでは、以下のスキルを順番に入力してください:
0. (任意)リポジトリのバージョン管理システム(VCS)履歴を分析し、過去の脆弱性を抽出する
/mantis_history
1. (任意)mantis_summary.md ディレクトリマップを生成する
/mantis_summarize
2. コードベースの構造と過去の学習成果を統合し、Markdown 形式の知識ベース(KB)を作成する
/mantis_architecture
3. KB を基にプロジェクトの動的脅威モデルを反復的に構築する
/mantis_threat_model
4. ターゲットとなる外部境界をマッピングし、KB の参照を組み込んでスキャンロードマップを構築する
/mantis_plan
5. 注入された文脈を用いて、マルチスレッドまたは逐次的なセキュリティ欠陥のスクリーニングを実行する
/mantis_researcher
6. 重複するファイルとバグを統合・整理する
/mantis_dedupe
7. コードの有効性を検証し、偽陽性をフィルタリングする
/mantis_review
8. 実運用で対応が困難な課題を除外する
/mantis_critic
9. 概念実証(PoC)のクラッシュ再現プログラムを生成し、サンドボックス内で実行する
/mantis_reproduce
10. 検証済みの個別の発見事項を組み合わせて、多段階の攻撃チェーンを構築する
/mantis_chain
11. 最小限の修正を適用し、クラッシュ再現プログラムがブロックされることを確認する
/mantis_patch
12. 最終的なリスク評価マトリクスを算出し、個別の発見事項に付加する
/mantis_calibrate
13. 実行軌跡から洞察を抽出し、学習インボックスへ追加
/mantis_reflect
14. (手動ステップ)次のループを開始する前に、workspace/findings/ ディレクトリをアーカイブ用ディレクトリへ移動させる
決定論的なパイプラインの構築(本番環境向け)
/mantis_meta_agent は探索的なセキュリティ研究のための動的な制御を提供しますが、企業利用や本番環境での運用においては、Mantis Skills を 決定論的なプログラムパイプライン(Python、Bash、Rust、または CI/CD ワークフローなど)に包み込むことを強く推奨します。
/mantis_researcher、/mantis_review、/mantis_reproduce といった個々のスキルを、workspace/findings/ ディレクトリ内で JSON 状態を読み書きするマイクロサービスとして扱い、堅牢なオーケストレーターを構築すれば、絶対的な信頼性と厳格なセキュリティ保証を実現できます。さらに言えば、単一のマシン上の JSON ファイルに頼るのではなく、より耐久性と回復力のあるデータベースの利用を検討すべきです。
ハーン(運用基盤)を構築する前に、schema.json で定義された各ステージ間のデータ契約を厳守してください。 もちろん、ご自身の環境に合うようにスキーマを変更することも可能です。ここでは厳格なルールはあまりありません。
パイプラインアダプタースキル (/mantis_pipeline_adapter)
必ず JSON 形式で返答してください。translation フィールドのみを含めてください。他のフィールドは一切追加しないでください。余計なフィールドを追加しようとして本文がトークン上限に達し、出力が途中で切れてしまう事故を防ぐためです。
高信頼性、トークン効率(UUID ベースの参照など)、カスタム環境への適応性(MCP を経由)を備えた独自のパイプライン構築を検討する際は、Pipeline Adapter Guide をご覧ください。
スタンドアロンモードとハレスモードに関する注意: Mantis Skills を CLI から直接スタンドアロンモードで使用する場合、/mantis_review や /mantis_patch などのスキルは、LLM に一時的な再利用可能な Python スクリプトを作成させて JSON ステートファイルを更新させるよう指示します。しかし、真の意味でプログラムされたハレス(運用環境)では、オーケストレーターがこれらの指示を上書きし、状態管理のためにネイティブのツール呼び出しや関数を提供する必要があります。LLM に都度スクリプトを書かせるのは避けるべきです。
プログラムによるハレスを構築する理由
- 決定性: 再現エージェントやパッチエージェントなどの一部の工程では、サブエージェントが再現結果やパッチのレビューを行うよう推奨されています。全体ワークフローのデモとしては妥当ですが、エージェントが「批評サブエージェントの呼び出しを忘れる」といった抜け道を使えず、より決定性の高い批評段階を設けることで、成果は向上する可能性が高いです。
- プロンプトインジェクションリスクの軽減: LLM がシェルスクリプトをオーケストレートする場合、悪意のあるコードを取り込むとホストレベルのプロンプトインジェクションに脆弱になります。オーケストレーションを堅牢な決定性パイプラインに移行すれば、LLM がホスト環境を直接制御するリスクを排除できます。
- 厳格なサンドボックスの強制: LLM に
--network noneオプションを指定してクラッシュ再現を行うよう記憶させるのではなく、決定論的なハルネスがプログラム側で制御し、信頼できない AI 生成ペイロードを実行する環境をロックダウンされた VM、コンテナ、または gVisor サンドボックスに限定します。
- CI/CD への統合: 静的解析と重複排除のステージを実行する決定論的なスクリプトは予測可能であり、GitHub Actions や Jenkins などの標準的な自動化ワークフローへ容易に組み込むことができます。
- スケーラビリティ: パイプラインを複数の構成要素に分割できるため、利用状況が低い時間帯には適切な数のマシンを並列稼働させて水平方向への拡張が可能です。
- 決定論的なレポート作成: パイプラインは内部状態を安全に維持するために機械可読な JSON ファイル(
workspace/findings/*.json)を利用しますが、プログラムによるハルネスがこれらの JSON 結果を人間が読みやすい Markdown レポートに変換したり、自動的にバグ追跡システムへ登録したりできます。これにより、LLM の幻覚や状態の破損リスクを回避できます。レポート作成プロセスの一部(必要に応じてエグゼクティブサマリーを提供するなど)にのみ LLM を使用すれば十分です。
ハイブリッドアプローチ
スイートの動的・適応的な性質を維持しつつ、実行の決定論性を確保するために、以下のようなパイプラインを構築できます。
- プログラムによる反復処理: ハルネスがワークスペースをループし、CLI を介して静的スキルと動的スキルを呼び出します。
- 学習結果のフィードバック:ハレスは生成された
learnings.jsonlファイルを読み込み、/mantis_planを呼び出して更新されたplan.jsonを作成します。これにより、AI が次の分析対象を決定し、決定的な実行ループを誘導することが可能になります。
- 実行サンドボックスの固定化:オプションで
/mantis_reproduceや/mantis_patchの決定的版を設定し、パッチやスクリプトファイルの生成のみを行わせることができます。実際の実行と採点は、厳格に管理されたサンドボックス内でハレス側で行うように設計できます。
非決定性の現実
セキュリティ研究で AI を活用する際、理解しておくべき重要な概念が「非決定性(Non-Determinism)」です。
- カバレッジは絶対的な保証ではない:ステージ 2(
/mantis_plan)ではプログラムされたシェルスクリプトを使ってコードベース全体をマッピングしようとしますが、それを実行するエージェント自体は本質的に非決定的です。スクリプトの失敗、パラメータの誤った生成(ハルシネーション)、あるいは手順の省略などが起こり得ます。
- 実行軌跡や会話の分析:非決定性の欠陥を補う一つの方法として、エージェントが行ったすべてのツール呼び出しをプログラムでレビューし、何を行ったかを把握することが挙げられます。これによりカバレッジや効率の指標を算出できますが、これらの数値が具体的に何を意味するかは、読者の想像に委ねます。
- ループをまたぐ推論のシフト:LLM の分析は非決定的であるため、最初のパスでは微妙なビジネスロジックの欠陥や権限回避を見逃しても、内部の「アテンション」が変化したり他の発見から文脈を得たりすることで、5 回目のパスで明確に特定される可能性があります。そのため、このスキャンパイプラインを複数回実行することを一般的に推奨しています。
- 収穫逓減:パイプラインは最終的にバグ報告を終了し、「完了」するものだと期待しがちですが、実際には発見が完全に止まることはなく、LLM が幻覚を起こしたり、些細な非問題点に執着し始めたりすると、発見の質や深刻度は次第に低下します。
この連続ループは、AI が見落としを防ぐために複数のパスを許容するよう設計されています。ただし、いつまでループを続けるかについては、各ユーザーが自らの責任でツールを試行し、発見された事案に対するリスクキャリブレータのスコアを確認した上で、発見の質が低下して停止すべきと判断するタイミングを決定する必要があります。長期的には、より高性能な新モデルが利用可能になった時や、コードベースに十分な規模の変更があったため単なる差分解析ではなく完全な再スキャンが必要となった時など、再スキャンの頻度をどう設定するかについても自らの判断で決める必要があります。
高度な/無人クラウドデプロイメント (GCE)
自律型かつ無人の状態で 24 時間 365 日、継続的なレビューループを実行することは、特にホストレベルのプロンプトインジェクションにおいて独自のセキュリティリスクをもたらします。それ以外にも、エージェントが単純なミスをおかして、意図しないアクションを実行してしまう可能性もあります。
その結果、無人モードで運用する場合は、隔離された Google Compute Engine (GCE) インスタンスのような堅牢化された仮想マシン(VM)へのデプロイが必須要件となります。(あるいは、個々のリスクのあるアクションをサンドボックス化する構造化された決定論的なパイプラインを構築することも可能ですが、これにはより多くの初期コストがかかります。)
1. 堅牢化された GCE 環境
AI エージェントが容易に脱出できないセキュリティ境界を提供するため、環境は以下の通り構成する必要があります。
- ネットワークの分離: GCE VM に外部インターネットへのアクセス権を与えないか、少なくとも信頼できるホワイトリストと適切なレート制限、および出口制御を備えた安全な Web プロキシを利用してください。
- VPC サービスコントロール (VPC-SC): VM を VPC-SC の境界内に配置します。これは、エージェントが乗っ取られた場合のデータ漏洩を防ぐ重要な防御策です。
- 最小権限のサービスアカウント: VM には専用 IAM サービスアカウントを紐付け、役割は厳しく制限してください。
roles/aiplatform.userやroles/storage.objectAdminのような広範なロールは使用しないでください。代わりに以下のように設定します。
カスタム AI ロール: aiplatform.endpoints.predict と aiplatform.endpoints.generateContent だけを付与するカスタム IAM ロールを作成します。これにより、エージェントがモデルを照会できる一方で、AI インフラストラクチャの改変を防ぐことができます。
- 追記専用 GCS ストレージの活用:中間結果やバックアップを保存するには、特定の GCS バケットに対してサービスアカウントに「roles/storage.objectCreator」と「roles/storage.objectViewer」のロールを付与します。ただし、削除権限(storage.objects.delete)は絶対に付与しないでください。同様の追記専用ストレージ機構を検討することも有効です。
- GCS のバージョン管理:GCS バケットでオブジェクトバージョン管理を有効にします。これにより、AI や信頼できないクラッシュ再現用ペイロードがファイル(例:learnings.jsonl)を上書きしても、以前の状態は非現在のバージョンとして残存し、AI による履歴の完全な削除を防ぐことができます。
2. インタラクティブプロンプトの回避(無人モード)
警告: これらのフラグを使用するのは、前述の「ハードニングされた GCE 環境」が完全に構築されている場合に限ってください。デフォルトでは CLI ツールはシステムコマンドを実行する前に手動確認を求めます。パイプラインを完全に無人で実行するには、CLI を起動する際に --dangerously-skip-permissions や --yolo のような自動承認フラグを指定する必要があります。
3. セキュリティ脆弱性の自動アラート通知(Cloud Pub/Sub)
無人モードで実行中に、パイプラインが信頼性の高いセキュリティ脆弱性を検出した際に、隔離された手段で通知を受け取りたい場合があります。その方法の一つとして、パイプラインをGoogle Cloud Pub/Subに接続することが挙げられます。
- 設定手順:Pub/Sub トピック(例:mantis-verified-vulns)を作成し、GCE VM のサービスアカウントに対して「roles/pubsub.publisher」ロールを付与します。
- Hooking it up: /mantis_meta_agent スキルを指定すれば、通知機能をネイティブにトリガーさせることができます。セキュリティ上の欠陥が確実に再現された際に、
gcloud pubsub topics publish mantis-verified-vulns --message="$(cat workspace/findings/<id>.json)"を実行するようにメタエージェントに指示を出せばよいでしょう。
- Routing: Google Cloud Function または Cloud Run サービスをその Pub/Sub トピックに購読させれば、アラートペイロードをチームのチャットツールや課題管理システム、 paging システムへ直接転送できます。これにより、分離されたスキャン環境と内部のアラートインフラストラクチャがきれいに切り離されます。
Meta-Agent Orchestration Pattern
真に自律的で永続的なセキュリティ運用を実現するには、/mantis_meta_agent スキルを呼び出してメタエージェントオーケストレーションパターンを採用できます。この構成では、高レベルの「メタエージェント」(長期間稼働する Gemini または Antigravity CLI セッション)がレビューパイプライン全体を主導します。
The Meta-Agent's Role:
- オーケストレーション:メタエージェントは、CLI サブエージェントへの委任を通じて各ステージの実行をネイティブに管理します。
- 永続性:単一の長期間会話内で動作し、数日や数週間にわたって継続します。これにより、会議中や帰宅後、週末であっても、セキュリティ欠陥の発見、パッチ適用、報告という目標に向かってレビューが止まることなく進行します。
- 監視:タスクを常に見守り、軽微な環境上の不具合に対応し、ログを読み込み、パイプラインが稼働状態にあることを保証します。
- インタラクティブなステアリング:このパターンの大きな利点は、サブエージェントが動作している最中にもメタ・エージェントとチャットできる点です。進捗状況の問い合わせや環境問題の共同デバッグ、あるいは「画像パーサーを深掘りせよ」といった高レベルな戦略的指示を与えることで、スワームの焦点をリアルタイムまたは次のループで即座に調整できます。
- セキュリティ境界:メタ・エージェントを自動承認フラグ(--dangerously-skip-permissions)付きで実行することは可能ですが、前述した堅牢化されたセキュリティ境界(VPC-SC、外部インターネットへの接続禁止、制限された IAM ロール)の内部に厳格に閉じ込める必要があります。
このパターンにより、単なるバラバラのツールの集合体から、継続的かつ自律的なセキュリティ調査オペレーションへと進化します。
Mantis Skills の評価と最適化
Mantis のような自律型マルチエージェント・パイプラインの評価は notoriously 困難です。プロンプトの微調整ごとに完全なエンドツーエンドの評価を実行するのは、時間と API トークンの観点からコスト高すぎます。これらのスキルを安全に修正したりモデルコストを最適化したりするには、階層型評価戦略を採用し、単なる成否(バイナリ)だけでなく、代替指標も測定する必要があります。
階層型評価戦略
必要な場合を除き、ループ全体を一度に評価するのは避けてください。評価は以下の 3 つのティアに分けます:
- ティア 1:静的チェック
概要:スキルファイルに対する高速なプログラムによるリンティング検査。
- 測定すべき項目:SKILL.md ファイルは正しくパースされるか、YAML のフロントマターは正しいか、必要なツールが定義されているか、システムプロンプトはコンテキストウィンドウの制限内に収まっているか。
- Tier 2: 隔離された「ユニット」評価
これは何なのか:パイプライン全体から完全に切り離し、単一のスキル(例:/mantis_patch)だけを評価する手法です。
- 設定方法:静的でハードコードされた入力(モックした findings.json と対象ファイル)を単一スキルに与え、その出力を観察します。
- 測定すべき項目:
フォーマット:期待通りの JSON スキーマまたは有効な差分(diff)が出力されたか。
ツール使用:正しいツール(run_command か view_file のどちらか)の呼び出しを試みたか。
LLM-as-a-Judge:より安価で高速なモデルを用いて、厳格な評価基準に基づき定性的な出力を採点します(例:「このパッチは SQL インジェクションへの対策になっているか?Yes/No」)。
- Tier 3: 「ゴールデンデータセット」によるエンドツーエンド評価
これは何なのか:パイプライン全体を実行する完全なテストです。メジャーリリース時や、基盤モデルのクラスを切り替える場合(例:最新フラッグシップモデルへのアップグレードなど)のみ実行してください。
- 設定方法:3〜5 の実世界の代表的な脆弱性を持つリポジトリからなる小さなデータセットを用意します。
- 測定すべき項目:二値の結果です。最終的なテストスイートはパスしたか、/mantis_reproduce は動作する PoC を生成できたか。また、人間による評価を行い、新たな脆弱性が発見されたかどうかを確認することも可能です。
「測定不能」なものの測り方
中間段階(例:/mantis_researcher など)を評価する際、単に「成功したか失敗したか」の二値で判断するのは困難です。代わりに、以下の代理指標を追跡して、スキルの低下を把握しましょう。
- ツールエラー率:エージェントがツール呼び出しを行った際に失敗する回数をカウントします(例:bash 構文の誤りや無効なファイルパスなど)。プロンプト変更後にエラー数が急増した場合、そのスキルの指示セットが劣化しているか、新しいモデルやコーディングエージェント用ハーンスに合わせてプロンプトを調整する必要があることを示しています。
- トランジェクト効率(ターン数/トークン数):もし /mantis_reproduce が以前は 5 ターンで PoC を記述できていたのに、プロンプトの微調整後に 150 ターン必要になったり、ループを繰り返したりする場合は、効率における明確な後退が測定できます。
- 「断念」率:エージェントが「判断できません」「行き詰まっています」といった表現を明示的に出力するか、トークン制限に達する前に無限ループに陥る頻度はどれくらいでしょうか?
「シャドウ評価」手法
最初から大規模な評価ハーンスを構築する必要はありません。データセットは有機的に育てていきましょう。
- パイプラインを手動で実行する際、エージェントが特定のタスクで失敗した瞬間を待ちます。
- その時の完全な開始状態(ユーザープロンプト、ワークスペース内のファイル、JSON 状態など)を保存します。
- エージェントが成功するまでスキル用のプロンプトを修正します。
- その特定の状態を孤立させた形で、最初の自動テストケースとして確立します。
実世界の失敗事例のみから評価データセットを構築することで、実際に問題となる後退の検証にのみトークンを使うことができます。
パイプラインの調整や、並列軌道探索(Parallel Trajectory Search)のような新機能の導入を行う際は、トークンの投資対効果を確認するために必ず実験を行ってください。
- 異なるモデルを試す:各工程において、主力モデルをより安価で高速なモデルや、コーディングに特化した専門モデルに差し替えて実験してください。本格的に展開する前に、Tier 2 の「ユニット」評価(Unit Evals)を用いて、コスト削減が成功率の低下を招かないか検証することが重要です。
- 並列軌道の効果を評価する:並列軌道探索を実装する場合(例えば、複数の研究者やパッチャーを同時に起動させる場合)、並行して動作させるエージェントの数(2 台、3 台、5 台など)を変えてテストしてください。もし並列で調査を行うと常に同じ脆弱性が見つかるだけなら、その並列化は独自価値を生んでおらず、単にトークンを浪費していることになります。一方で、並列でパッチを生成する方が、単独のエージェントよりもはるかにクリーンで自然な修正結果をもたらすのであれば、計算コストの増大も正当化されます。
ロードマップ / 今後の取り組み
- スキル自己改善(メタ学習):現在の learnings.jsonl とナレッジベース(KB)アーキテクチャは、コードベース固有の実証結果を追跡し、THREAT_MODEL.md やコンテキストポインタを適応させる役割を果たしています。今後のパイプラインのバージョンアップでは、この履歴データを活用して自己の SKILL.md プロンプトを見直し、自動的に書き換えることまで目指せるようになるでしょう。例えば、特定のタイプのハルシネーション(幻覚)が Critic によって繰り返し検出された場合、自己改善を行うメタエージェントが、Review ステージに到達する前にその特定のパターンを明示的にフィルタリングできるよう、Researcher の SKILL.md 指示を更新します。
セキュリティ上の注意:SKILL.md ファイルへの自動変更は、必ず人間による承認(ゲート)を経る必要があります。悪意のあるペイロードを含むターゲットファイルを通じてプロンプトインジェクション攻撃が行われ、メタエージェントが特定の脆弱性クラスをグローバルに無視するように仕向けられるリスクを防ぐためです。
- ソフトウェアのダークファクトリー:このパイプラインを、AI 駆動のソフトウェア開発全体に統合します。人間がアクションを起こすための脆弱性発見ではなく、Mantis は自律的な脆弱性調査およびリリースゲート担当コンポーネントとして機能します。ダークファクトリーが本番環境へ展開する前に、Mantis による N 時間の敵対的脆弱性調査(レッドチーム演習)を完了していることが必須条件となります。
トラブルシューティングガイド
1. ループ反復で同じコードを再評価している
- 症状:ループが同じファイルを繰り返しレビューし、同一のバグを報告し続ける。
- 解決策:
/mantis_architectureが正常に完了し、合成された知識をworkspace/kb/ディレクトリに書き込んでいることを確認してください。また、/mantis_planの戦略担当モジュールは、このナレッジベースを確認して既に分析済みの領域を動的にスキップします。ファイル権限がworkspace/kb/への書き込みを許可しているかも併せて確認しましょう。
2. その他の課題
- 症状: 何かが動作しない。
- 解決策: AI コーディングツールを使って、パイプラインや予期せぬ挙動を引き起こしている会話・トジェクト(軌跡)のレビューを依頼してください。多くの場合、有用な洞察が得られます。
本プロジェクトは Google の公式製品ではありません。また、Google Open Source Software Vulnerability Rewards Program の対象外です。
本プロジェクトはデモンストレーション目的のみを想定しており、本番環境での使用は意図されていません。
原文を表示
Mantis Skills: Portable Toolkit for Building Security Review Harnesses
[!CAUTION] USE AT YOUR OWN RISK. BE EXTREMELY CAREFUL. This suite is
designed to generate and execute autonomously generated code that may be
unstable or perform unexpected actions. USE THIS ONLY IN ISOLATED,
RESTRICTED ENVIRONMENTS. Never run this suite on a machine with access to
production systems, sensitive data, or internal networks. See the "Unattended
Cloud Deployment" section for mandatory hardening requirements.
[!IMPORTANT] RESPONSIBLE USE AI models are non-deterministic and can
hallucinate findings or generate incorrect patches. All findings must be
manually verified by a security expert before being reported. Do not
mass-file unverified, AI-generated reports to open-source maintainers. A
failure to automatically reproduce a vulnerability does not definitively mean
it is a false positive, nor does a successful reproducer guarantee the bug is
exploitable in all contexts. Use these skills responsibly.
Mantis Skills is a decoupled, sequential, and security-focused set of Skills
designed for use with Coding Agents. It is intended to be a **flexible
foundation and starting point** rather than a rigid set of instructions. You
should adapt, tune, and extend these skills to fit your organization's specific
software or hardware stack.
For example, while the default skills will look for generic security issues,
business logic problems, and authorization vulnerabilities, they can be adapted
for:
- Hardware / RTL Reviews: Auditing Register-Transfer Level (RTL) designs
(SystemVerilog, VHDL) for security properties or logical bugs.
- Infrastructure-as-Code (IaC): Analyzing cloud deployment boundaries,
Terraform state, or Kubernetes RBAC configurations for privilege escalation
paths.
- Data & ML Pipelines: Auditing training data ingress, model serialization
formats (e.g., Pickle vulnerabilities), or boundary constraints between data
science notebooks and production.
- Compiled Binaries & Firmware (Gray-Box Auditing): Pointing the suite at
compiled release artifacts (using tools like unblob, Ghidra, radare2,
qemu, or unicorn) without providing source code. The intent of this mode
is to emulate a third-party security researcher, allowing you to see exactly
what vulnerabilities are discoverable by adversaries who only have access to
your released binaries.
- Custom Test Environments: Replacing the default container reproduction
stage with isolated VMs, physical hardware testbeds (via USB/serial), or
custom simulators.
We strongly recommend using AI to iterate on these skills and using your
internal documentation, coding standards, and build systems to augment the
threat model. We also strongly recommend adapting risk calibration to your
environment and risk tolerance.
For more information on securing AI systems, see Google's
This suite enables anyone with an agentic coding tool to systematically review,
deduplicate, validate, criticize, reproduce, and patch codebases of any scale.
It also features a continuous learning loop that allows the suite to adapt
across iterative runs and avoid redundant analysis.
Above all, while orchestrated vulnerability discovery is incredibly powerful and
useful, it is even more important to use this in a suitably isolated environment
to prevent impacting production systems. See the notes on unattended cloud
deployment later in this guide.
Architecture and Sequential Flow
The pipeline is composed of sixteen distinct components (one supervisor and
fifteen execution stages), maintaining state across a directory of finding files
(workspace/findings/*.json). This entire process can be supervised
autonomously by the overarching /mantis_meta_agent.
graph TD
Meta["/mantis_meta_agent (Supervisor)"]
subgraph "Continuous Review Loop"
Hist["/mantis_history (Optional)"]
Sum["/mantis_summarize (Optional)"]
Arch["/mantis_architecture"]
TM["/mantis_threat_model"]
Plan["/mantis_plan"]
Res["/mantis_researcher"]
Ded["/mantis_dedupe"]
Rev["/mantis_review"]
Cri["/mantis_critic"]
Rep["/mantis_reproduce"]
Cha["/mantis_chain"]
Pat["/mantis_patch"]
Cal["/mantis_calibrate"]
Ref["/mantis_reflect"]
Rpt["/mantis_report"]
end
FileHist[("historical_learnings.jsonl")]
FileSum[("mantis_summary.md")]
FileKB[/"workspace/kb/ (Markdown KB)"/]
FilePlan[("plan.json")]
FileFind[("workspace/findings/*.json")]
FileLearn[("learnings.jsonl")]
FileRpt[/"workspace/report/review_packet.md"/]
Meta --> Hist
Hist --> Sum
Sum --> Arch
Arch --> TM
TM --> Plan
Plan --> Res
Res --> Ded
Ded --> Rev
Rev --> Cri
Cri --> Rep
Rep --> Cha
Cha --> Pat
Pat -.->|Re-attack Bypass Loop| Rep
Pat --> Cal
Cal --> Ref
Ref --> Rpt
Rpt -.->|Next Loop Iteration| Arch
Hist -.->|Generates| FileHist
Hist -.->|Reads| FileSum
Sum -.->|Reads| FileHist
Sum -.->|Generates| FileSum
Arch -.->|Reads| FileHist
Arch -.->|Generates| FileKB
Arch -.->|Reads/Clears| FileLearn
TM -.->|Reads/Updates| FileKB
Plan -.->|Reads| FileKB
Plan -.->|Reads| FileSum
Plan -.->|Generates| FilePlan
Res -.->|Reads| FilePlan
Res -.->|Reads| FileKB
Res -.->|Creates| FileFind
Ded -.->|Reads| FileLearn
Ded -.->|Merges| FileFind
Rev -.->|Updates| FileFind
Cri -.->|Updates| FileFind
Rep -.->|Updates| FileFind
Cha -.->|Reads| FileKB
Cha -.->|Creates| FileFind
Pat -.->|Updates| FileFind
Cal -.->|Updates| FileFind
Ref -.->|Parses Trajectories & Appends| FileLearn
Cri -.->|Appends| FileLearn
Pat -.->|Appends| FileLearn
Rpt -.->|Reads| FileFind
Rpt -.->|Generates| FileRpt
- /mantis_meta_agent (Supervisor): A persistent, overarching agent that
launches the continuous loop, monitors execution, handles errors, reports
findings, and archives the workspace/findings/ directory between loops.
- /mantis_history (History Extractor): An optional pre-processing step
that analyzes the repository's version control system (VCS) history to
extract past vulnerabilities, security fixes, and vulnerability patterns,
saving findings to historical_learnings.jsonl.
- /mantis_summarize (Summarizer): An optional pre-processing step that
generates a mantis_summary.md for each directory, reading past
vulnerabilities from historical_learnings.jsonl to enrich summaries and
provide a quick reference map to optimize downstream planning and research.
- /mantis_architecture (Knowledge Base Architect): Analyzes the codebase
and clears the learnings.jsonl inbox to synthesize a permanent,
interlinked Markdown Knowledge Base (workspace/kb/) detailing entities,
data flows, and historical vulnerability classes.
- /mantis_threat_model (Threat Modeler): Evaluates the entities and
architecture defined in the KB to establish or refine a living
workspace/kb/THREAT_MODEL.md, focusing on trust boundaries and attacker
profiles.
- /mantis_plan (Strategist): Scans workspace boundaries and reads the KB
indices to output a targeted review strategy into plan.json, injecting
specific kb_references file paths for context.
- /mantis_researcher (Mantis Researcher): Executes file-by-file triage
and deep security flaw reviews, outputting hotspots as individual JSON files
in workspace/findings/.
- /mantis_dedupe (Deduplicator): Groups index-based duplicate findings,
merging records and deleting redundancies within workspace/findings/.
- /mantis_review (Validator): Filters out false positives using strict
pragmatic constraints, updating the status in
workspace/findings/<id>.json.
- /mantis_critic (Critic): Verifies release-build crash reproducibility
(ignoring debug/assert checks), updates production viability in
workspace/findings/<id>.json, and appends false positives/non-viable paths
to learnings.jsonl.
- /mantis_reproduce (Proof-of-Concept Developer): Writes
Proof-of-Concept Reproduction Scripts (Repros) or raw payloads, executes
them in isolated environments such as gVisor or Virtual Machines, and
updates reproduction status in workspace/findings/<id>.json.
- /mantis_chain (Vulnerability Chainer): Analyzes individual validated
findings and knowledge base primitives to identify and construct complex
multi-step exploit chains, creating new "Super Findings" in
workspace/findings/.
- /mantis_patch (Patcher): Generates and applies code fixes, runs
post-patch validation tests inside the sandbox, updates patch status in
workspace/findings/<id>.json, and appends logs to learnings.jsonl.
- /mantis_calibrate (Risk Calibrator): Calculates a final numerical
Mantis Risk Score (1-10) for each finding in the workspace directory based
on impact, evidence, and viability, appending the results directly to each
workspace/findings/<id>.json file.
- /mantis_reflect (Reflector): Parses the execution trajectories of the
agents from the current round, extracting false assumptions, tool failures,
and successes, and appends these structured insights to the
learnings.jsonl inbox.
- /mantis_report (Reporter): Generates a human-readable security review
packet containing verified/reproduced findings, evidence, risk rationales,
and patch information at workspace/report/review_packet.md.
Prerequisites and Setup
Before executing any skills, ensure your local CLI environment is fully
configured:
- Gemini CLI or Antigravity CLI installed. (Others should also work).
- Docker Installed & Running (Required for local "sandboxed" execution).
- gVisor (runsc) Installed & Registered in Docker (Recommended): For
enhanced security when executing untrusted AI-generated crash reproducer
code, register the runsc runtime in your Docker daemon configuration
(/etc/docker/daemon.json):
{
"runtimes": {
"runsc": {
"path": "runsc"
}
}
}Restart Docker to apply: sudo systemctl restart docker.
- Relevant Cloud SDKs: If running remote cloud sandboxes instead of local
containers.
Installing the Skills
You can install these skills either globally (available across all projects) or
locally to a specific workspace. You can also ask your coding agent for help.
Beginner's Guide & Best Practices
If you are new to automated AI-assisted defensive security reviews, keep these
recommendations in mind:
1. "Interactive Mode" (Human-in-the-Loop)
- What it is: For users or organizations not yet ready to deploy fully
unattended, long-running pipelines, you should run the pipeline in an
"Interactive Mode".
- How to use it: Launch your CLI normally (e.g., type agy or gemini in
your terminal). Then, from inside the interactive chat UI, type the slash
commands (e.g., /mantis_plan) individually. Do not use --yolo or
--dangerously-skip-permissions flags when launching the CLI.
- Why it matters: The CLI will pause and prompt you for human approval
before executing any sensitive command (especially when the
/mantis_reproduce or /mantis_patch agents attempt to run Docker sandbox
executions or write to files). This allows you to inspect what the AI
intends to run. To run without human approval you will require stronger
boundaries to keep the agents contained.
2. Hardened Security & The "No Host-Run" Rule
- Why it matters: AI models can sometimes generate code payloads that
break the host. Run scripts only inside a sandbox if you aren't reading
them.
- Mantis Protection: The /mantis_reproduce and /mantis_patch skills
are explicitly instructed to execute payloads inside isolated container
environments with networking disabled (--network none, for example).
- Disclaimer: While these instructions are designed to maintain isolation,
AI agents are non-deterministic. They may occasionally attempt unsafe
actions or bypass intended constraints if the local environment allows it.
These instructions do NOT provide an absolute guarantee of safety. Always
prioritize running this suite in a dedicated, isolated VM (see GCE section
below) to provide a reasonable security boundary that the AI cannot escape.
3. Model Choice & Tiered Efficiency
To maximize the speed and efficiency of your automated pipeline, you should
strategically pair the right AI model class with the specific task. You do not
need to use the heaviest, most advanced frontier models for every stage:
- Tier 1 (Triage & Deduplication): For rapid classification sweeps (e.g.,
Wave 1 of /mantis_researcher) or clustering similar text patterns
(/mantis_dedupe), choose fast "flash" or "lite" tier models. These tasks
do not require immense logic depth, just rapid text parsing, allowing you to
parallelize massive file sweeps with zero bottleneck. Avoid models that are
so low-powered they struggle with basic instructions, but don't slow your
pipeline down by over-allocating intelligence here. Consider allowing the
planner to specify a difficulty level for a given research task to allow
targeting simpler questions at faster models, while allowing for some more
complex vulnerability discovery tasks to benefit from the most advanced
frontier models.
- Tier 2 (Deep Reasoning): Save your most powerful, heavy-reasoning
flagship models for the highly complex stages that demand deep context and
zero-shot problem solving: /mantis_reproduce (writing functional crash
reproducers) and /mantis_patch (writing side-effect-free codebase fixes).
- Tip: For very large repositories, configure your plan /mantis_plan to
focus on specific high-risk subfolders (e.g. src/crypto/ or api/) to
keep the scan focused and efficient.
Try different tiers of models in different parts of your pipeline to see what
works well and what does not.
4. Understanding False Positives (The "Negative Filter" Rule)
- What to expect: AI scanners can be overly enthusiastic. To address this,
the /mantis_review stage runs a strict validator applying 12 negative
rules. (The 12 are by no means set in stone but must be adapted, reframed,
or even split out into a different stage of their own if it suits your use
case.)
- Low/hardening risks are NOT false positives: Effective risk calibration
is critical as a first stage of triage of vulnerabilities. Take care when
tuning your pipeline to ensure the difference between a false positive and
something that is currently below the risk tolerance bar does not negatively
impact your ability to detect vulnerabilities.
- Pragmatism: AI-based vulnerability scanning, like SAST of old, can lead
to a frustrating number of false positives. Unlike SAST of old there are
ways to tune this without creating highly complex rules. Try things and see
what works and what doesn't, then adapt.
- Don't open the firehose all at once: As with the pragmatism
recommendation, it is far more efficient to run a small scan, triage a few
items, and use this to feed back into constructing your scanning pipeline.
Running a scan over everything and reporting all the potential
vulnerabilities might work, but in our experience is unlikely to be the most
successful way to adopt this new technology.
Running the Pipeline (Manual Mode)
You can execute the reviewing stages sequentially from inside your active
CLI terminal.
- Start your CLI from your terminal.
- Inside the interactive UI prompt, type the skills sequentially:
# 0. (Optional) Analyze repository's version control system (VCS) history and extract past vulnerabilities
/mantis_history
# 1. (Optional) Generate mantis_summary.md directory maps
/mantis_summarize
# 2. Synthesize codebase structure and historical learnings into the Markdown Knowledge Base
/mantis_architecture
# 3. Iteratively develop the project's living threat model based on the KB
/mantis_threat_model
# 4. Map target external boundary and build scanning roadmap, injecting KB references
/mantis_plan
# 5. Run multi-threaded/sequential security flaw sweep using injected context
/mantis_researcher
# 6. Consolidate overlapping files and duplicate bugs
/mantis_dedupe
# 7. Verify code validity & filter false positives
/mantis_review
# 8. Eliminate non-viable production issues
/mantis_critic
# 9. Generate proof-of-concept crash reproducers and run them in sandboxes
/mantis_reproduce
# 10. Combine validated individual findings into multi-step exploit chains
/mantis_chain
# 11. Apply minimal fixes and verify they block the crash reproducer
/mantis_patch
# 12. Calculate final matrix risk ratings and append to individual findings
/mantis_calibrate
# 13. Extract insights from execution trajectories and append to the learnings inbox
/mantis_reflect
# 14. (Manual Step) Move workspace/findings/ to an archive directory before starting the next loop
Building Deterministic Pipelines (Production-Grade)
While the /mantis_meta_agent provides dynamic steering for exploratory
security research, we highly recommend wrapping the Mantis Skills in a
deterministic programmatic pipeline (e.g., Python, Bash, Rust, or CI/CD
workflow) for use in enterprise or production settings.
By treating the individual skills (like /mantis_researcher, /mantis_review,
and /mantis_reproduce) as microservices that read and write JSON state in the
workspace/findings/ directory, you can build a rigid orchestrator that
provides absolute reliability and strict security guarantees. Better yet, you
should use more durable and resilient databases instead of json files on a
single machine.
**Before building your harness, strictly adhere to the inter-stage data
contracts defined in schema.json.** Of course, you can also
modify the schema based on what works for you. There are few hard rules here.
The Pipeline Adapter Skill (/mantis_pipeline_adapter)
To get started on brainstorming your custom pipeline for high reliability, token
efficiency (such as using UUID-based referencing), and adaptability to custom
environments (via MCP), see the
Note on Standalone vs. Harness Mode: When using Mantis Skills directly
from the CLI in standalone mode, skills like /mantis_review or
/mantis_patch will instruct the LLM to write temporary reusable Python
scripts to update the JSON state files. However, in a true programmatic
harness, your orchestrator should override these instructions and provide
native tool calls or functions for state management to avoid forcing the LLM
to write one-off scripts.
Why Build a Programmatic Harness?
- Determinism: Some stages such as the reproduction agent or patch agent
include recommendations to have subagents criticize the repro or patch.
While it is reasonable to demonstrate the overall workflow, a more
deterministic critic stage that the agent cannot bypass by "forgetting" to
call the critic subagent will likely produce better results.
- Mitigates Prompt Injection Risk: An LLM orchestrating shell commands is
susceptible to host-level prompt injection if it ingests malicious code.
Moving the orchestration to a hardened deterministic pipeline removes the
LLM's control over the host environment.
- Enforces Strict Sandboxing: Rather than relying on the LLM to remember
to use --network none when executing a crash reproducer, your
deterministic harness can programmatically enforce that untrusted
AI-generated payloads are executed exclusively within a locked-down VM,
container, or gVisor sandbox.
- CI/CD Integration: A deterministic script executing the static analysis
and deduplication stages is predictable and easily integrated into standard
automated workflows like GitHub Actions or Jenkins.
- Scale: The pipeline can be decomposed into several pieces, allowing you
to scale horizontally across a suitably sized fleet during periods of low
utilization.
- Deterministic Reporting: While the pipeline relies on machine-readable
JSON files (workspace/findings/*.json) to safely maintain internal state,
a programmatic harness can deterministically translate these JSON findings
into human-readable Markdown reports or automatically file them into
bug-tracking systems without risking LLM hallucination or state corruption.
Only use an LLM for deterministic subsets of this reporting process, such as
providing an executive summary if necessary.
The Hybrid Approach
To maintain the dynamic, adaptive nature of the suite while ensuring
deterministic execution, you can build a pipeline that:
- Iterates Programmatically: A harness loops over the workspace, invoking
the static and dynamic skills via the CLI.
- Feeds Learnings Back: The harness takes the resulting learnings.jsonl
file and invokes /mantis_plan to generate a newly updated plan.json,
effectively allowing the AI to guide the deterministic runner on what to
analyze next.
- Hardcodes the Execution Sandbox: You can optionally configure the
deterministic versions of /mantis_reproduce and /mantis_patch to only
generate the patch or script file, leaving the actual execution and grading
to your harness in a strictly controlled sandbox.
The Reality of Non-Determinism
A critical concept to understand when using AI for security research is
Non-Determinism.
- Coverage is not an absolute guarantee: Even though Stage 2
(/mantis_plan) attempts to use programmatic shell scripts to map your
entire codebase, the agent running those scripts is fundamentally
non-deterministic. It might occasionally fail to run the script correctly,
hallucinate parameters, or skip steps.
- Trajectory/Conversation analysis: One way to mitigate the lack of
determinism is to programmatically review all the tool calls made by the
agents to see what they've done. This can be used to calculate coverage and
efficiency metrics, although what those numbers mean exactly we will leave
to your imagination.
- Reasoning shifts across loops: Because the LLM's analysis is
non-deterministic, it may miss a subtle business logic flaw or authorization
bypass on Pass 1 but identify it clearly on Pass 5 as its internal
"attention" shifts or as it gains context from other findings. This is why
we generally recommend running this scanning pipeline many times.
- Diminishing Returns: You might expect the pipeline to eventually
"finish" and stop reporting bugs. In reality, the discovery of findings
often does not stop completely; rather, the quality and severity of the
findings will eventually degrade as the LLM starts hallucinating or reaching
for pedantic non-issues.
The continuous loop is designed to leverage this non-determinism allowing the AI
multiple passes to catch things it missed. However, **it is up to each user to
experiment with the suite, review the Risk Calibrator scores on the findings,
and determine for themselves when the quality of findings has dropped enough to
pause the loop.** In the long term you will also have to determine how often to
rescan, such as when new models with greater capabilities are made available or
when a codebase has received sufficiently large changes to warrant a complete
rescan instead of just an analysis of a given diff or changelist.
Advanced / Unattended Cloud Deployment (GCE)
Running the continuous review loop 24/7 in a fully autonomous, unattended state
presents unique security risks, particularly host-level prompt injection.
Beyond this, agents might simply make mistakes and perform actions you did not
intend.
**As a result, deploying to a hardened VM such as an isolated Google Compute
Engine (GCE) instance is a STRICT REQUIREMENT for unattended mode.**
(Alternatively you can build a more structured deterministic pipeline where
individual risky actions are sandboxed, although this will require more up front
effort).
1. Hardened GCE Environment
To provide a security boundary that an AI agent cannot easily escape, you MUST
configure your environment as follows:
- Network Isolation: Provision the GCE VM with no external internet
access, or at least use a secure web proxy with a trusted allowlist and
good rate limiting and egress controls.
- VPC Service Controls (VPC-SC): Place the VM inside a VPC-SC perimeter.
This is an important defense against data exfiltration if an agent is
compromised.
- Least-Privilege Service Account: Attach a dedicated IAM Service Account
to the VM with strictly limited roles. Do not use broad roles like
roles/aiplatform.user or roles/storage.objectAdmin. Instead:
Custom AI Role: Create a custom IAM role that only grants
aiplatform.endpoints.predict and
aiplatform.endpoints.generateContent. This restricts the agent to only
query models and prevents modifying AI infrastructure.
- Append-Only GCS Storage: To store intermediate results or backups,
grant the service account roles/storage.objectCreator and
roles/storage.objectViewer to a specific GCS bucket. Crucially, do
not grant delete permissions (storage.objects.delete). Also consider
other append-only storage mechanisms.
- GCS Versioning: Enable Object Versioning on the GCS bucket. This
provides a mechanism so that even if the AI or an untrusted crash
reproducer payload overwrites a file (like learnings.jsonl), previous
states are preserved as non-current versions, preventing the AI from
permanently deleting the history.
2. Bypassing Interactive Prompts (Unattended Mode)
Warning: Only use these flags if the Hardened GCE Environment (above) is
fully implemented. By default, the CLI tools require manual confirmation before
executing system commands. To run the pipeline entirely unattended, you must
pass the appropriate auto-approve flag when starting the CLI, such as
--dangerously-skip-permissions or --yolo.
3. Automated Security Flaw Alerting (Cloud Pub/Sub)
When running unattended, you might desire an isolated way to be notified when
the pipeline discovers a high-confidence security flaw. There are numerous ways
to do this, including connecting the pipeline to Google Cloud Pub/Sub.
- Setup: Create a Pub/Sub topic (e.g., mantis-verified-vulns) and grant
your GCE VM's Service Account the roles/pubsub.publisher role.
- Hooking it up: The /mantis_meta_agent skill can be instructed to
trigger notifications natively. You can instruct the meta-agent to run
gcloud pubsub topics publish mantis-verified-vulns --message="$(cat workspace/findings/<id>.json)" whenever a security flaw is successfully
reproduced.
- Routing: Subscribe a Google Cloud Function or Cloud Run service to that
Pub/Sub topic to route the alert payload directly into your team's chat,
issue tracker, or paging system. This cleanly decouples the isolated
scanning environment from your internal alerting infrastructure.
Meta-Agent Orchestration Pattern
For a truly autonomous and persistent security operation, you can employ the
Meta-Agent Orchestration pattern by invoking the /mantis_meta_agent skill.
In this setup, a high-level "Meta-Agent" (a long-lived Gemini or Antigravity CLI
session) is responsible for driving the entire reviewing pipeline.
The Meta-Agent's Role:
- Orchestration: The Meta-Agent manages the execution of each stage
natively using CLI subagent delegation.
- Persistence: It operates in a single, long-lived conversation that spans
days or weeks, ensuring that the review continues working towards the goal
of security flaw discovery, patching, and reporting even while you are in
meetings, away for the evening, or over the weekend.
- Supervision: It keeps an eye on the task, handles minor environmental
hiccups, reads logs, and ensures the pipeline remains operational.
- Interactive Steering: A major advantage of this pattern is that you can
chat with the Meta-Agent while subagents are working. You can ask for status
updates, collaboratively debug environment issues, or provide high-level
strategic guidance (e.g., "Deep dive on the image parser") to influence the
swarm's focus in real-time or in the next loop.
- Security Boundaries: While you can run the Meta-Agent with auto-approve
flags (--dangerously-skip-permissions), you must strictly confine it
within the hardened security boundaries previously described (VPC-SC, no
external internet, and restricted IAM roles).
This pattern transforms the suite from a set of disjointed tools into a
continuous, self-driving security research operation.
Evaluating and Optimizing Mantis Skills
Evaluating an autonomous, multi-agent pipeline like Mantis is notoriously
difficult. Running full end-to-end evaluations for every prompt tweak is
cost-prohibitive in both time and API tokens. To safely modify these skills or
optimize model costs, you should adopt a Tiered Evaluation Strategy and
measure proxy metrics rather than just binary success.
The Tiered Evaluation Strategy
Do not evaluate the entire loop unless necessary. Split your evaluations into
three tiers:
- Tier 1: Static Checks
What it is: Fast, programmatic linting of the skill files.
- What to measure: Do the SKILL.md files parse? Are the YAML
frontmatters correct? Do they define the required tools? Are the system
prompts within the context window limits?
- Tier 2: Isolated "Unit" Evals
What it is: Evaluating a single skill (e.g., /mantis_patch) in a
vacuum, entirely decoupled from the rest of the pipeline.
- The Setup: Feed a static, hardcoded input (a mocked findings.json
and a target file) to a single skill and observe its output.
- What to measure:
Format: Did it output the expected JSON schema or valid diff?
- Tool Use: Did it attempt to call the correct tools
(run_command vs view_file)?
- LLM-as-a-Judge: Use a cheaper, faster model to grade the
qualitative output with a strict rubric (e.g., "Did the patch
address the SQL injection? Yes/No.").
- Tier 3: The "Golden Dataset" End-to-End Eval
What it is: A full run of the entire pipeline. Only run this when
doing a major release or swapping base model classes (e.g., upgrading to
a newer flagship model).
- The Setup: Curate a tiny dataset of 3-5 real-world, representative
vulnerable repositories.
- What to measure: Binary outcomes. Did the final test suite pass? Did
/mantis_reproduce generate a working PoC? You could also perform human
evaluation to see if there were novel vulnerabilities discovered.
Measuring the "Unmeasurable"
When evaluating intermediate stages (like /mantis_researcher), binary success
is difficult to define. Instead, track these proxy metrics to gauge skill
degradation:
- Tool Error Rate: Count how many times the agent's tool calls fail (e.g.,
bad bash syntax, invalid file paths). A spike in tool errors after a prompt
change indicates the skill's instruction set has degraded or that the
prompts might need to be adapted to a new model or coding agent harness.
- Trajectory Efficiency (Turns/Tokens): If /mantis_reproduce used to
write a PoC in 5 turns, and after a prompt tweak it takes 150 turns or loops
repeatedly, that is a measurable regression in efficiency.
- The "Give Up" Rate: How often does the agent explicitly output phrases
like "I cannot determine", "I am stuck", or enter an infinite loop before
hitting a token limit?
The "Shadow Eval" Method
Do not build a massive evaluation harness on day one. Instead, build your
dataset organically:
- When running the pipeline manually, wait for the agents to fail at a
specific task.
- Save that exact starting state (the user prompt, the workspace files, the
JSON state).
- Fix the skill prompts until the agent succeeds.
- Turn that specific, isolated state into your first automated test.
By building your eval dataset exclusively from real-world failures, you ensure
you are only spending tokens testing regressions that actually matter.
Optimizing Parallelism and Model Selection
When tweaking the pipeline or introducing features like Parallel Trajectory
Search, you should run experiments to ensure you are getting a return on your
token investment:
- Try Different Models: For any given stage, experiment with swapping the
flagship model for a cheaper, faster model or a specialized coding model.
Use the Tier 2 "Unit" Evals to verify if the cheaper model degrades the
success rate before rolling it out.
- Evaluate Parallel Trajectories: If you implement parallel trajectory
search (e.g., spawning multiple Researchers or Patchers), test different
numbers of concurrent agents (e.g., 2, 3, or 5). If running parallel
researchers always results in them finding the exact same vulnerabilities,
then the parallelization is not yielding unique value and is just burning
tokens. Conversely, if parallel patchers consistently produce a much
cleaner, more idiomatic fix than a single agent, the compute cost can be
justified.
Roadmap / Future Work
- Skill Self-Improvement (Meta-Learning): The current learnings.jsonl
and Knowledge Base (KB) architecture tracks codebase-specific empirical
outcomes to adapt the THREAT_MODEL.md and context pointers. Future
iterations of the pipeline could take this a step further and use this
historical data to reflect on and automatically rewrite its own SKILL.md
prompts. For example, if a certain type of hallucination is repeatedly
caught by the Critic, a self-improvement meta-agent could update the
Researcher's SKILL.md instructions to explicitly filter out that specific
pattern before it even reaches the Review stage. Security Note:
Committing automated changes to SKILL.md files must always be human-gated
to prevent an attacker from using prompt injection (e.g., via a malicious
payload in a target file) to trick the meta-agent into ignoring a
vulnerability class globally.
- Software Dark Factory: Integrate this pipeline into an entirely AI
driven software development. Instead of vulnerable discovery for action by
humans, Mantis would become the autonomous vulnerability research and
release gating component of the dark factory. Before the dark factory can
push to production, it must have had N hours of adversarial vulnerability
research or "red teaming" by a pipeline like Mantis.
Troubleshooting Guide
1. Loop Iterations are Re-Evaluating the Same Code
- Symptom: The loop keeps reviewing the same files and reporting identical
bugs.
- Solution: Ensure /mantis_architecture completes successfully and
writes its synthesized knowledge to the workspace/kb/ directory. The
/mantis_plan strategist checks this Knowledge Base to dynamically skip
already analyzed areas. Check that file permissions allow writing to
workspace/kb/.
2. Other Issues
- Symptom: Something isn't working.
- Solution: Ask an AI coding tool to review your pipeline and the
conversations or trajectories that are leading to the unexpected behavior.
They will often give you useful insights.
This is not an officially supported Google product. This project is not eligible
for the
Google Open Source Software Vulnerability Rewards Program.
This project is intended for demonstration purposes only. It is not intended for
use in a production environment.
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み