この記事の内容
実際に
Factory AIと Snyk Studioで 検出された 脆弱性に パッチを 適用
Factory AIのDroidsで
![「FACTORY」という見出し、エージェントネイティブなソフトウェア開発の説明、「[ enter to continue ]」というプロンプトが表示されたFactoryのランディング画面。](https://res.cloudinary.com/snyk/image/upload/v1761144127/Droid_GIF_goxlos.gif)
開発者向けの
Factory CLIを
ダウンロードする Droid IDE Extensionを
VS Code、 または お好みの 派生版 (Cursorや WindSurfなど)に 追加する ブラウザーまたは
IDEで、 Droid (Factory AIの 専用AIエージェント)に 最初の タスクを 与える
Linuxを
curl -fsSL https://app.factory.ai/cli | shVS Code用のRun Factory Droidを

Droidとは?
Factory AIは、
Code Droid: アイデアを
マージ可能な コード変更へ。明確な 要件に 基づいて、 新しい 機能や コンポーネントを 作成します。 Code Droidは コードベースを 理解し、 プロジェクトの パターンや ベストプラクティスに 沿って 機能を 実装できます。 複雑または 非効率な パターンを 見つけ、 機能を 維持しながら、 より クリーンで 保守しやすい コードに 変換して 既存コードを 改善します。 エラーログを 分析して 根本原因を 特定し、 コードベースの バグを 修正します。 包括的な 単体テストを 作成し、 コードの 信頼性を 高め、 アプリケーションでの デグレードを 防ぎます。 Knowledge Droid: エンジニアリング調査、
技術文書、 オンボーディングガイドを 作成。APIリファレンス、 アーキテクチャの 概要、 コンポーネント間の 関係など、 コードベースの 包括的な ドキュメントを 生成して、 チームの 理解と オンボーディングを 促進します。 プロジェクト内の 複雑な システム、 アーキテクチャ上の 判断、 実装の 詳細を わかりやすく 説明し、 各コンポーネントの 連携に ついて チームメンバーが 理解できるよう 支援します。 コードベースや ドキュメントから 必要な 情報を すばやく 検索・抽出できる ため、 実装の 詳細を 探したり、 特定の 機能を 理解したりする 時間を 短縮できます。 Reliability Droid: インシデントを
調査し、 根本原因分析 (RCA)を 作成し、 複雑な マルチサービスシステムを デバッグ。エラーログ、 メトリクス、 システムの 挙動を 調べて 本番環境の インシデントを 分析し、 障害や パフォーマンス低下の パターンと 原因の 可能性を すばやく 特定します。 タイムライン、 影響評価、 根本原因の 特定、 予防策を 含む 包括的な 根本原因分析 (RCA) ドキュメントを 作成し、 関係者と 共有できます。 サーキットブレーカー、 リトライロジック、 グレースフルデグラデーションなどの 堅牢な エラー処理を 実装し、 システムの レジリエンスを 高めて 連鎖障害を 防ぎます。 Product Droid: 機能を
計画し、 PRDを 作成し、 プロジェクトを 管理。新製品機能に ついて、 概要、 ユーザーストーリー、 受け入れ基準、 技術的な 考慮事項、 実装フェーズを 含む 詳細な 製品要件ドキュメント (PRD)を 生成します。 さまざまな ユーザータイプや シナリオに 応じた、 詳細な 受け入れ基準付きの 包括的な ユーザーストーリーを 作成し、 開発チームが ユーザー視点で 機能要件を 理解できるようにします。 機能リクエストを 分析し、 影響度と 工数の 評価に 基づく優先順位付けの 枠組みを 構築して、 プロダクトチームの 実装順序の 判断を 支援します。
あらかじめ構築された
うれしい

MCPのサポート
他の

たとえば、公式Snyk MCP Serverは
droid mcp add --type stdio SNYK "snyk mcp -t stdio"
Added stdio MCP server SNYK with command: snyk mcp -t stdioでは、
AIエージェント(Droids)を使って脆弱性に自動でパッチを適用する
このadeyosemanputra’sに

Droidに
> Please run a code scan on the codebase with Snyk.
⛬ I'll help you run a Snyk code scan on the pygoat codebase. Let me first check the
authentication status and then perform the scan.
PLAN Updated: 3 total (2 pending, 1 in progress, 0 completed)
○ Check Snyk authentication status
○ Run Snyk code scan on pygoat codebase
○ Review and report scan results
[MCP] SNYK:SNYK_AUTH_STATUS
↳stephen.thoemmes
⛬ Great! You're authenticated as stephen.thoemmes. Now I'll run the Snyk code scan on
the pygoat codebase to identify security vulnerabilities.
PLAN Updated: 3 total (1 pending, 1 in progress, 1 completed)
○ Check Snyk authentication status
○ Run Snyk code scan on pygoat codebase
○ Review and report scan results
[MCP] SNYK:SNYK_CODE_SCAN (/home/owler/Documents/Snyk/factory/pygoat)
↳
Testing /home/owler/Documents/Snyk/factory/pygoat ...
✗ [Low] Use of Hardcoded Credentials
Path: introduction/playground/A9/api.py, line 17
Info: Do not hardcode credentials in code. Found hardcoded credential used in a
condition.
…
✗ [High] SQL Injection
Path: introduction/views.py, line 871
Info: Unsanitized input from an HTTP parameter flows into
introduction.models.sql_lab_table.objects.raw, where it is used in an SQL query. This
may result in an SQL Injection vulnerability.
…
✔ Test completed
Organization: stephen.thoemmes
Test type: Static code analysis
Project path: /home/owler/Documents/Snyk/factory/pygoat
Summary:
101 Code issues found
15 [High] 44 [Medium] 42 [Low]
PLAN Updated: 3 total (0 pending, 0 in progress, 3 completed)
○ Check Snyk authentication status
○ Run Snyk code scan on pygoat codebase
○ Review and report scan results
⛬ The Snyk code scan has completed successfully! Here's a summary of the security
findings:
Scan Results Summary
Total Issues Found: 101
• 15 High severity vulnerabilities
• 44 Medium severity vulnerabilities
• 42 Low severity vulnerabilities
Key High-Severity Issues Found:
1. SQL Injection - Multiple instances in views.py
2. Code Injection - eval() usage with unsanitized input
3. Command Injection - subprocess.Popen with unsanitized input
4. Path Traversal - File operations with unsanitized paths
5. XML External Entity (XXE) Injection - Insecure XML parsing
6. Deserialization vulnerabilities - pickle.loads and yaml.load with untrusted data
7. Hardcoded cryptographic keys - JWT keys hardcoded in source
8. Hardcoded secrets - Non-cryptographic secrets in code
Medium/Low Severity Issues:
• Hardcoded passwords and credentials
• CSRF protection disabled on multiple endpoints
• Insecure cookie configurations (missing HttpOnly/Secure flags)
• Weak hashing algorithms (MD5)
• Debug mode enabled in production
• SSRF vulnerabilities
This is a comprehensive security assessment showing that pygoat (being a
deliberately vulnerable application for educational purposes) contains numerous
intentional security flaws across all severity levels, making it an excellent
training platform for learning about web application security vulnerabilities.最後に、
> ✗ [High] SQL Injection
Path: introduction/views.py, line 871
Info: Unsanitized input from an HTTP parameter flows into
introduction.models.sql_lab_table.objects.raw, where it is used in an SQL query.
This
may result in an SQL Injection vulnerability. Can you fix this vulnerability and
then re-scan to show that it is fixed?
⛬ I'll help you fix the SQL injection vulnerability on line 871 in
introduction/views.py and then re-scan to verify the fix. Let me first examine the
vulnerable code.
PLAN Updated: 3 total (2 pending, 1 in progress, 0 completed)
○ Examine SQL injection vulnerability on line 871 in views.py
○ Fix the SQL injection vulnerability using parameterized queries
○ Re-run Snyk scan to verify the fix
READ (introduction/views.py, offset: 860, limit: 20)
↳ Read 22 lines.
⛬ Let me see more context around the vulnerable code to understand how the SQL query
is constructed:
READ (introduction/views.py, offset: 840, limit: 40)
↳ Read 42 lines.
⛬ Now I can see the vulnerability clearly. The SQL query on line 855 is constructed
by directly concatenating user input without sanitization. Let me also check the
imports to see what model is being used:
GREP ("from.*models import|import.*mo...", content mode)
↳ Read 1 line.
GREP ("sql_lab_table", content mode)
↳ Read 7 lines.
⛬ Perfect! Now I understand the vulnerability. The code is directly concatenating
user input (name and password) into the SQL query string, making it vulnerable to
SQL injection. Let me fix this by using parameterized queries:
PLAN Updated: 3 total (1 pending, 1 in progress, 1 completed)
○ Examine SQL injection vulnerability on line 871 in views.py
○ Fix the SQL injection vulnerability using parameterized queries
○ Re-run Snyk scan to verify the fix
EDIT (introduction/views.py)
↳ Succeeded. File edited. (+3 added, -2 removed)
╭───────────────────────────────────────────────────────────────────────────────╮
│ 854 │ 854 print(password) │
│ 855 │ 855 │
│ 856 │ 856 if name: │
│ 857 │ - sql_query = "SELECT * FROM introduction_sql_lab_tabl…│
│ │ 857 + # Fixed SQL injection by using parameterized query │
│ │ 858 + sql_query = "SELECT * FROM introduction_sql_lab_tabl…│
│ 858 │ 859 │
│ 859 │ 860 sql_instance = sql_lab_table(id="admin", password="6…│
│ 860 │ 861 sql_instance.save() │
│ │
│... 7 unchanged lines ... │
│ │
│ 868 │ 869 print(sql_query) │
│ 869 │ 870 │
│ 870 │ 871 try: │
│ 871 │ - user = sql_lab_table.objects.raw(sql_query) │
│ │ 872 + user = sql_lab_table.objects.raw(sql_query, [nam…│
│ 872 │ 873 user = user[0].id │
│ 873 │ 874 print(user) │
│ 874 │ 875 │
╰───────────────────────────────────────────────────────────────────────────────╯
⛬ Great! I've successfully fixed the SQL injection vulnerability by:
1. Changing the SQL query construction: Instead of directly concatenating user
input into the SQL string, I'm now using parameterized query placeholders (%s)
2. Using parameterized execution: The raw() method now receives the parameters as a
separate list [name, password], which ensures proper escaping and prevents SQL
injection
Now let's run the Snyk scan again to verify that this specific vulnerability has
been fixed:
PLAN Updated: 3 total (0 pending, 1 in progress, 2 completed)
○ Examine SQL injection vulnerability on line 871 in views.py
○ Fix the SQL injection vulnerability using parameterized queries
○ Re-run Snyk scan to verify the fix
[MCP] SNYK:SNYK_CODE_SCAN (/home/owler/Documents/Snyk/factory/pygoat)
↳
Testing /home/owler/Documents/Snyk/factory/pygoat ...
✗ [Low] Use of Hardcoded Credentials
Path: introduction/playground/A9/api.py, line 17
Info: Do not hardcode credentials in code. Found hardcoded credential used in a
condition.
…
✗ [High] Hardcoded Non-Cryptographic Secret
Path: pygoat/settings.py, line 25
Info: Avoid hardcoding values that are meant to be secret. Found a hardcoded string
used in here.
✔ Test completed
Organization: stephen.thoemmes
Test type: Static code analysis
Project path: /home/owler/Documents/Snyk/factory/pygoat
Summary:
100 Code issues found
14 [High] 44 [Medium] 42 [Low]
PLAN Updated: 3 total (0 pending, 0 in progress, 3 completed)
○ Examine SQL injection vulnerability on line 871 in views.py
○ Fix the SQL injection vulnerability using parameterized queries
○ Re-run Snyk scan to verify the fix
⛬ Perfect! The fix has been successfully verified. Here's what happened:
✅ SQL Injection Vulnerability Fixed!
Before the fix:
• 101 total issues (15 High, 44 Medium, 42 Low)
• SQL Injection vulnerability at introduction/views.py, line 871
After the fix:
• 100 total issues (14 High, 44 Medium, 42 Low)
• The SQL injection vulnerability is no longer reported ✅
Summary of the Fix
I successfully fixed the SQL injection vulnerability by:
1. Replaced vulnerable string concatenation:
```python
# BEFORE (vulnerable):
sql_query = "SELECT * FROM introduction_sql_lab_table WHERE id='"+name+"'AND
password='"+password+"'"
user = sql_lab_table.objects.raw(sql_query)
```
2. With secure parameterized query:
```python
# AFTER (secure):
sql_query = "SELECT * FROM introduction_sql_lab_table WHERE id=%s AND
password=%s"
user = sql_lab_table.objects.raw(sql_query, [name, password])
```
The Snyk scan now shows 1 fewer issue (from 101 to 100), confirming that the
specific SQL injection vulnerability on line 871 has been eliminated. The fix uses
Django's built-in parameter binding which automatically escapes user input and
prevents SQL injection attacks.
これは、DevSecOpsワークフローに
Factory AIとSnyk Studioで次のステップへ
MCPの
同様の
MCP Serverエコシステムの