AIエージェントでコードの脆弱性を低成本で見つける方法
Vercel Labsのdeepsecを最近見つけました。開発者がAIエージェントを使ってコードベースの深いセキュリティスキャンを行うというアイデアに惹かれました。従来の静的解析ツール(SAST)のように誤検知を大量に出すのではなく、「スマート」な検索を活用しています。
従来のツールの問題点は、パターンは検出するがコンテキストを見落とすことです。Deepsecはそれを改善しようとしています。
このツールの概要
Essentially, it's a wrapper for managing scans. The system doesn’t just hunt for dangerous code snippets using regex patterns—it feeds suspicious areas to language models for analysis. The creators honestly warn that scanning a large repository at full intensity could get pricey. The README mentions costs in the thousands, even tens of thousands of dollars.
These numbers are intimidating, but Vercel's reasoning is straightforward: a single missed critical bug in production could cost the business far more.
プロセスの仕組み
The tool operates in stages. First, a quick pass runs without neural networks—command scan simply identifies potentially problematic areas using matchers. This phase costs nothing.
The real magic happens with command process. That's when agents take over. They take the first stage's findings and start unraveling them. The agent determines whether there's actually a vulnerability or if it's a false alarm. For massive projects, execution can be distributed across workers.
気に入った機能
Deepsec has several architectural decisions that reveal experienced engineers behind it.
First, the system can resume from where it left off. If your internet drops or you run out of funds in your OpenAI/Anthropic API balance, you don’t need to start over. State is saved locally in folder .deepsec.
Second, there's a revalidation mechanism. Command revalidate checks the Git history: if you've already fixed a vulnerability, the tool will notice and won’t flag it again.
Third, there's contextual awareness. Rather than feeding the entire repository to the model (which would be prohibitively expensive and inefficient), deepsec asks you to prepare a condensed project brief—file INFO.md. You describe the specifics: how authorization works, what middleware is used, where configs are located. This helps the agent avoid asking obvious questions and reduces errors.
ローカルでの実行方法
To get started, a standard npx is sufficient:
次に、アクセス鍵を設定します。チーム的にはVercel AI Gatewayの使用を推奨していますが、直接AnthropicやOpenAIのトークンを渡すこともできます。重要なのは制限を意識することです。標準のClaude Proサブスクリプションではフルスキャンは賄えないため、APIアクセスの予算を最初から確保しておきましょう。
特定のPull Requestの変更のみをチェックする場合は便利なフラグがあります:
This saves significant time and money since only the modified files are analyzed.
技術的な側面とセキュリティ
值得注意的是,deepsec本身具有shell访问权限。您运行的代码控制着具有命令执行权限的代理。为了避免项目依赖中的恶意代码,提供了Vercel Sandbox模式。在这种情况下,工作在隔离的微虚拟机中进行,您的API密钥保留在外部,无法被窃取。
こんな人におすすめ
小さなペットプロジェクトにはdeepsecはオーバースペックです。しかし、大規模なレガシーコードベースを持つエンタープライズ環境で、セキュリティがトークンの節約より重要であれば、試す価値があります。特に、認証のロジック欠陥や従来のリンターでは決して検出されない複雑な脆弱性チェーンの発見に優れています。
すべてのCI/CDパイプラインに急着で導入すべきか?おそらく答えはNoです。しかし、定期的な深いコードベース監査のためのツールとしては、2024年のAppSec还是非常明智なアプローチです。
関連プロジェクト