agentsh

2026-05-15 · source · source ↗ · raw capture · wiki page

agentsh is a policy-enforced execution gateway that sits beneath AI agents and tooling, intercepting file, network, process, and signal activity — including entire subprocess trees. It enforces user-defined policies in real time and produces structured audit events.

Repository: github.com/canyonroad/agentsh

Architecture

Client-server model:

Core Features

  1. Per-operation policy decisions: allow, deny, approve (human OK), audit, soft_delete, and redirect
  2. Full I/O visibility across file operations, network connects + DNS, process start/exit, PTY activity, signal send/block, LLM API requests, and declared HTTP services
  3. Two output modes: human-friendly shell output and compact JSON for agents/tools
  4. Session Reports: Markdown summaries with decision breakdowns, findings detection, and activity timelines
  5. Workspace Checkpoints: Snapshots for recovery before risky operations, with diff preview, dry-run rollback, and auto-checkpointing
  6. LLM Proxy with DLP: Embedded proxy intercepting LLM requests, supporting automatic routing via environment variable injection, PII redaction, custom DLP patterns, token usage tracking, and full audit trails
  7. Policy Generation: Profile-then-lock workflow that generates restrictive policies from observed session behavior, supporting CI/CD lockdown and agent sandboxing
  8. MCP Security: Tool whitelisting, version pinning (rug pull detection), cross-server exfiltration blocking, and token bucket rate limiting

Redirect & Steering

The redirect capability is a distinguishing feature. Rather than simply denying an action (which may cause agents to brute-force workarounds), agentsh can swap the command or path transparently.

This steering approach keeps agents on desired paths and "reducing wasted retries" by avoiding denial errors that prompt alternative attempts.

Policy Engine

Evaluation: First matching rule wins. Rules live in named policies; sessions select a policy by name.

Scopes covered: file operations, commands, environment variables, network (DNS + connect), PTY/session settings, and declared HTTP services.

Environment policy: Agents can enforce allowlists and denylists on environment variables, with byte/key count limits, secret stripping, and an env_block_iteration flag that prevents enumeration via LD_PRELOAD injection. Operator-trusted env_inject values bypass all filtering.

Integrity: Optional policies.manifest_path can specify a SHA256 manifest to verify policy files at load time.

Policy packs: Three opinionated configurations: - dev-safe.yaml — local development with approvals on deletes - ci-strict.yaml — CI runners, denies outbound network except registries - agent-sandbox.yaml — default-deny + explicit allowlists for untrusted code

Platform Support

Security Modes

Five modes with varying protection levels:

Mode Mechanism Protection
full seccomp + eBPF + FUSE 100%
landlock Landlock + FUSE ~85%
landlock-only Landlock ~80%
minimal (none) ~50%
ptrace SYS_PTRACE ~95%

Authentication & Approval

Multiple auth methods: api_key, oidc (enterprise SSO), hybrid. Human-in-the-loop approval via local_tty prompts, totp authenticator codes, webauthn hardware keys, or a remote API endpoint.

MCP Security

Tool whitelisting, version pinning (rug pull detection), cross-server exfiltration blocking, and token bucket rate limiting. This is a novel addition — MCP-native security controls that most sandboxing solutions don't address.

Integration Patterns

Scaling

Canyon Road offers two platform products: - Beacon: Monitors AI desktop tools (Claude, Cursor, ChatGPT) on endpoints - Watchtower: Control plane with centralized policies, approval routing (Slack/email/SMS), SIEM export, kill switch