Overview
Vectra Guard provides defense in depth for development environments where AI agents and automation tools execute commands with shell access. The tool focuses on preventing catastrophic mistakes and malicious actions while maintaining developer productivity.What Vectra Guard Protects Against
1. Accidental Destructive Commands
Threat: Developers or AI agents accidentally run commands that destroy data or corrupt systems. Examples:- ✅ Enhanced pattern detection: Catches all variations (
rm -rf /,rm -r /*, etc.) - ✅ Mandatory sandboxing: Critical commands cannot bypass sandbox
- ✅ Pre-execution assessment: Commands blocked before execution
- ✅ No fallback: If sandbox unavailable, command is blocked entirely
DANGEROUS_DELETE_ROOT are ALWAYS blocked or run in mandatory sandbox.
2. AI Agent Misbehavior
Threat: AI coding agents (Cursor, Copilot, Claude) generate and execute risky commands without proper validation. Examples:- ✅ Session tracking: All agent actions logged with session ID
- ✅ Risk analysis: Commands classified as low/medium/high/critical
- ✅ Sandbox isolation: Medium+ risk commands run in containers
- ✅ Interactive approval: Optional human confirmation for risky actions
- ✅ Network restrictions: External HTTP(S) blocked by default
3. Malicious Scripts from Untrusted Sources
Threat: Scripts from unknown sources contain malicious payloads. Examples:- Downloaded deployment scripts
- Third-party automation tools
- Modified open-source scripts
- ✅ Script validation: Analyze without executing (
vg validate script.sh) - ✅ Risk explanation: Human-readable risk assessment (
vg explain script.sh) - ✅ Sandbox execution: Run scripts in isolated containers
- ✅ Pattern detection: Flags dangerous operations (file deletion, network installs, sudo usage)
4. Supply Chain Attacks
Threat: Malicious or vulnerable dependencies introduced through package managers. Examples:- Compromised npm packages
- Vulnerable Python libraries
- Malicious Go modules
- ✅ CVE scanning: Local vulnerability database (
vg cve scan) - ✅ Manifest scanning: Checks package.json, requirements.txt, go.mod
- ✅ Package audits: npm/Python package vulnerability checks
- ✅ Pre-install scanning: Detect vulnerabilities before installation
5. Privilege Escalation
Threat: Unauthorized elevation to root or system-level access. Examples:- ✅ Sudo detection: Flags
sudousage (override withVECTRAGUARD_ALLOW_SUDO=1) - ✅ System directory protection: Monitors writes to
/etc,/var,/usr,/bin - ✅ Sandbox isolation: Even with sudo, critical commands sandboxed
- ✅ Audit trail: All sudo usage logged in session
6. Data Exfiltration via Network
Threat: Commands that send data to external servers. Examples:- ✅ Network mode restrictions: Default blocks external HTTP(S) (override with
VECTRAGUARD_ALLOW_NET=1) - ✅ URL scanning: Flags non-localhost HTTP requests in code
- ✅ Sandbox network isolation:
network_mode: nonein paranoid mode
7. Exposed Secrets and Credentials
Threat: API keys, tokens, and passwords committed to version control. Examples:- ✅ Secret scanning: Detects AWS keys, API tokens, private keys (
vg scan-secrets) - ✅ Entropy analysis: Flags high-entropy strings with secret context
- ✅ Pre-commit hooks: Block commits with exposed secrets
- ✅ CI integration: Fail builds when secrets detected
8. Deployment Misconfigurations
Threat: Production services exposed without authentication or TLS. Examples:- ✅ Config scanning: Flags
BIND_ALL_INTERFACES,UNAUTHENTICATED_ACCESS(vg scan-security --languages config) - ✅ Trust proxy detection: Warns about localhost trust misconfigurations
- ✅ Pre-deployment checks: Run in CI before production deploy
Attack Vectors Covered
High Impact (Critical Protection)
| Attack Vector | Detection | Prevention | Mitigation |
|---|---|---|---|
Root filesystem deletion (rm -rf /) | ✅ Pattern detection | ✅ Mandatory sandbox | ✅ Pre-execution block |
| System directory modification | ✅ Path analysis | ✅ Sandbox isolation | ✅ Audit logging |
| Fork bombs | ✅ Pattern detection | ✅ Mandatory sandbox | ✅ Resource limits |
Credential access (.env reads) | ✅ Pattern detection | ✅ Sandbox isolation | ✅ Secret scanning |
Medium Impact (Important Protection)
| Attack Vector | Detection | Prevention | Mitigation |
|---|---|---|---|
Network installs (curl | sh) | ✅ Pattern detection | ✅ Sandbox + approval | ✅ Network restrictions |
| Risky git operations (force push) | ✅ Pattern detection | ⚠️ Warning + approval | ✅ Audit logging |
| Vulnerable dependencies | ✅ CVE scanning | ⚠️ Advisory | ✅ Manifest checks |
| Command injection | ✅ Code scanning | ⚠️ Warning | ✅ Best practices docs |
Low Impact (Advisory)
| Attack Vector | Detection | Prevention | Mitigation |
|---|---|---|---|
| External HTTP requests | ✅ Code scanning | ⚠️ Advisory | ✅ SSRF awareness |
| Environment variable access | ✅ Code scanning | ⚠️ Advisory | ✅ Best practices |
Unsafe C functions (strcpy) | ✅ Code scanning | ⚠️ Advisory | ✅ Recommendations |
Security Guarantees
What We Guarantee
Strong Guarantees
- ✅ Critical commands (
rm -r /*, fork bombs, etc.) are ALWAYS blocked or run in mandatory sandbox - ✅ No bypass possible for critical commands (trust store, config, user bypass all ignored)
- ✅ Sandbox required for critical commands (no fallback to host execution)
- ✅ Enhanced detection catches all variations of destructive commands
- ✅ Pre-execution assessment happens before any critical command runs
What We Don’t Guarantee
Security Boundaries and Layers
Layer 1: Pattern Detection (All Commands)
Coverage: 200+ risky patternsEffectiveness: ~85% of common threats
Bypass difficulty: Low (requires obfuscation) Examples:
rm -rf /→ Detected asDANGEROUS_DELETE_ROOTcurl | sh→ Detected asNETWORK_INSTALL:(){ :|:& };:→ Detected asFORK_BOMB
Layer 2: Risk Classification (All Commands)
Coverage: low/medium/high/critical levelsEffectiveness: ~90% appropriate classification
Bypass difficulty: Medium (requires disguised intent) Logic:
- Root operations → Critical
- System directory writes → High
- Network installs → Medium
- Read operations → Low
Layer 3: Mandatory Sandboxing (Critical Commands)
Coverage: Critical-risk commands onlyEffectiveness: ~95% isolation (container-based)
Bypass difficulty: High (requires container escape) Cannot be bypassed by:
- Trust store entries
- Allowlist patterns
- Configuration settings
- User bypass flags
Layer 4: Pre-Execution Assessment (Critical Commands)
Coverage: Critical commandsEffectiveness: 100% (command blocked if sandbox unavailable)
Bypass difficulty: Very high (requires system-level compromise) Behavior:
Configuration for Different Threat Models
Development Environment (Balanced)
Goal: Prevent catastrophic mistakes while maintaining productivity.- Accidental destructive commands
- Most AI agent mistakes
- Malicious scripts (if sandboxed)
- Deliberate bypass by developer
- Social engineering
CI/CD Pipeline (Strict)
Goal: Prevent any risky code from reaching production.- Exposed secrets reaching production
- Vulnerable dependencies in builds
- Deployment misconfigurations
Production Deployment (Paranoid)
Goal: Maximum protection, zero tolerance.- ALL commands → Mandatory sandbox + approval
- Critical commands → BLOCKED (cannot execute)
- No network, no writes, full isolation
- All automated attacks
- Most insider threats
- Supply chain compromises
Known Limitations
1. Opt-In Enforcement
Problem: Protection only applies when usingvg exec or vectra-guard exec.
Risk: Developers can bypass by running commands directly.
Mitigation:
- Use shell integration for automatic tracking
- Deploy container isolation (Level 3 enforcement)
- Team policy and education
2. Container Escape
Problem: Advanced attackers may escape Docker/container sandbox. Risk: Full system compromise if sandbox is broken. Mitigation:- Use hardened container runtimes
- Apply seccomp profiles
- Run on isolated VMs or cloud sandboxes
- Regular security updates
3. Zero-Day Patterns
Problem: New attack patterns not yet in detection database. Risk: Novel attacks may not be caught. Mitigation:- Defense in depth (multiple layers)
- Regular pattern updates
- Community contributions
- Machine learning (future)
4. Social Engineering
Problem: Attackers trick users into allowing malicious commands. Risk: User approves risky action without understanding impact. Mitigation:- Clear risk explanations (
vg explain) - Security training
- Approval fatigue awareness
- Audit logs for review
5. Performance Overhead
Problem: Security checks and sandboxing add latency. Risk: Developers disable protection for speed. Mitigation:- Intelligent caching (10x speedup)
- Trust store for common commands
- Optimize pattern matching
- Async scanning where possible
Best Practices for Maximum Protection
1. Use Shell Integration
Automatic protection for all terminal commands:2. Enforce in CI/CD
Fail builds on security issues:3. Use Container Isolation
Maximum protection for untrusted code:4. Regular Audits
Review what happened:5. Principle of Least Privilege
Run with minimal permissions:Incident Response: The rm -r /* Case
What Happened
A tool executedrm -r /* during development:
- Command was not detected by analyzer
- Bypassed sandboxing and ran on host
- Result: Entire OS corrupted
Root Causes
- Pattern detection too narrow (only
rm -rf /) - Sandboxing could be bypassed
- No mandatory pre-execution assessment
- Critical commands could fallback to host
Improvements Implemented
✅ Enhanced pattern detection: Now catchesrm -r /*, rm -rf /, rm -r /, etc.✅ Mandatory sandboxing: Critical commands CANNOT bypass
✅ Pre-execution assessment: Runs BEFORE execution
✅ No fallback: Blocked if sandbox unavailable
Verification
Future Enhancements
Planned
- eBPF-based monitoring: Kernel-level syscall filtering
- ML-based anomaly detection: Learn normal patterns, flag outliers
- Network policy enforcement: Fine-grained network controls
- File operation monitoring: Track all file access in real-time
- Web-based approval UI: Team-based approval workflows
Under Research
- Hardware-based isolation: Use VMs or hardware virtualization
- Behavioral analysis: Track command sequences for patterns
- Integration with EDR: Enterprise detection and response
- Zero-trust architecture: Verify every operation
Related Documentation
- Secret Scanning: Detect exposed credentials
- Code Scanning: Find risky code patterns
- Sandbox Guide: Complete sandboxing reference
- Configuration: Security configuration options
Conclusion
Vectra Guard provides strong protection against common and critical threats in AI-assisted development: ✅ Prevents catastrophic mistakes (root deletion, system corruption)✅ Mitigates AI agent risks (sandbox isolation, approval workflows)
✅ Detects supply chain issues (CVE scanning, package audits)
✅ Blocks credential exposure (secret scanning, pre-commit hooks)
✅ Catches deployment misconfigs (config scanning, bind detection) Use as part of a comprehensive security strategy that includes:
- Code review processes
- Penetration testing
- Security training
- Incident response planning
- Regular security audits
Stay Safe. Code Fearlessly. 🛡️Vectra Guard is defense in depth. Layer it with other security practices for maximum protection.