security-checklist.md•11 kB
# Security Remediation Checklist - Scout MCP
**Date:** 2025-01-28
**Status:** IN PROGRESS
---
## Phase 1: CRITICAL Fixes (Week 1)
### ✅ V-001: Command Injection (CVSS 9.8)
**Files to Modify:**
- [ ] Create `scout_mcp/mcp_cat/validators.py`
- [ ] Update `scout_mcp/mcp_cat/executors.py`
- [ ] Create `tests/test_validators.py`
**Implementation Checklist:**
- [ ] Create `ALLOWED_COMMANDS` allowlist
- [ ] Implement `validate_command()` function
- [ ] Implement `validate_path()` function
- [ ] Add `ValidationError` exception class
- [ ] Update `run_command()` to use validation
- [ ] Update `stat_path()` to use `shlex.quote()`
- [ ] Update `cat_file()` to use validation
- [ ] Update `ls_dir()` to use validation
- [ ] Add timeout protection to all remote operations
**Testing Requirements:**
- [ ] Test valid commands pass
- [ ] Test command injection attempts fail
- [ ] Test disallowed commands fail
- [ ] Test dangerous flags blocked
- [ ] Test empty commands rejected
- [ ] Test path traversal blocked
- [ ] Test relative paths rejected
- [ ] Test sensitive paths blocked
- [ ] Test null bytes in paths rejected
- [ ] Test validation performance < 1ms
**Acceptance Criteria:**
- [ ] All tests pass (100% coverage on validators)
- [ ] Command injection attacks blocked
- [ ] Path traversal attacks blocked
- [ ] Error messages don't leak information
- [ ] Code review approved
- [ ] Security review approved
---
### ✅ V-002: SSH Host Key Bypass (CVSS 9.1)
**Files to Modify:**
- [ ] Update `scout_mcp/mcp_cat/pool.py`
- [ ] Update `scout_mcp/mcp_cat/config.py`
- [ ] Create `tests/test_pool_security.py`
**Implementation Checklist:**
- [ ] Add `known_hosts_path` parameter to `ConnectionPool`
- [ ] Change `known_hosts=None` to proper path
- [ ] Add connection timeout (`asyncio.wait_for`)
- [ ] Add SSH timeout parameters (`connect_timeout`, `login_timeout`)
- [ ] Configure secure cipher suites
- [ ] Add proper exception handling for `HostKeyNotVerifiable`
- [ ] Add connection pool limit (`max_connections`)
- [ ] Add security logging for connections
- [ ] Implement keepalive for connection health
**Testing Requirements:**
- [ ] Test host key verification enabled
- [ ] Test connection fails on bad host key
- [ ] Test connection timeout works
- [ ] Test connection pool limit enforced
- [ ] Test connection reuse works
- [ ] Test stale connections cleaned up
- [ ] Test secure ciphers used
**Acceptance Criteria:**
- [ ] All tests pass
- [ ] Host key verification mandatory
- [ ] Timeouts prevent hangs
- [ ] Connection pool limits enforced
- [ ] Logging shows all connection events
- [ ] Code review approved
- [ ] Security review approved
---
### ✅ V-003: Path Traversal (CVSS 8.6)
**Status:** Fixed in V-001 (validators.py)
- [ ] Verify path validation integrated
- [ ] Verify tests cover all traversal scenarios
---
## Phase 2: HIGH Severity (Week 2)
### ✅ V-004: No Connection Timeouts (CVSS 7.5)
**Status:** Fixed in V-002
- [ ] Verify all SSH operations have timeouts
- [ ] Verify timeout tests pass
---
### ✅ V-005: Insufficient Input Validation (CVSS 7.0)
**Status:** Fixed in V-001
- [ ] Verify comprehensive validation in place
- [ ] Verify validation tests comprehensive
---
### ✅ V-006: Weak Access Control (CVSS 6.5)
**Files to Modify:**
- [ ] Update `scout_mcp/mcp_cat/config.py`
- [ ] Create `tests/test_access_control.py`
**Implementation Checklist:**
- [ ] Add `allowed_ip_ranges` field
- [ ] Add `blocked_ip_ranges` field
- [ ] Add `require_explicit_allow` field (default True)
- [ ] Add `max_connections` field
- [ ] Implement `_is_ip_allowed()` method
- [ ] Update `_is_host_allowed()` with IP checks
- [ ] Add default deny when no allowlist
**Testing Requirements:**
- [ ] Test IP allowlist works
- [ ] Test IP blocklist works
- [ ] Test default deny enforced
- [ ] Test hostname + IP filtering combined
- [ ] Test special IP ranges blocked
**Acceptance Criteria:**
- [ ] All tests pass
- [ ] Default deny policy active
- [ ] IP-based filtering works
- [ ] Documentation updated
---
## Phase 3: MEDIUM Severity (Week 3)
### ✅ V-007: Information Disclosure (CVSS 5.3)
**Files to Modify:**
- [ ] Update `scout_mcp/mcp_cat/server.py`
- [ ] Create logging configuration
**Implementation Checklist:**
- [ ] Replace detailed errors with generic messages
- [ ] Add structured logging for internal errors
- [ ] Log detailed errors internally only
- [ ] Return user-friendly errors externally
- [ ] Remove stack traces from user output
**Testing Requirements:**
- [ ] Test errors don't leak paths
- [ ] Test errors don't leak system info
- [ ] Test internal logging captures details
- [ ] Test error messages are user-friendly
**Acceptance Criteria:**
- [ ] No information disclosure in errors
- [ ] Internal logging comprehensive
- [ ] User experience maintained
---
### ✅ V-008: No Rate Limiting (CVSS 5.0)
**Files to Modify:**
- [ ] Create `scout_mcp/mcp_cat/rate_limiter.py`
- [ ] Update `scout_mcp/mcp_cat/server.py`
- [ ] Create `tests/test_rate_limiter.py`
**Implementation Checklist:**
- [ ] Create `RateLimiter` class (token bucket)
- [ ] Add per-host rate limiting
- [ ] Add global rate limiting
- [ ] Integrate into `scout()` tool
- [ ] Add configuration for limits
**Testing Requirements:**
- [ ] Test rate limiting enforced
- [ ] Test limits configurable
- [ ] Test reset after time window
- [ ] Test per-host isolation
**Acceptance Criteria:**
- [ ] Rate limiting active
- [ ] DoS attacks mitigated
- [ ] Legitimate use not impacted
---
### ✅ V-009: Race Conditions (CVSS 5.0)
**Files to Modify:**
- [ ] Update `scout_mcp/mcp_cat/server.py`
- [ ] Create `tests/test_concurrency.py`
**Implementation Checklist:**
- [ ] Add `asyncio.Lock` for global state
- [ ] Implement double-check locking for singletons
- [ ] Make `get_config()` async
- [ ] Make `get_pool()` async
- [ ] Update all callers
**Testing Requirements:**
- [ ] Test concurrent initialization
- [ ] Test no duplicate instances
- [ ] Test thread safety
**Acceptance Criteria:**
- [ ] No race conditions
- [ ] Single instance guarantee
- [ ] Tests pass with concurrent requests
---
### ✅ V-010: No Security Logging (CVSS 5.0)
**Files to Modify:**
- [ ] Create `scout_mcp/mcp_cat/logging_config.py`
- [ ] Update all modules with logging
- [ ] Create `tests/test_logging.py`
**Implementation Checklist:**
- [ ] Configure structured logging
- [ ] Log all connection attempts
- [ ] Log all command executions
- [ ] Log access control violations
- [ ] Log rate limit violations
- [ ] Log validation failures
- [ ] Add request IDs for tracing
**Testing Requirements:**
- [ ] Test all events logged
- [ ] Test log format structured
- [ ] Test sensitive data not logged
- [ ] Test log rotation works
**Acceptance Criteria:**
- [ ] Comprehensive audit trail
- [ ] Security events detectable
- [ ] Compliance requirements met
---
## Phase 4: Hardening (Week 4)
### ✅ Security Testing Suite
**Tasks:**
- [ ] Create `tests/test_security_regression.py`
- [ ] Add command injection test suite
- [ ] Add path traversal test suite
- [ ] Add MITM test cases
- [ ] Add fuzzing tests
- [ ] Add performance tests
- [ ] Achieve >85% code coverage
**Tools:**
- [ ] Configure Bandit for SAST
- [ ] Configure Semgrep rules
- [ ] Run pip-audit in CI
- [ ] Add pre-commit hooks
**Acceptance Criteria:**
- [ ] All security tests pass
- [ ] Code coverage >85%
- [ ] No SAST findings
- [ ] No dependency vulnerabilities
---
### ✅ Documentation
**Tasks:**
- [ ] Security architecture document
- [ ] Deployment security guide
- [ ] Configuration examples (secure)
- [ ] Incident response procedures
- [ ] Security API documentation
- [ ] User security guidelines
**Acceptance Criteria:**
- [ ] All docs complete
- [ ] Examples tested and working
- [ ] Reviewed by security team
---
### ✅ Monitoring & Alerting
**Tasks:**
- [ ] Create `scout_mcp/mcp_cat/metrics.py`
- [ ] Add security metrics collection
- [ ] Configure alert thresholds
- [ ] Document monitoring requirements
- [ ] Create Grafana dashboard (optional)
**Metrics to Track:**
- [ ] Connection attempts (success/fail)
- [ ] Command executions
- [ ] Validation failures
- [ ] Rate limit violations
- [ ] Error rates
- [ ] Response times
**Acceptance Criteria:**
- [ ] Metrics collected
- [ ] Alerts configured
- [ ] Dashboard functional
- [ ] Documentation complete
---
## Final Validation
### Pre-Deployment Checklist
**Code Quality:**
- [ ] All unit tests pass (100%)
- [ ] All integration tests pass
- [ ] Code coverage >85%
- [ ] No linting errors (ruff)
- [ ] No type errors (mypy --strict)
- [ ] No SAST findings (Bandit, Semgrep)
**Security:**
- [ ] All critical vulnerabilities fixed
- [ ] All high vulnerabilities fixed
- [ ] All medium vulnerabilities fixed
- [ ] Penetration testing complete
- [ ] Security review approved
- [ ] Threat model updated
**Documentation:**
- [ ] README updated
- [ ] Security docs complete
- [ ] API documentation current
- [ ] Configuration examples tested
- [ ] Deployment guide reviewed
**Compliance:**
- [ ] OWASP Top 10 compliance verified
- [ ] Regulatory requirements met
- [ ] Audit trail functional
- [ ] Incident response plan ready
**Operations:**
- [ ] Staging deployment successful
- [ ] Monitoring configured
- [ ] Alerting tested
- [ ] Rollback plan documented
- [ ] Team training complete
---
## Sign-Off
### Phase 1 Completion
- [ ] Developer: _________________ Date: _______
- [ ] Code Reviewer: _____________ Date: _______
- [ ] Security Reviewer: _________ Date: _______
### Phase 2 Completion
- [ ] Developer: _________________ Date: _______
- [ ] Code Reviewer: _____________ Date: _______
- [ ] Security Reviewer: _________ Date: _______
### Phase 3 Completion
- [ ] Developer: _________________ Date: _______
- [ ] Code Reviewer: _____________ Date: _______
- [ ] Security Reviewer: _________ Date: _______
### Phase 4 Completion
- [ ] Developer: _________________ Date: _______
- [ ] Security Tester: ___________ Date: _______
- [ ] Security Team Lead: ________ Date: _______
### Production Deployment Approval
- [ ] Engineering Lead: __________ Date: _______
- [ ] Security Team: _____________ Date: _______
- [ ] Product Management: ________ Date: _______
- [ ] Executive Sponsor: _________ Date: _______
---
## Progress Tracking
| Phase | Start Date | Target Date | Completion Date | Status |
|-------|------------|-------------|-----------------|--------|
| Phase 1 | _________ | _________ | _________ | ⬜ Not Started |
| Phase 2 | _________ | _________ | _________ | ⬜ Not Started |
| Phase 3 | _________ | _________ | _________ | ⬜ Not Started |
| Phase 4 | _________ | _________ | _________ | ⬜ Not Started |
**Legend:**
- ⬜ Not Started
- 🟡 In Progress
- ✅ Complete
- ❌ Blocked
---
## Notes
**Blockers:**
**Risks:**
**Questions:**
---
**Last Updated:** 2025-01-28
**Owner:** Development Team
**Next Review:** Upon Phase 1 completion