MAINFRAME is designed as an AI-Native Bash Runtime where security is foundational, not an afterthought. AI agents controlling computer systems through bash commands must operate within strict safety boundaries.
- No Eval by Default - Command execution uses safe dispatch patterns, not
eval - Validate Before Execute - All inputs validated before any system operation
- Structured Errors - Errors return JSON for AI self-correction, not ambiguous text
- Audit Everything - All agent operations can be logged for traceability
- Fail Safely - Operations fail closed, never fail open
- Defense in Depth - Multiple layers of validation and sanitization
| Version | Supported | Security Updates |
|---|---|---|
| 5.x | ✅ | Active |
| 4.x | ✅ | Security only |
| 3.x | ✅ | Security only |
| < 3.0 | ❌ | End of life |
We take security vulnerabilities seriously, especially given MAINFRAME's role in AI agent automation.
- DO NOT open a public issue for security vulnerabilities
- Use GitHub Security Advisories (preferred)
- Or email security concerns to the repository owner
- Include:
- Description of the vulnerability
- Steps to reproduce
- Potential impact (especially for AI agent scenarios)
- Affected functions/libraries
- Suggested fix (if any)
| Severity | Response Time | Fix Timeline |
|---|---|---|
| Critical (RCE, privilege escalation) | 24 hours | 24-72 hours |
| High (data exposure, unsafe execution) | 48 hours | 7 days |
| Medium (input validation bypass) | 7 days | 14 days |
| Low (minor issues) | 14 days | Next release |
Security issues we're particularly concerned about:
| Category | Examples | Impact |
|---|---|---|
| Command Injection | Unsanitized input passed to commands | Full system compromise |
| Path Traversal | Bypassing path_is_safe validation |
Unauthorized file access |
| TOCTOU Races | Time-of-check to time-of-use | Race condition exploits |
| Unsafe Deserialization | JSON parsing that executes code | Arbitrary code execution |
| Privilege Escalation | Agent operations gaining unintended access | System compromise |
| Information Disclosure | Leaking sensitive data in errors/logs | Data breach |
- Issues requiring physical access to the machine
- Social engineering attacks
- Denial of service (unless trivially exploitable)
- Issues in external dependencies (report to their maintainers)
- Theoretical vulnerabilities without proof of concept
Safe command execution for AI agents:
source lib/agent_safety.sh
# Safe command dispatch - no eval, whitelisted commands only
agent_safe_exec "ls" "-la" "/safe/path"
# Command validation before execution
agent_validate_command "git" "status" || die 1 "Command not allowed"
# Idempotent operations - safe to retry
agent_ensure_dir "/path/to/dir"
agent_ensure_file "/path/to/file" "content"
# Full audit logging
agent_audit_log "created" "/path/to/file"Input validation and sanitization:
source lib/validation.sh
# Path validation - prevents directory traversal
validate_path_safe "$user_input" "/allowed/base" || die 1 "Path traversal detected"
# Command safety - detects injection attempts
validate_command_safe "$cmd" || die 1 "Injection detected"
# Shell argument sanitization
safe_arg=$(sanitize_shell_arg "$untrusted_input")
# Build properly escaped commands
safe_cmd=$(build_safe_command "grep" "$pattern" "$file")Structured errors for AI self-correction:
source lib/output.sh
export MAINFRAME_OUTPUT=json
# Errors include machine-parseable details
output_error "E_PATH_TRAVERSAL" "Path traversal detected" "Use absolute paths within allowed directory"
# {"ok":false,"error":{"code":"E_PATH_TRAVERSAL","msg":"Path traversal detected","suggestion":"Use absolute paths within allowed directory"}}Safe file operations with rollback:
source lib/atomic.sh
# Atomic write - temp file then rename, prevents partial writes
atomic_write "/important/file" "content"
# Checkpoint before risky operations
file_checkpoint "/config/file"
# Rollback if something goes wrong
file_rollback "/config/file"# GOOD: Validate before use
validate_path_safe "$user_path" "/allowed" || exit 1
validate_int "$user_count" 1 100 || exit 1
# BAD: Direct use of untrusted input
cd "$user_path" # Path traversal risk# GOOD: Safe dispatch
agent_safe_exec "ls" "-la" "$validated_path"
# BAD: String concatenation
eval "ls -la $user_input" # Command injection# GOOD: Structured error handling
if ! result=$(some_operation 2>&1); then
output_error "E_OPERATION_FAILED" "Operation failed" "Check permissions"
exit 1
fi
# BAD: Ignoring errors
some_operation || true # Silent failure# GOOD: Safe to retry
ensure_dir "/path/to/dir"
ensure_file "/path/to/file" "content"
# BAD: Fails on retry
mkdir "/path/to/dir" # Fails if exists# Enable audit logging
export AGENT_AUDIT_LOG="/var/log/agent_audit.log"
# Operations are automatically logged
agent_safe_exec "chmod" "755" "/path/to/script"
# Logged: [timestamp] EXEC chmod 755 /path/to/script -> successMAINFRAME minimizes but cannot completely eliminate eval. Current eval usage:
| Location | Purpose | Mitigation |
|---|---|---|
cli.sh |
Dynamic function dispatch | Validated command names only |
template.sh |
Variable expansion | Sandboxed context |
We actively work to eliminate or sandbox remaining eval usage.
Some operations have inherent TOCTOU windows:
- File existence checks before writes
- Lock acquisition
Use atomic operations (atomic_write, with_lock) where possible.
We gratefully acknowledge security researchers who help keep MAINFRAME safe:
No acknowledgments yet - be the first!
MAINFRAME: Building for a safe and accurate agentic future.