mech.app
Security

Claw Patrol: How Deno Built a Security Firewall for Production AI Agents

Permission boundaries, audit trails, and destructive-action gates for agents operating on Postgres, Kubernetes, GCP, and GitHub in production.

Source: github.com
Claw Patrol: How Deno Built a Security Firewall for Production AI Agents

An agent with unrestricted access to production infrastructure is a blast radius waiting to happen. Deno runs OpenClaw agents in production to respond to PagerDuty alerts. When an alert fires, the agent investigates the cause and attempts fixes. This requires real credentials for Postgres, Kubernetes, GCP, ClickHouse, and GitHub.

Claw Patrol is Deno’s answer, released as a Show HN post that drew 101 points and 28 comments. It sits between the agent and production systems, enforcing permission boundaries, logging every action, and blocking destructive operations until a human approves them. Unlike sandboxing or rate limiting, Claw Patrol is a stateful firewall that understands tool calls and applies policy before credentials are handed over.

Architecture: Proxy Layer with Policy Engine

Claw Patrol intercepts tool calls before they reach production APIs. The agent does not hold credentials directly. Instead, it sends tool invocations to the Claw Patrol proxy, which evaluates each request against a policy file and decides whether to execute, block, or escalate.

The agent receives a PagerDuty alert and decides to run a kubectl command. It calls the kubectl tool through Claw Patrol’s API. Claw Patrol checks the policy: is this command allowed? Is it destructive? If allowed, Claw Patrol executes the command using stored credentials and returns the result. If destructive (e.g., kubectl delete), Claw Patrol blocks execution and sends a notification to the on-call engineer. The human reviews the request and approves or denies. If approved, Claw Patrol executes and logs the action.

Every step is logged with full context: which agent, which tool, which arguments, timestamp, and outcome.

Permission Boundaries: Tool-Level and Argument-Level

According to the Claw Patrol repository, policies are defined using a declarative configuration format. The system supports tool-level allowlists and argument-level pattern matching to identify destructive operations.

A policy configuration typically includes:

  • Tool allowlists (which tools the agent can invoke)
  • Destructive pattern matching (keywords or patterns that trigger human approval)
  • Argument-level constraints (scope limits like specific repositories or read-only database access)
  • Approval requirements (which actions require human sign-off)

For example, you might allow kubectl get commands but require approval for kubectl delete. You could permit SELECT queries on Postgres but block DROP, TRUNCATE, or DELETE statements. GitHub access might be limited to specific repositories, with actions like repository deletion always blocked.

The destructive pattern matching uses substring or regex matching on command arguments. If an agent tries to run kubectl delete pod, the system catches the delete keyword and escalates. You can tune this to your risk tolerance. Some teams allow kubectl delete pod but block kubectl delete namespace.

Audit Trail: Structured Logs and Replay

Every tool call generates a structured log entry with timestamp, agent identifier, tool name, command or API call, policy decision, execution time, and result summary.

For destructive actions that required approval, logs include the approver’s identity and approval timestamp. This creates a complete audit trail showing what the agent did and who authorized each high-risk action.

Logs can be written to a time-series database for analysis. You can replay agent sessions to understand decision paths, audit compliance, or debug failures. The structured format makes it straightforward to build dashboards showing agent activity patterns, approval latency, and policy violations.

Destructive-Action Gates: Human-in-the-Loop

When Claw Patrol blocks a destructive action, it sends a notification to the on-call channel with:

  • The agent’s reasoning (extracted from the agent’s internal context or tool call metadata)
  • The exact command or API call
  • An approval interface

The on-call engineer reviews the request. If they approve, Claw Patrol executes the command and logs the approval. If they deny, the agent receives an error and must find another path.

This creates a human-in-the-loop gate without breaking agent autonomy. The agent can still investigate, query, and propose fixes. It cannot execute irreversible changes without oversight.

Credential Management: Secrets Stay in the Proxy

Agents never see production credentials. Claw Patrol holds them in environment variables or a secrets manager. When a tool call is approved, Claw Patrol injects the credentials at execution time.

This limits the blast radius of a compromised agent. If an attacker gains control of the agent’s process, they can send tool calls to Claw Patrol, but those calls are still subject to policy enforcement and logging. They cannot exfiltrate credentials or bypass the firewall.

The proxy acts as a credential intermediary. For a Postgres query, the agent sends the SQL statement to Claw Patrol, which validates it against policy, injects the database credentials, executes the query, and returns only the results. The agent never touches the connection string or password.

Trade-Offs and Failure Modes

RiskMitigationResidual Exposure
Agent prompt injection tricks Claw Patrol into allowing destructive actionsPolicy uses argument parsing, not natural language. Substring matching on commands.Attacker crafts edge-case commands that pass filters but cause harm (e.g., using synonyms or indirect methods).
Claw Patrol itself is compromisedRun Claw Patrol in a separate security boundary with minimal attack surface. No inbound internet access.If Claw Patrol is compromised, attacker has full production access. Single point of failure.
Human approver is unavailableSet timeout for approval requests. After timeout, deny by default.Agent cannot proceed with destructive actions during off-hours unless policy is relaxed.
Agent learns to avoid destructive keywordsPolicy must evolve with agent behavior. Monitor for suspicious patterns (e.g., agent always uses indirect methods).Adversarial agents probe for policy gaps. Requires ongoing policy tuning and anomaly detection.

The biggest operational risk is approval latency. If the on-call engineer is in a meeting or asleep, the agent stalls. One approach is to allow certain low-risk destructive actions (like restarting a single pod) without approval, while blocking high-risk actions (like deleting a database table).

Deployment Pattern: Sidecar Architecture

A typical deployment runs Claw Patrol as a sidecar container alongside the agent. The agent’s tool definitions point to a local proxy endpoint instead of directly invoking system commands or APIs. The sidecar handles all external communication.

In a Kubernetes environment, this pattern might look like (illustrative example):

apiVersion: v1
kind: Pod
metadata:
  name: openclaw-agent
spec:
  containers:
  - name: agent
    image: deno/openclaw:latest
    env:
    # Agent sends all tool calls to localhost sidecar proxy
    - name: TOOL_PROXY_URL
      value: "http://localhost:8080"
  - name: clawpatrol
    image: deno/clawpatrol:latest
    env:
    - name: POLICY_FILE
      value: "/etc/clawpatrol/policy.yaml"
    - name: NOTIFICATION_WEBHOOK_URL
      valueFrom:
        secretKeyRef:
          name: clawpatrol-secrets
          key: notification-webhook
    volumeMounts:
    - name: policy
      mountPath: /etc/clawpatrol
  volumes:
  - name: policy
    configMap:
      name: clawpatrol-policy

The agent container has no network policies allowing direct access to production APIs. All traffic is routed through the sidecar. This creates a network-level enforcement boundary in addition to the application-level policy checks.

Observability: Metrics and Monitoring

For production deployments, you need visibility into agent behavior and policy enforcement. Recommended metrics include:

  • Tool call counters by tool name and policy decision (allowed, blocked, escalated)
  • Approval latency (time between escalation and human response)
  • Tool execution duration by tool type
  • Policy violation patterns

You can alert on:

  • High rate of blocked calls (possible attack or misconfigured policy)
  • Long approval latency (on-call engineer is unavailable)
  • Spike in destructive actions (agent is misbehaving or policy is too permissive)
  • Unusual tool usage patterns (agent exploring new attack vectors)

The structured logs provide the raw data for these metrics. Export them to your existing observability stack (Prometheus, Datadog, CloudWatch) and build dashboards showing agent activity over time. In Deno’s production deployment, these metrics feed into their existing monitoring infrastructure to track agent behavior alongside traditional application metrics.

Technical Verdict

Claw Patrol is a good fit for:

  • Agents responding to operational alerts (PagerDuty, Datadog, Sentry)
  • Agents performing infrastructure tasks (scaling, restarting services, running diagnostics)
  • Environments where audit trails are a compliance requirement
  • Teams that want to experiment with agent autonomy while maintaining safety boundaries

Claw Patrol is not suitable for:

  • Agents that only need read-only access (use IAM roles with read-only permissions instead)
  • Sandboxed agents in non-production environments (no need for a firewall if nothing requires protection)
  • Teams that cannot commit to maintaining policies as agent behavior evolves (stale policies create false security)
  • Use cases requiring sub-second response times for all agent actions (approval gates add latency)

The key insight is that agent security is not a binary choice between full access and no access. Claw Patrol creates a middle ground where agents can operate autonomously within guardrails, and humans step in only when the risk exceeds the threshold. This is practical security for production agent deployments.

Tags

agentic-ai orchestration infrastructure security

Primary Source

github.com