proc_jail
Process execution guard for agentic systems.
proc_jail provides a safe wrapper around process spawning, enforcing deterministic bounds on process execution to prevent command injection, unauthorized binary execution, and resource abuse.
Features
- No shell interpretation: Commands use argv-style execution, not shell strings
- Allowlist-only: Explicit enumeration of permitted binaries and flags
- Fail closed: Any error or ambiguity results in denial
- Resource limits: Timeout, stdout/stderr byte limits
- Double-dash injection: Automatic
--insertion to prevent flag injection - Python and Rust APIs: Native bindings for both languages
Quick Start (Python)
# Define a policy
=
# Create and execute a request
=
=
Quick Start (Rust)
[]
= "0.1"
= { = "1", = ["rt-multi-thread", "macros"] }
use ;
use Duration;
async
Why proc_jail?
Traditional process spawning is dangerous in agentic systems:
# VULNERABLE: Shell injection
# Attacker sets: query = "x'; rm -rf / #"
# Executes: grep 'x'; rm -rf / #' file.txt
With proc_jail, the same attack becomes harmless:
=
=
# If query = "x'; rm -rf / #"
# Executes: grep "x'; rm -rf / #" file.txt
# The injection is just a literal string, not interpreted
Policies
Binary Allowlist
Only explicitly allowed binaries can be executed:
# ...
Argument Rules
Every binary requires explicit argument rules:
Subcommand Pinning
Pin allowed subcommands for tools like git:
Risky Binary Detection
Shells, interpreters, and privilege escalation tools are blocked by default:
# Even if allowed, bash is denied by default
# Error: BinRiskyDenied
# Opt-in with explicit acknowledgment
# ...
Environment Control
By default, no environment variables are passed. Dangerous variables (LD_PRELOAD, PYTHONPATH, etc.) are always stripped.
Resource Limits
# seconds
# 10 MB
# 1 MB
Platform Support
Unix only (Linux, macOS). Windows is not supported because CreateProcess passes arguments as a single string that each program parses differently, making injection prevention impossible to guarantee. See docs/windows.md for details.
Related Projects
| Project | Description | PyPI/Crates.io |
|---|---|---|
| path_jail | Path traversal prevention | |
| url_jail | SSRF-safe URL validation | |
| safe_unzip | Zip Slip and zip bomb prevention | |
| tenuo | Capability-based authorization for AI agents |
Integration with Tenuo
proc_jail provides the execution layer, while Tenuo provides cryptographic authorization. Together they offer defense in depth:
# proc_jail handles the safe execution
# Tenuo handles the authorization (who can call which tools)
"""Execute grep with proc_jail protection."""
=
# Even if user_query = "'; rm -rf / #", it's treated as a literal string
=
=
return
Why both?
- Tenuo: Cryptographic proof the agent is authorized for this tool
- proc_jail: Prevents command injection even if the agent is compromised
Documentation
- SECURITY.md - Security properties, limitations, threat model
- CHANGELOG.md - Version history
- docs/windows.md - Why Windows is not supported
- docs/risky-binaries.md - Blocked binary categories
- docs/design-decisions.md - Rationale for key decisions
Repository Structure
proc_jail/
├── src/ # Rust library source
├── tests/ # Rust integration tests
├── docs/ # Documentation
├── python/ # Python bindings (PyO3)
│ ├── src/ # Rust binding code
│ └── proc_jail/ # Python package
└── ...
Development
# Build Rust library
# Run tests
# Build Python bindings
License
MIT OR Apache-2.0