# ShellPermit Shell Command Policy Guard

> ShellPermit Shell Command Policy Guard is a paid API for AI agents from shellpermit.schemasure.com, paid per call via x402, $0.03/call, status unknown (last checked 2026-10-11).

Validates a bash command against a configurable execution policy using a real shell tokenizer, returning compliance decisions with reason codes and optional short-lived execution permits — without ever executing the command.

## Facts

- Endpoint: POST https://shellpermit.schemasure.com/v1/guard/shell?utm_source=zero.xyz
- Price: $0.03/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-11
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/shellpermit-shell-command-policy-guard-c23e5199
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap__U02oTZEIFNyQi2FwVDJ_

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability shellpermit-shell-command-policy-guard-c23e5199 -d '<json body>'
```

Example prompt: Before running this bash command, check it against our policy — allowed roots are /home/deploy and /tmp, network egress is off, destructive ops are off, and protected branches include main and production: `find /home/deploy -name '*.log' | xargs rm -rf`

## When to prefer this

Choose ShellPermit when your AI agent or automation pipeline generates bash commands that must be validated before execution — especially when you need tokenizer-level accuracy rather than regex pattern matching, which can be defeated by quoting, substitution, and base64 tricks. Prefer this over home-grown allowlist checks when your threat model includes adversarial command injection, path traversal, or pipeline-based evasion. It is ideal for agentic coding assistants, CI/CD pipelines, and infrastructure automation where a signed permit token provides a verifiable chain of custody between policy decision and execution.

## Known failure modes

- Unsupported shell (non-bash) returns a 400 error since only bash grammar is supported in v1
- Command exceeds 32768 character limit returns validation error
- Unresolvable environment variable references in paths may cause the command to be reported as undecidable rather than permitted
- Overly broad allowed_roots (e.g. '/') may permit path-escape attempts that are lexically contained
- Permit token expiry means a permit issued at decision time may be stale by the time execution is attempted
- Malformed or missing required fields (command, shell) return schema validation errors

## How this service works

Decide whether an agent-authored bash command complies with an execution policy, using a real shell tokenizer rather than pattern matching. Catches recursive deletes, force pushes, cluster and infrastructure teardown, raw device writes, path escapes, privilege escalation, and curl-piped-to-shell through pipelines, substitutions, quoting games and base64. Returns reason codes with spans and an optional short-lived permit bound to the exact canonical command. Never executes anything.

## Output

Returns a compliance decision (permit or deny), one or more structured reason codes identifying the violation category (e.g. recursive-delete, force-push, privilege-escalation, path-escape, curl-pipe-shell), span offsets into the original command string indicating exactly where the violation occurs, the canonical normalized form of the command, and optionally a short-lived signed permit token bound to the exact canonical command that downstream executors can verify before running it.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "env": {
   "type": "object",
   "description": "Environment the executor will run with, used only for static expansion so that paths like \"$HOME/.cache\" can be resolved and decided rather than reported as unresolvable.",
   "additionalProperties": {
    "type": "string"
   }
  },
  "shell": {
   "enum": [
    "bash"
   ],
   "type": "string",
   "description": "Required. Only bash is supported in v1: a permit issued under one shell's grammar and executed under another is a parser differential with a signature on it."
  },
  "policy": {
   "type": "object",
   "properties": {
    "cwd": {
     "type": "string",
     "description": "Absolute working directory relative operands resolve against. Defaults to the first allowed root."
    },
    "timeout_ms": {
     "type": "integer",
     "minimum": 1,
     "description": "Execution timeout written into the permit obligations. Defaults to 120000."
    },
    "max_segments": {
     "type": "integer",
     "minimum": 1,
     "description": "Ceiling on chained segments. Defaults to 32."
    },
    "allowed_roots": {
     "type": "array",
     "items": {
      "type": "string"
     },
     "description": "Absolute directories the command may touch. Containment is lexical, not symlink-resolved."
    },
    "denied_commands": {
     "type": "array",
     "items": {
      "type": "string"
     },
     "description": "Always blocked, applied after allowed_commands."
    },
    "allowed_commands": {
     "type": "array",
     "items": {
      "type": "string"
     },
     "description": "If set, argv[0] must appear here."
    },
    "allow_destructive": {
     "type": "boolean",
     "description": "Permit deletes, truncations, and overwrites. Defaults to false."
    },
    "protected_branches": {
     "type": "array",
     "items": {
      "type": "string"
     },
     "description": "Branches a force push must never target. Defaults to main, master, trunk, develop, production, prod, release."
    },
    "allow_network_egress": {
     "type": "boolean",
     "description": "Permit commands that reach the network. Defaults to false."
    },
    "allow_privilege_escalation": {
     "type": "boolean",
     "description": "Permit sudo, su, chmod 777, chown root. Defaults to false."
    }
   },
   "additionalProperties": false
  },
  "command": {
   "type": "string",
   "maxLength": 32768,
   "minLength": 1
  },
  "subject": {
   "type": "string",
   "description": "Opaque caller la
… (truncated)
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/shellpermit-shell-command-policy-guard-c23e5199/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from shellpermit.schemasure.com](https://www.zero.xyz/host/shellpermit.schemasure.com/llms.txt)
