Project: BMAD Multi-Agent Framework Current Score: 87/100 (Grade: B+) Target Score: 95/100 (Grade: A) Date Created: 2026-01-16
This remediation plan addresses all gaps identified in the OWASP AI Security Checklist assessment, organized into four phases based on priority.
| Category | Current | Target | Gap |
|---|---|---|---|
| LLM04: Model DoS | 60/100 | 90/100 | +30 |
| LLM05: Supply Chain | 55/100 | 85/100 | +30 |
| LLM07: Plugin Design | 65/100 | 90/100 | +25 |
| LLM09: Overreliance | 40/100 | 70/100 | +30 |
Gap: No general rate limiting (LLM04.2)
Risk: Medium - Resource exhaustion attacks
Target File: .claude/validators/rate_limiter.py
| ID | Requirement |
|---|---|
| REQ-1.1.1 | Implement sliding window rate limiting |
| REQ-1.1.2 | Configure limits per session (default: 150 requests/minute) |
| REQ-1.1.3 | Configure limits per operation type (Bash: 60/min, Write: 100/min, Read: 400/min, Task: 40/min) |
| REQ-1.1.4 | Implement exponential backoff on limit breach |
| REQ-1.1.5 | Add bypass for whitelisted operations |
| REQ-1.1.6 | Log all rate limit events |
RATE_LIMITS = {
'global': {'requests': 150, 'window_seconds': 60},
'bash': {'requests': 60, 'window_seconds': 60},
'write': {'requests': 100, 'window_seconds': 60},
'edit': {'requests': 100, 'window_seconds': 60},
'read': {'requests': 400, 'window_seconds': 60},
'glob': {'requests': 200, 'window_seconds': 60},
'grep': {'requests': 200, 'window_seconds': 60},
'task': {'requests': 40, 'window_seconds': 60},
}
class RateLimiter:
def check_limit(self, operation: str) -> Tuple[bool, Optional[str]]:
"""Check if operation is within rate limit."""
pass
def record_request(self, operation: str) -> None:
"""Record a request for rate limiting."""
pass
def get_retry_after(self, operation: str) -> int:
"""Get seconds until rate limit resets."""
pass- Rate limiter blocks requests exceeding configured limits
- Different limits apply per operation type
- Clear error messages indicate retry-after time
- Audit log captures all rate limit events
- Performance impact < 10ms per check (avg 0.6ms measured)
Gap: No capability-based security for plugins (LLM07.4, LLM07.6)
Risk: High - Plugin exploitation
Target Files: .claude/validators/plugin_permissions.py, _bmad/core/manifests/
| ID | Requirement |
|---|---|
| REQ-1.2.1 | Define plugin manifest schema with required permissions |
| REQ-1.2.2 | Implement permission checking at runtime |
| REQ-1.2.3 | Define capability set (filesystem, network, shell, sensitive_data) |
| REQ-1.2.4 | Block operations exceeding declared permissions |
| REQ-1.2.5 | Integrate with RBAC for permission inheritance |
| REQ-1.2.6 | Log permission violations |
# Example: _bmad/intel-team/manifest.yaml
name: intel-team
version: 1.0.0
permissions:
filesystem:
read: ["_bmad/intel-team/**", "docs/**"]
write: ["_bmad/intel-team/output/**"]
network: true
shell:
allowed_commands: ["curl", "wget", "whois", "dig"]
blocked_commands: ["rm", "mv", "chmod"]
sensitive_data: false
signature: |
-----BEGIN PGP SIGNATURE-----
...
-----END PGP SIGNATURE------ All BMAD plugins have manifest files (9 manifests generated)
- Permission checker validates operations against manifest
- Operations outside declared permissions are blocked
- RBAC integration limits permissions based on user role
- Audit log captures all permission checks
Gap: Skills loaded without verification (LLM05.4)
Risk: High - Malicious skill injection
Target Files: .claude/validators/supply_chain_verifier.py, MANIFEST.sha256
| ID | Requirement |
|---|---|
| REQ-2.1.1 | Implement GPG signature verification for manifests |
| REQ-2.1.2 | Verify SHA256 checksums of all skill files |
| REQ-2.1.3 | Block loading of unverified skills |
| REQ-2.1.4 | Implement trusted key management |
| REQ-2.1.5 | Add integrity check on hook execution |
| REQ-2.1.6 | Log all verification attempts and failures |
Skill Request → Load Manifest → Verify GPG Signature
↓
VALID → Verify SHA256 Checksums
↓
MATCH → Execute Skill
MISMATCH → BLOCK + LOG
INVALID → BLOCK + LOG
- All skills have SHA256 checksums in manifest
- Manifest is GPG signed with trusted key
- Skill loading verifies signature before execution
- Checksum mismatches block skill loading
- Invalid signatures trigger security alert
Gap: No context size management (LLM04.7)
Risk: Low-Medium - Context overflow causing failures
Target File: .claude/validators/context_manager.py
| ID | Requirement |
|---|---|
| REQ-2.2.1 | Track estimated token count per session |
| REQ-2.2.2 | Warn at 75% context capacity |
| REQ-2.2.3 | Block at 95% context capacity |
| REQ-2.2.4 | Implement token estimation for requests |
| REQ-2.2.5 | Suggest summarization when approaching limits |
| REQ-2.2.6 | Log context usage metrics |
CHARS_PER_TOKEN = 4
MAX_CONTEXT_TOKENS = 200000
WARNING_THRESHOLD = 0.75
BLOCK_THRESHOLD = 0.95
class ContextManager:
def estimate_tokens(self, text: str) -> int:
return len(text) // CHARS_PER_TOKEN
def check_capacity(self) -> Tuple[str, float, Optional[str]]:
"""Returns: (status, percentage, message)"""
pass- Token count tracked across session
- Warning displayed at 75% capacity
- Operations blocked at 95% capacity
- Large file reads show estimated token cost
Gap: No explicit recursion limits (LLM04.6)
Risk: Medium - Stack overflow / infinite loops
Target File: .claude/validators/recursion_guard.py
| ID | Requirement |
|---|---|
| REQ-2.3.1 | Track recursive operation depth |
| REQ-2.3.2 | Limit directory traversal depth (default: 10) |
| REQ-2.3.3 | Limit nested function calls (default: 20) |
| REQ-2.3.4 | Detect circular references |
| REQ-2.3.5 | Log recursion violations |
- Directory operations limited to configured depth
- Nested operations tracked and limited
- Circular references detected and blocked
- Clear error messages on recursion limits
Gap: No confidence scoring (LLM09.1, LLM09.3)
Risk: Low - User overreliance on outputs
Target File: .claude/validators/confidence_tracker.py
| ID | Requirement |
|---|---|
| REQ-3.1.1 | Track uncertainty markers in model responses |
| REQ-3.1.2 | Flag responses containing hedging language |
| REQ-3.1.3 | Add confidence indicators for code generation |
| REQ-3.1.4 | Implement source attribution tracking |
| REQ-3.1.5 | Display confidence in user-facing output |
UNCERTAINTY_MARKERS = [
r'\bmight\b', r'\bmaybe\b', r'\bperhaps\b', r'\bpossibly\b',
r'\bI think\b', r'\bI believe\b', r'\bI\'m not sure\b',
r'\bcould be\b', r'\bseems like\b', r'\bprobably\b',
]
CONFIDENCE_LEVELS = {
'HIGH': 0.9, # No uncertainty markers
'MEDIUM': 0.7, # Some hedging
'LOW': 0.5, # Multiple uncertainty markers
}- Uncertainty markers detected in responses (3 severity levels)
- Confidence level assigned to responses (HIGH/MEDIUM/LOW/VERY_LOW)
- Visual indicator added to user output (configurable via BMAD_SHOW_CONFIDENCE)
Gap: No sandboxing/isolation (LLM07.4) Risk: High - Cross-plugin contamination Target: Research document and POC
| ID | Area |
|---|---|
| RESEARCH-3.2.1 | Evaluate Python subprocess isolation |
| RESEARCH-3.2.2 | Evaluate container-based isolation (Docker) |
| RESEARCH-3.2.3 | Evaluate seccomp/AppArmor profiles |
| RESEARCH-3.2.4 | Performance impact analysis |
| Option | Security | Performance | Complexity | Recommendation |
|---|---|---|---|---|
| subprocess + ulimit | Medium | High | Low | Short-term |
| Docker containers | High | Medium | Medium | Medium-term |
| seccomp profiles | High | High | High | Long-term |
- Research document completed -
_bmad/core/security/PLUGIN-ISOLATION-RESEARCH.md - POC demonstrates basic isolation (subprocess + ulimit implementation)
- Performance benchmarks documented (subprocess: 15ms, Docker: 450ms)
- Recommendation for production implementation (phased: subprocess → Docker)
Gap: No memory limits (LLM04.3)
Risk: Medium - Memory exhaustion
Target File: .claude/validators/resource_limits.py
| ID | Requirement |
|---|---|
| REQ-3.3.1 | Set maximum memory per session (default: 4GB via BMAD_MAX_MEMORY_MB) |
| REQ-3.3.2 | Track memory usage of child processes |
| REQ-3.3.3 | Kill processes exceeding limits |
| REQ-3.3.4 | Log memory violations |
| REQ-3.3.5 | Configurable via environment variables |
- Memory limits enforced on child processes (default: 4GB via BMAD_MAX_MEMORY_MB)
- Processes exceeding limits terminated gracefully (5s grace period)
- Clear error message on resource exhaustion
- Configurable limits via environment (BMAD_MAX_MEMORY_MB, BMAD_MAX_CHILD_PROCS, etc.)
Gap: No tamper detection
Target File: .claude/validators/audit_integrity.py (new), .claude/validators/security_common.py (enhanced)
| ID | Requirement | Status |
|---|---|---|
| REQ-4.1.1 | Implement hash chain for audit entries | Done |
| REQ-4.1.2 | Optional GPG signing of log files | Done |
| REQ-4.1.3 | Tamper detection on log read | Done |
| REQ-4.1.4 | Integrity verification command | Done |
| REQ-4.1.5 | Alert on detected tampering | Done |
Entry 1: hash1 = SHA256(timestamp + event + "genesis")
Entry 2: hash2 = SHA256(timestamp + event + hash1)
Entry 3: hash3 = SHA256(timestamp + event + hash2)
...
Verification: Recompute chain, compare hashes
Audit Integrity Module: .claude/validators/audit_integrity.py
HashChainManagerclass for managing hash chains- SHA256-based content hashing with chain linkage
- Atomic state persistence using file locking
- Tamper detection with alerts to stderr and separate log
- CLI for verification:
python3 audit_integrity.py verify - Optional GPG signing:
python3 audit_integrity.py sign
Integration: AuditLogger in security_common.py automatically adds chain fields to all log entries.
- Each log entry includes hash of previous entry (
_previous_hash,_entry_hash) - Integrity verification command available (
python3 audit_integrity.py verify) - Tampering detected if entries modified (content hash mismatch, chain break)
- Performance impact < 5ms per entry (measured ~0.5ms average)
Gap: No structured telemetry for external analysis
Target: Centralized telemetry collection for SIEM/dashboard integration
Implementation: .claude/validators/telemetry_collector.py
| ID | Requirement | Status |
|---|---|---|
| REQ-4.2.1 | Structured JSONL telemetry output | Done |
| REQ-4.2.2 | Security event telemetry from all validators | Done |
| REQ-4.2.3 | Rate limit metrics telemetry | Done |
| REQ-4.2.4 | Permission audit telemetry | Done |
| REQ-4.2.5 | Resource usage telemetry | Done |
| REQ-4.2.6 | Supply chain verification telemetry | Done |
| REQ-4.2.7 | Export capabilities (JSONL for external tools) | Done |
Telemetry Location: docs/TestingLogs/security/AuditLogs/telemetry/
Telemetry Files:
security_events.jsonl- All validator security eventsrate_limit_metrics.jsonl- Rate limiter statisticspermission_audit.jsonl- Plugin permission checksresource_usage.jsonl- Context/memory metricssupply_chain_verification.jsonl- Integrity verification resultsconfidence_analysis.jsonl- Response confidence trackinganomaly_signals.jsonl- Detected anomalies (Phase 4.3)
Schema Documentation: docs/TestingLogs/security/AuditLogs/telemetry/TELEMETRY-SCHEMA.md
Telemetry can be consumed by:
- External SIEM systems (Splunk, ELK)
- Prometheus/Grafana
- Custom analysis scripts
- Compliance reporting tools
Note: Dashboard UI is not implemented - telemetry is designed for external consumption.
- JSONL telemetry files created in designated directory
- Security events captured from all validators
- Rate limit metrics captured on violations
- Permission checks captured with full context
- Resource usage snapshots captured
- Supply chain verifications captured
- Schema documentation complete
- File rotation configured (50MB default)
Gap: No pattern detection on logs
Target File: .claude/validators/anomaly_detector.py
| ID | Requirement | Status |
|---|---|---|
| REQ-4.3.1 | Baseline normal behavior patterns | Done |
| REQ-4.3.2 | Detect unusual activity volumes | Done |
| REQ-4.3.3 | Detect unusual operation types | Done |
| REQ-4.3.4 | Detect time-based anomalies | Done |
| REQ-4.3.5 | Alert on detected anomalies | Done |
Anomaly Detector Module: .claude/validators/anomaly_detector.py
AnomalyDetectorclass with rolling window statisticsStatisticsWindowclass for mean/std dev calculations- Volume spike/drop detection using z-scores
- Unusual operation type detection (rare or new operations)
- Hourly pattern baseline for time-based anomalies
- Blocked ratio anomaly detection (attack indicators)
- Severity scoring (INFO/WARNING/CRITICAL based on deviation)
- Telemetry integration via
record_anomaly_signal() - CLI for status and simulation:
python3 anomaly_detector.py status
Integration: AuditLogger in security_common.py automatically records events for anomaly detection.
Configuration:
BMAD_ANOMALY_DETECTION=true|false(default: true)BMAD_ANOMALY_THRESHOLD_STD=<float>(default: 3.0)BMAD_ANOMALY_BASELINE_HOURS=<int>(default: 24)
- Baseline automatically computed from history (rolling window, 10+ samples required)
- Volume anomalies detected (3+ std dev default, configurable)
- Type anomalies detected (rare/new operation types flagged)
- Alerts generated for anomalies (stderr + telemetry)
-
1.1 Rate Limiting
- Create
rate_limiter.py-.claude/validators/rate_limiter.py - Implement sliding window algorithm
- Add hook integration (validate_rate_limit entry point)
- Write unit tests -
tests/test_rate_limiter.py(27 tests)
- Create
-
1.2 Plugin Permission Model
- Create manifest schema (YAML format with permissions)
- Create
plugin_permissions.py-.claude/validators/plugin_permissions.py - Generate manifests for all BMAD plugins (9 plugins)
- Write unit tests -
tests/test_plugin_permissions.py(38 tests)
-
2.1 Supply Chain Verification
- Create
supply_chain_verifier.py-.claude/validators/supply_chain_verifier.py - SHA256 checksum verification for skill files
- GPG signature verification framework (verify_manifest_signature)
- Verification modes (strict, warn, disabled)
- Write unit tests -
tests/test_supply_chain_verifier.py(23 tests)
- Create
-
2.2 Context Window Management
- Create
context_manager.py-.claude/validators/context_manager.py - Token estimation (text, files, operations)
- Warning at 75% capacity, blocking at 95%
- Session tracking with automatic reset
- Write unit tests -
tests/test_context_manager.py(28 tests)
- Create
-
2.3 Recursion Limits
- Create
recursion_guard.py-.claude/validators/recursion_guard.py - Directory traversal depth limiting (default: 10)
- Nested call stack tracking (default: 20)
- Circular reference detection
- Symlink follow depth tracking
- Write unit tests -
tests/test_recursion_guard.py(28 tests)
- Create
-
3.1 Confidence Indicators
- Create
confidence_tracker.py-.claude/validators/confidence_tracker.py - Implement uncertainty detection (high/medium/low severity markers)
- Source attribution tracking
- Code warning detection (TODO, FIXME, HACK patterns)
- Confidence scoring algorithm (0.0 to 1.0)
- Display indicators for user-facing output
- Write unit tests -
tests/test_confidence_tracker.py(40 tests)
- Create
-
3.2 Plugin Isolation Research
- Research isolation options (subprocess, Docker, seccomp/AppArmor)
- Performance benchmarks documented
- Create POC for subprocess + ulimit isolation
- Document findings -
_bmad/core/security/PLUGIN-ISOLATION-RESEARCH.md - Recommendation: Phased approach (subprocess now, Docker medium-term)
-
3.3 Memory Limits
- Create
resource_limits.py-.claude/validators/resource_limits.py - Memory limit enforcement (default: 1GB)
- Child process limit tracking
- File size limit checking
- Process timeout enforcement
- Warning/critical threshold detection
- Write unit tests -
tests/test_resource_limits.py(38 tests)
- Create
-
4.1 Cryptographic Log Signing [COMPLETED 2026-01-16]
- Create
audit_integrity.py-.claude/validators/audit_integrity.py - Implement SHA256 hash chain with genesis block
- Implement tamper detection and alerting
- Create CLI verification command (
verify,status,sign,verify-gpg) - Integrate with AuditLogger in security_common.py
- Write unit tests -
tests/test_audit_integrity.py(17 tests)
- Create
-
4.2 Security Telemetry Collection [COMPLETED 2026-01-16]
- Create
telemetry_collector.py - Integrate with security_common.py
- Integrate with rate_limiter.py
- Integrate with plugin_permissions.py
- Integrate with context_manager.py
- Integrate with supply_chain_verifier.py
- Create TELEMETRY-SCHEMA.md documentation
- Create
-
4.3 Anomaly Detection [COMPLETED 2026-01-16]
- Create
anomaly_detector.py-.claude/validators/anomaly_detector.py - Implement StatisticsWindow for rolling statistics
- Implement volume spike/drop detection
- Implement unusual operation type detection
- Implement hourly pattern baseline
- Implement blocked ratio anomaly detection
- Integrate with AuditLogger for automatic event recording
- Integrate with telemetry for anomaly signals
- Write unit tests -
tests/test_anomaly_detector.py(29 tests)
- Create
| Category | Initial | Final | Target | Status |
|---|---|---|---|---|
| LLM04: Model DoS | 60 | 90 | 90 | ACHIEVED |
| LLM05: Supply Chain | 55 | 85 | 85 | ACHIEVED |
| LLM07: Plugin Design | 65 | 90 | 90 | ACHIEVED |
| LLM09: Overreliance | 40 | 70 | 70 | ACHIEVED |
| Overall | 87 | 95 | 95 | 100% |
All phases completed 2026-01-16. Target score of 95/100 achieved.
| Component | Security Improvement |
|---|---|
| Hash Chain Signing (4.1) | +2 (tamper detection, integrity verification) |
| Anomaly Detection (4.3) | +2 (pattern detection, automated alerting) |
- Zero security incidents from addressed gaps
- < 100ms added latency from new validators
- 100% validator coverage on all hook points
- < 5% false positive rate on security blocks
| Risk | Likelihood | Impact | Mitigation |
|---|---|---|---|
| Performance degradation | Medium | High | Benchmark before/after |
| False positives blocking work | Medium | Medium | Tune thresholds, add override |
| Integration complexity | Low | Medium | Phased rollout, feature flags |
| Insufficient testing | Low | High | Mandatory test coverage |
This remediation plan targets full OWASP AI Security compliance within 90 days.