claude-mpm 2.1.0__py3-none-any.whl → 3.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- claude_mpm/_version.py +2 -2
- claude_mpm/agents/agent_loader.py +682 -102
- claude_mpm/agents/base_agent_loader.py +23 -8
- claude_mpm/agents/schema/agent_schema.json +237 -83
- claude_mpm/agents/templates/data_engineer.json +6 -3
- claude_mpm/agents/templates/documentation.json +6 -3
- claude_mpm/agents/templates/engineer.json +7 -4
- claude_mpm/agents/templates/ops.json +6 -3
- claude_mpm/agents/templates/qa.json +10 -5
- claude_mpm/agents/templates/research.json +31 -42
- claude_mpm/agents/templates/security.json +14 -6
- claude_mpm/agents/templates/version_control.json +9 -5
- claude_mpm/core/base_service.py +61 -1
- claude_mpm/hooks/claude_hooks/hook_handler.py +224 -20
- claude_mpm/schemas/README_SECURITY.md +92 -0
- claude_mpm/schemas/agent_schema.json +130 -51
- claude_mpm/schemas/agent_schema_security_notes.md +165 -0
- claude_mpm/services/agent_capabilities_generator.py +0 -1
- claude_mpm/services/agent_deployment.py +479 -91
- claude_mpm/services/agent_lifecycle_manager.py +62 -4
- claude_mpm/services/deployed_agent_discovery.py +6 -2
- claude_mpm/services/version_control/semantic_versioning.py +165 -16
- claude_mpm/validation/agent_validator.py +147 -13
- {claude_mpm-2.1.0.dist-info → claude_mpm-3.0.0.dist-info}/METADATA +4 -2
- {claude_mpm-2.1.0.dist-info → claude_mpm-3.0.0.dist-info}/RECORD +29 -28
- claude_mpm-3.0.0.dist-info/licenses/LICENSE +21 -0
- claude_mpm/cli_old/__init__.py +0 -1
- claude_mpm/cli_old/ticket_cli.py +0 -102
- {claude_mpm-2.1.0.dist-info → claude_mpm-3.0.0.dist-info}/WHEEL +0 -0
- {claude_mpm-2.1.0.dist-info → claude_mpm-3.0.0.dist-info}/entry_points.txt +0 -0
- {claude_mpm-2.1.0.dist-info → claude_mpm-3.0.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Agent Schema Security Guide
|
|
2
|
+
|
|
3
|
+
## Critical Security Notice
|
|
4
|
+
|
|
5
|
+
**This schema is a SECURITY BOUNDARY.** Any changes to agent_schema.json must be carefully reviewed for security implications.
|
|
6
|
+
|
|
7
|
+
## Security Controls in agent_schema.json
|
|
8
|
+
|
|
9
|
+
### 1. Field Validation
|
|
10
|
+
- **agent_id**: Pattern `^[a-z][a-z0-9_]*$` prevents path traversal and command injection
|
|
11
|
+
- **version fields**: Semantic versioning pattern prevents version injection
|
|
12
|
+
- **enums**: All enums are allowlists preventing arbitrary values
|
|
13
|
+
|
|
14
|
+
### 2. Size Limits
|
|
15
|
+
- **instructions**: 8000 char max prevents memory exhaustion
|
|
16
|
+
- **name**: 50 char max prevents UI breaking
|
|
17
|
+
- **description**: 200 char max prevents storage abuse
|
|
18
|
+
- **tags**: max 10 items prevents array bombing
|
|
19
|
+
|
|
20
|
+
### 3. Resource Limits by Tier
|
|
21
|
+
```
|
|
22
|
+
intensive: memory: 4096-8192MB, cpu: 60-100%, timeout: 600-3600s
|
|
23
|
+
standard: memory: 2048-4096MB, cpu: 30-60%, timeout: 300-1200s
|
|
24
|
+
lightweight: memory: 512-2048MB, cpu: 10-30%, timeout: 30-600s
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 4. Tool Security Matrix
|
|
28
|
+
|
|
29
|
+
| Tool Combination | Risk Level | Security Impact |
|
|
30
|
+
|-----------------|------------|-----------------|
|
|
31
|
+
| Bash + Write | CRITICAL | Arbitrary code execution |
|
|
32
|
+
| docker + kubectl | HIGH | Container escape potential |
|
|
33
|
+
| aws + gcloud + azure | HIGH | Multi-cloud attack surface |
|
|
34
|
+
| WebFetch + Write | MEDIUM | Data exfiltration risk |
|
|
35
|
+
| Read + network_access | MEDIUM | Information disclosure |
|
|
36
|
+
|
|
37
|
+
### 5. Required Security Reviews
|
|
38
|
+
|
|
39
|
+
Any PR modifying agent_schema.json MUST include:
|
|
40
|
+
1. Security impact assessment
|
|
41
|
+
2. Validation that no new fields bypass security controls
|
|
42
|
+
3. Test cases for new validation rules
|
|
43
|
+
4. Update to this security guide if needed
|
|
44
|
+
|
|
45
|
+
### 6. Security Checklist for Schema Changes
|
|
46
|
+
|
|
47
|
+
- [ ] No new fields allow arbitrary string input without validation
|
|
48
|
+
- [ ] All new arrays have maxItems limits
|
|
49
|
+
- [ ] All new strings have maxLength limits
|
|
50
|
+
- [ ] New enum values are reviewed for security impact
|
|
51
|
+
- [ ] Resource limits maintain tier boundaries
|
|
52
|
+
- [ ] No new fields can bypass additionalProperties: false
|
|
53
|
+
- [ ] Pattern validations prevent injection attacks
|
|
54
|
+
- [ ] Default values follow principle of least privilege
|
|
55
|
+
|
|
56
|
+
## Common Security Mistakes to Avoid
|
|
57
|
+
|
|
58
|
+
1. **Never** add fields that accept arbitrary file paths without validation
|
|
59
|
+
2. **Never** increase resource limits without security review
|
|
60
|
+
3. **Never** add tools that bypass the enum list
|
|
61
|
+
4. **Never** remove pattern validation from ID fields
|
|
62
|
+
5. **Never** set additionalProperties to true
|
|
63
|
+
6. **Always** default network_access to false
|
|
64
|
+
7. **Always** validate new tool combinations for security impact
|
|
65
|
+
|
|
66
|
+
## Security Testing
|
|
67
|
+
|
|
68
|
+
Run these tests after any schema change:
|
|
69
|
+
```bash
|
|
70
|
+
# Validate schema structure
|
|
71
|
+
python scripts/validate_agent_schema.py
|
|
72
|
+
|
|
73
|
+
# Test security boundaries
|
|
74
|
+
python tests/test_agent_security_boundaries.py
|
|
75
|
+
|
|
76
|
+
# Check for injection vulnerabilities
|
|
77
|
+
python tests/test_agent_validation_security.py
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Incident Response
|
|
81
|
+
|
|
82
|
+
If a security vulnerability is found in the schema:
|
|
83
|
+
1. Immediately add validation in agent_validator.py as a hotfix
|
|
84
|
+
2. Update schema to prevent the vulnerability
|
|
85
|
+
3. Audit all existing agents for exploitation
|
|
86
|
+
4. Document the vulnerability and fix in security log
|
|
87
|
+
|
|
88
|
+
## Security Contacts
|
|
89
|
+
|
|
90
|
+
- Security reviews: security-team@company.com
|
|
91
|
+
- Vulnerability reports: security@company.com
|
|
92
|
+
- Emergency response: security-oncall@company.com
|
|
@@ -1,37 +1,71 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"version": "1.2.0",
|
|
3
4
|
"title": "Claude MPM Agent Schema",
|
|
4
|
-
"description": "Schema definition for Claude MPM agent templates",
|
|
5
|
+
"description": "Schema definition for Claude MPM agent templates. This schema enforces the structure and validation rules for all agent configurations in the Claude MPM system.",
|
|
5
6
|
"type": "object",
|
|
6
|
-
"required": [
|
|
7
|
+
"required": [
|
|
8
|
+
"schema_version", // Required: Must match the schema version this agent was built for
|
|
9
|
+
"agent_id", // Required: Unique identifier for the agent type
|
|
10
|
+
"agent_version", // Required: Semantic version of this specific agent template
|
|
11
|
+
"agent_type", // Required: Categorizes the agent's primary function
|
|
12
|
+
"metadata", // Required: Human-readable information about the agent
|
|
13
|
+
"capabilities", // Required: Technical specifications and resource requirements
|
|
14
|
+
"instructions" // Required: System prompt that defines agent behavior
|
|
15
|
+
],
|
|
7
16
|
"properties": {
|
|
8
|
-
"
|
|
17
|
+
"schema_version": {
|
|
9
18
|
"type": "string",
|
|
10
|
-
"pattern": "
|
|
11
|
-
"description": "
|
|
12
|
-
"examples": ["
|
|
19
|
+
"pattern": "^\\d+\\.\\d+\\.\\d+$", // Enforces semantic versioning format (X.Y.Z)
|
|
20
|
+
"description": "Schema version for the agent template format. This ensures compatibility between the agent template and the schema validator. Must be updated when breaking changes are made to the schema.",
|
|
21
|
+
"examples": ["1.0.0", "1.2.0"]
|
|
13
22
|
},
|
|
14
|
-
"
|
|
23
|
+
"agent_id": {
|
|
15
24
|
"type": "string",
|
|
16
|
-
"pattern": "
|
|
17
|
-
"description": "
|
|
25
|
+
"pattern": "^[a-z][a-z0-9_]*$", // Must start with lowercase letter, followed by lowercase letters, numbers, or underscores
|
|
26
|
+
"description": "Unique agent identifier used for agent discovery and loading. This ID must be unique across all agents in the system and follows snake_case naming convention.",
|
|
27
|
+
"examples": ["research_agent", "engineer_agent", "qa_agent", "security_agent"]
|
|
28
|
+
},
|
|
29
|
+
"agent_version": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"pattern": "^\\d+\\.\\d+\\.\\d+$", // Enforces semantic versioning for agent templates
|
|
32
|
+
"description": "Semantic version of the agent template itself (not the schema). Increment major for breaking changes, minor for new features, patch for bug fixes.",
|
|
18
33
|
"examples": ["1.0.0", "2.1.3"]
|
|
19
34
|
},
|
|
35
|
+
"agent_type": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"description": "Type of agent that determines its primary function and default capabilities. This categorization helps in agent discovery and capability matching.",
|
|
38
|
+
"enum": [
|
|
39
|
+
"base", // Generic agent with no specialization
|
|
40
|
+
"engineer", // Code implementation and development
|
|
41
|
+
"qa", // Quality assurance and testing
|
|
42
|
+
"documentation", // Documentation creation and maintenance
|
|
43
|
+
"research", // Code analysis and research
|
|
44
|
+
"security", // Security analysis and vulnerability detection
|
|
45
|
+
"ops", // Operations and infrastructure management
|
|
46
|
+
"data_engineer", // Data pipeline and ETL development
|
|
47
|
+
"version_control" // Git and version control operations
|
|
48
|
+
]
|
|
49
|
+
},
|
|
20
50
|
"metadata": {
|
|
21
51
|
"type": "object",
|
|
22
|
-
"required": [
|
|
52
|
+
"required": [
|
|
53
|
+
"name", // Human-readable name for UI display
|
|
54
|
+
"description", // Brief explanation of agent's purpose
|
|
55
|
+
"tags" // Searchable tags for agent discovery
|
|
56
|
+
],
|
|
23
57
|
"properties": {
|
|
24
58
|
"name": {
|
|
25
59
|
"type": "string",
|
|
26
|
-
"minLength": 3,
|
|
27
|
-
"maxLength": 50,
|
|
28
|
-
"description": "Human-readable agent name"
|
|
60
|
+
"minLength": 3, // Minimum 3 characters for meaningful names
|
|
61
|
+
"maxLength": 50, // Maximum 50 characters to prevent UI overflow
|
|
62
|
+
"description": "Human-readable agent name displayed in UI and logs. Should be concise but descriptive."
|
|
29
63
|
},
|
|
30
64
|
"description": {
|
|
31
65
|
"type": "string",
|
|
32
|
-
"minLength": 10,
|
|
33
|
-
"maxLength": 200,
|
|
34
|
-
"description": "Brief description of agent purpose"
|
|
66
|
+
"minLength": 10, // Minimum 10 characters to ensure meaningful descriptions
|
|
67
|
+
"maxLength": 200, // Maximum 200 characters for conciseness
|
|
68
|
+
"description": "Brief description of agent purpose and capabilities. Used in agent selection and documentation."
|
|
35
69
|
},
|
|
36
70
|
"category": {
|
|
37
71
|
"type": "string",
|
|
@@ -42,12 +76,12 @@
|
|
|
42
76
|
"type": "array",
|
|
43
77
|
"items": {
|
|
44
78
|
"type": "string",
|
|
45
|
-
"pattern": "^[a-z][a-z0-9-]*$"
|
|
79
|
+
"pattern": "^[a-z][a-z0-9-]*$" // Lowercase letters, numbers, and hyphens only
|
|
46
80
|
},
|
|
47
|
-
"minItems": 1,
|
|
48
|
-
"maxItems": 10,
|
|
49
|
-
"uniqueItems": true,
|
|
50
|
-
"description": "Tags for agent discovery"
|
|
81
|
+
"minItems": 1, // At least one tag required for discovery
|
|
82
|
+
"maxItems": 10, // Maximum 10 tags to prevent over-tagging
|
|
83
|
+
"uniqueItems": true, // No duplicate tags allowed
|
|
84
|
+
"description": "Tags for agent discovery and categorization. Used by the agent registry for searching and filtering."
|
|
51
85
|
},
|
|
52
86
|
"author": {
|
|
53
87
|
"type": "string",
|
|
@@ -67,66 +101,99 @@
|
|
|
67
101
|
},
|
|
68
102
|
"capabilities": {
|
|
69
103
|
"type": "object",
|
|
70
|
-
"required": [
|
|
104
|
+
"required": [
|
|
105
|
+
"model", // Claude model version to use
|
|
106
|
+
"tools", // Array of allowed tools for the agent
|
|
107
|
+
"resource_tier" // Resource allocation category
|
|
108
|
+
],
|
|
71
109
|
"properties": {
|
|
72
110
|
"model": {
|
|
73
111
|
"type": "string",
|
|
74
112
|
"enum": [
|
|
113
|
+
// Haiku models - fastest, most cost-effective
|
|
75
114
|
"claude-3-haiku-20240307",
|
|
76
115
|
"claude-3-5-haiku-20241022",
|
|
116
|
+
// Sonnet models - balanced performance
|
|
77
117
|
"claude-3-sonnet-20240229",
|
|
78
118
|
"claude-3-5-sonnet-20241022",
|
|
79
|
-
"claude-3-opus-20240229",
|
|
80
119
|
"claude-3-5-sonnet-20240620",
|
|
81
120
|
"claude-sonnet-4-20250514",
|
|
82
121
|
"claude-4-sonnet-20250514",
|
|
122
|
+
// Opus models - highest capability
|
|
123
|
+
"claude-3-opus-20240229",
|
|
83
124
|
"claude-opus-4-20250514",
|
|
84
125
|
"claude-4-opus-20250514"
|
|
85
126
|
],
|
|
86
|
-
"description": "Claude model to use for this agent"
|
|
127
|
+
"description": "Claude model to use for this agent. Choose based on task complexity and performance requirements."
|
|
87
128
|
},
|
|
88
129
|
"tools": {
|
|
89
130
|
"type": "array",
|
|
90
131
|
"items": {
|
|
91
132
|
"type": "string",
|
|
92
133
|
"enum": [
|
|
93
|
-
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
|
|
99
|
-
"
|
|
134
|
+
// File operations
|
|
135
|
+
"Read", // Read file contents
|
|
136
|
+
"Write", // Write new files
|
|
137
|
+
"Edit", // Edit existing files
|
|
138
|
+
"MultiEdit", // Multiple edits in one operation
|
|
139
|
+
// Search and navigation
|
|
140
|
+
"Grep", // Search file contents
|
|
141
|
+
"Glob", // Find files by pattern
|
|
142
|
+
"LS", // List directory contents
|
|
143
|
+
// System operations
|
|
144
|
+
"Bash", // Execute shell commands
|
|
145
|
+
// Web operations
|
|
146
|
+
"WebSearch", // Search the web
|
|
147
|
+
"WebFetch", // Fetch web content
|
|
148
|
+
// Notebook operations
|
|
149
|
+
"NotebookRead", // Read Jupyter notebooks
|
|
150
|
+
"NotebookEdit", // Edit Jupyter notebooks
|
|
151
|
+
// Workflow operations
|
|
152
|
+
"TodoWrite", // Manage task lists
|
|
153
|
+
"ExitPlanMode", // Exit planning mode
|
|
154
|
+
// CLI tools (future expansion)
|
|
155
|
+
"git", // Git operations
|
|
156
|
+
"docker", // Docker commands
|
|
157
|
+
"kubectl", // Kubernetes operations
|
|
158
|
+
"terraform", // Infrastructure as code
|
|
159
|
+
"aws", // AWS CLI
|
|
160
|
+
"gcloud", // Google Cloud CLI
|
|
161
|
+
"azure" // Azure CLI
|
|
100
162
|
]
|
|
101
163
|
},
|
|
102
|
-
"uniqueItems": true,
|
|
103
|
-
"description": "Available tools for the agent"
|
|
164
|
+
"uniqueItems": true, // Each tool can only be listed once
|
|
165
|
+
"description": "Available tools for the agent. Tools determine what operations the agent can perform."
|
|
104
166
|
},
|
|
105
167
|
"resource_tier": {
|
|
106
168
|
"type": "string",
|
|
107
|
-
"enum": [
|
|
108
|
-
|
|
169
|
+
"enum": [
|
|
170
|
+
"basic", // Default resources for simple tasks
|
|
171
|
+
"standard", // Medium resources for typical operations
|
|
172
|
+
"intensive", // High resources for complex tasks
|
|
173
|
+
"lightweight" // Minimal resources for quick operations
|
|
174
|
+
],
|
|
175
|
+
"description": "Resource allocation tier that determines memory, CPU, and timeout limits. See definitions section for specific limits."
|
|
109
176
|
},
|
|
110
177
|
"max_tokens": {
|
|
111
178
|
"type": "integer",
|
|
112
|
-
"minimum": 1000,
|
|
113
|
-
"maximum": 200000,
|
|
114
|
-
"default": 8192,
|
|
115
|
-
"description": "Maximum tokens for response"
|
|
179
|
+
"minimum": 1000, // Minimum for meaningful responses
|
|
180
|
+
"maximum": 200000, // Maximum supported by Claude models
|
|
181
|
+
"default": 8192, // Default suitable for most tasks
|
|
182
|
+
"description": "Maximum tokens for response generation. Higher values allow longer responses but increase cost and latency."
|
|
116
183
|
},
|
|
117
184
|
"temperature": {
|
|
118
185
|
"type": "number",
|
|
119
|
-
"minimum": 0,
|
|
120
|
-
"maximum": 1,
|
|
121
|
-
"default": 0.7,
|
|
122
|
-
"description": "Model temperature setting"
|
|
186
|
+
"minimum": 0, // 0 = deterministic, focused
|
|
187
|
+
"maximum": 1, // 1 = creative, varied
|
|
188
|
+
"default": 0.7, // Balanced default
|
|
189
|
+
"description": "Model temperature setting controlling response randomness. Lower values for consistency, higher for creativity."
|
|
123
190
|
},
|
|
124
191
|
"timeout": {
|
|
125
192
|
"type": "integer",
|
|
126
|
-
"minimum": 30,
|
|
127
|
-
"maximum": 3600,
|
|
128
|
-
"default": 300,
|
|
129
|
-
"description": "Operation timeout in seconds"
|
|
193
|
+
"minimum": 30, // Minimum 30 seconds for basic operations
|
|
194
|
+
"maximum": 3600, // Maximum 1 hour for long-running tasks
|
|
195
|
+
"default": 300, // Default 5 minutes
|
|
196
|
+
"description": "Operation timeout in seconds. Should align with resource_tier settings."
|
|
130
197
|
},
|
|
131
198
|
"memory_limit": {
|
|
132
199
|
"type": "integer",
|
|
@@ -159,14 +226,24 @@
|
|
|
159
226
|
"description": "Allowed write paths"
|
|
160
227
|
}
|
|
161
228
|
}
|
|
229
|
+
},
|
|
230
|
+
"allowed_tools": {
|
|
231
|
+
"type": "array",
|
|
232
|
+
"items": {"type": "string"},
|
|
233
|
+
"description": "Glob patterns for allowed file paths. Restricts which files the agent can access (e.g., 'tests/**' for test files only)."
|
|
234
|
+
},
|
|
235
|
+
"disallowed_tools": {
|
|
236
|
+
"type": "array",
|
|
237
|
+
"items": {"type": "string"},
|
|
238
|
+
"description": "Tool names to explicitly disallow, overriding the tools array. Use for security restrictions (e.g., 'Bash' to prevent shell access)."
|
|
162
239
|
}
|
|
163
240
|
}
|
|
164
241
|
},
|
|
165
242
|
"instructions": {
|
|
166
243
|
"type": "string",
|
|
167
|
-
"minLength": 100,
|
|
168
|
-
"maxLength": 8000,
|
|
169
|
-
"description": "Agent system instructions
|
|
244
|
+
"minLength": 100, // Minimum to ensure meaningful instructions
|
|
245
|
+
"maxLength": 8000, // Maximum to fit within context limits
|
|
246
|
+
"description": "Agent system instructions that define behavior, approach, and constraints. This becomes the agent's system prompt."
|
|
170
247
|
},
|
|
171
248
|
"knowledge": {
|
|
172
249
|
"type": "object",
|
|
@@ -305,8 +382,10 @@
|
|
|
305
382
|
}
|
|
306
383
|
}
|
|
307
384
|
},
|
|
308
|
-
"additionalProperties": false,
|
|
385
|
+
"additionalProperties": false, // Strict validation - no extra properties allowed
|
|
309
386
|
"definitions": {
|
|
387
|
+
// Resource tier definitions provide guidance for resource allocation
|
|
388
|
+
// These are not enforced by the schema but used by the runtime
|
|
310
389
|
"resource_tier_limits": {
|
|
311
390
|
"intensive": {
|
|
312
391
|
"memory_limit": {"min": 4096, "max": 8192},
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Security Analysis: Agent Schema and Validation System
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
This document provides a comprehensive security analysis of the claude-mpm agent validation system, highlighting security features, considerations, and recommendations.
|
|
5
|
+
|
|
6
|
+
## Schema Security Features (agent_schema.json)
|
|
7
|
+
|
|
8
|
+
### 1. Input Validation
|
|
9
|
+
- **Strict Type Enforcement**: All fields have explicit types preventing type confusion attacks
|
|
10
|
+
- **Pattern Validation**: Agent IDs use pattern `^[a-z][a-z0-9_]*$` preventing injection attacks
|
|
11
|
+
- **Enum Restrictions**: Tools and models restricted to known safe values
|
|
12
|
+
- **Length Limits**: All string fields have min/max length to prevent memory exhaustion
|
|
13
|
+
- Instructions: max 8000 characters
|
|
14
|
+
- Name: max 50 characters
|
|
15
|
+
- Description: max 200 characters
|
|
16
|
+
|
|
17
|
+
### 2. Resource Controls
|
|
18
|
+
- **Memory Limits**: 512MB-8192MB range prevents OOM attacks
|
|
19
|
+
- **CPU Limits**: 10%-100% prevents resource hogging
|
|
20
|
+
- **Timeout Limits**: 30s-3600s prevents infinite operations
|
|
21
|
+
- **Token Limits**: 1000-200000 prevents API abuse
|
|
22
|
+
|
|
23
|
+
### 3. Access Controls
|
|
24
|
+
- **Network Access**: Default false, explicit opt-in required
|
|
25
|
+
- **File Access Paths**: Explicit read/write path restrictions
|
|
26
|
+
- **Tool Access**: Enumerated list prevents arbitrary tool usage
|
|
27
|
+
- **Additional Properties**: Set to false preventing field injection
|
|
28
|
+
|
|
29
|
+
### 4. Dangerous Tool Combinations
|
|
30
|
+
The schema allows these potentially dangerous combinations:
|
|
31
|
+
- **Bash + Write**: Can create and execute arbitrary scripts
|
|
32
|
+
- **docker + kubectl**: Container escape potential
|
|
33
|
+
- **aws + gcloud + azure**: Multiple cloud access increases attack surface
|
|
34
|
+
|
|
35
|
+
## Validator Security Features (agent_validator.py)
|
|
36
|
+
|
|
37
|
+
### 1. File Operation Security
|
|
38
|
+
- **Path Validation**: Checks file exists and is regular file
|
|
39
|
+
- **File Size Limits**: 1MB max prevents memory exhaustion
|
|
40
|
+
- **Symlink Protection**: Skips symlinks to prevent directory traversal
|
|
41
|
+
- **Directory Limits**: Max 100 files per directory prevents DoS
|
|
42
|
+
|
|
43
|
+
### 2. Business Rule Security
|
|
44
|
+
- **Double Validation**: Schema + business rules for defense in depth
|
|
45
|
+
- **ID Format Checking**: Additional validation beyond schema pattern
|
|
46
|
+
- **Resource Tier Validation**: Ensures limits match tier constraints
|
|
47
|
+
- **Tool Compatibility**: Validates dangerous tool combinations
|
|
48
|
+
|
|
49
|
+
### 3. Migration Security
|
|
50
|
+
- **Privilege Escalation Prevention**: Flags dangerous tools added during migration
|
|
51
|
+
- **Functionality Preservation**: Ensures security constraints maintained
|
|
52
|
+
- **Instruction Validation**: Prevents loss of security instructions
|
|
53
|
+
|
|
54
|
+
## Security Recommendations
|
|
55
|
+
|
|
56
|
+
### 1. Immediate Improvements
|
|
57
|
+
```python
|
|
58
|
+
# Add to validator.py
|
|
59
|
+
def _validate_path_injection(self, path: str) -> bool:
|
|
60
|
+
"""Prevent path traversal attacks"""
|
|
61
|
+
if '..' in path or path.startswith('/'):
|
|
62
|
+
return False
|
|
63
|
+
return True
|
|
64
|
+
|
|
65
|
+
def _validate_command_injection(self, value: str) -> bool:
|
|
66
|
+
"""Prevent command injection in string values"""
|
|
67
|
+
dangerous_chars = ['$', '`', ';', '&', '|', '>', '<']
|
|
68
|
+
return not any(char in value for char in dangerous_chars)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 2. Schema Enhancements
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"capabilities": {
|
|
75
|
+
"properties": {
|
|
76
|
+
"sandbox_mode": {
|
|
77
|
+
"type": "boolean",
|
|
78
|
+
"default": true,
|
|
79
|
+
"description": "Run agent in sandboxed environment"
|
|
80
|
+
},
|
|
81
|
+
"max_file_size": {
|
|
82
|
+
"type": "integer",
|
|
83
|
+
"default": 10485760,
|
|
84
|
+
"description": "Maximum file size agent can read/write (10MB default)"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### 3. Audit Logging
|
|
92
|
+
```python
|
|
93
|
+
def validate_agent(self, agent_data: Dict[str, Any]) -> ValidationResult:
|
|
94
|
+
# Add security audit logging
|
|
95
|
+
audit_log = {
|
|
96
|
+
"timestamp": datetime.utcnow().isoformat(),
|
|
97
|
+
"agent_id": agent_data.get("id"),
|
|
98
|
+
"tools": agent_data.get("capabilities", {}).get("tools", []),
|
|
99
|
+
"network_access": agent_data.get("capabilities", {}).get("network_access", False),
|
|
100
|
+
"validation_result": "pending"
|
|
101
|
+
}
|
|
102
|
+
# Log to security audit trail
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 4. Runtime Security Checks
|
|
106
|
+
- Implement runtime validation of actual tool usage vs declared tools
|
|
107
|
+
- Monitor resource usage against declared limits
|
|
108
|
+
- Validate file access against declared paths
|
|
109
|
+
- Check for privilege escalation attempts
|
|
110
|
+
|
|
111
|
+
## Potential Security Issues
|
|
112
|
+
|
|
113
|
+
### 1. Missing Validations
|
|
114
|
+
- No validation of hook configurations
|
|
115
|
+
- No validation of file path patterns for malicious patterns
|
|
116
|
+
- No rate limiting on validation operations
|
|
117
|
+
- No cryptographic signing of agent configurations
|
|
118
|
+
|
|
119
|
+
### 2. Information Disclosure
|
|
120
|
+
- Error messages may reveal system paths
|
|
121
|
+
- Schema version in metadata could aid attackers
|
|
122
|
+
- No sanitization of user-provided descriptions
|
|
123
|
+
|
|
124
|
+
### 3. Trust Boundaries
|
|
125
|
+
- No verification of agent template sources
|
|
126
|
+
- No integrity checking of loaded schemas
|
|
127
|
+
- Migration process trusts old configurations
|
|
128
|
+
|
|
129
|
+
## Security Best Practices for Agent Authors
|
|
130
|
+
|
|
131
|
+
1. **Principle of Least Privilege**: Only request tools actually needed
|
|
132
|
+
2. **Avoid Dangerous Combinations**: Don't combine Bash with Write unless essential
|
|
133
|
+
3. **Explicit Path Restrictions**: Always specify file access paths
|
|
134
|
+
4. **Network Isolation**: Only enable network_access when required
|
|
135
|
+
5. **Resource Limits**: Set appropriate limits for agent workload
|
|
136
|
+
6. **Input Sanitization**: Never trust user input in agent instructions
|
|
137
|
+
7. **Secure Defaults**: Start with minimal permissions and add as needed
|
|
138
|
+
|
|
139
|
+
## Compliance Considerations
|
|
140
|
+
|
|
141
|
+
### OWASP Top 10 Coverage
|
|
142
|
+
- **A01:2021 Broken Access Control**: ✓ Tool and file access restrictions
|
|
143
|
+
- **A02:2021 Cryptographic Failures**: ⚠️ No encryption of agent configs
|
|
144
|
+
- **A03:2021 Injection**: ✓ Pattern validation, enum restrictions
|
|
145
|
+
- **A04:2021 Insecure Design**: ✓ Defense in depth validation
|
|
146
|
+
- **A05:2021 Security Misconfiguration**: ✓ Secure defaults, explicit opt-in
|
|
147
|
+
- **A06:2021 Vulnerable Components**: ⚠️ No component version checking
|
|
148
|
+
- **A07:2021 Identification and Authentication**: N/A (handled elsewhere)
|
|
149
|
+
- **A08:2021 Software and Data Integrity**: ⚠️ No integrity verification
|
|
150
|
+
- **A09:2021 Security Logging**: ⚠️ Limited security event logging
|
|
151
|
+
- **A10:2021 SSRF**: ✓ Network access controls
|
|
152
|
+
|
|
153
|
+
## Conclusion
|
|
154
|
+
|
|
155
|
+
The claude-mpm validation system implements strong security controls through:
|
|
156
|
+
- Strict schema validation with type safety
|
|
157
|
+
- Resource limits preventing DoS attacks
|
|
158
|
+
- Access controls for tools and files
|
|
159
|
+
- Defense in depth with multiple validation layers
|
|
160
|
+
|
|
161
|
+
Key areas for improvement:
|
|
162
|
+
- Cryptographic signing of configurations
|
|
163
|
+
- Enhanced audit logging
|
|
164
|
+
- Runtime security monitoring
|
|
165
|
+
- Integrity verification
|