{"slug": "enclawed-code-how-deterministic-security-layers-harden-claude-code-agent", "title": "Enclawed Code: How Deterministic Security Layers Harden Claude Code Agent Execution", "summary": "An open-source project called Enclawed Code wraps the Claude Code CLI in a deterministic security layer that classifies every tool call as reversible or not before execution, running reversible actions in a sandbox and requiring approval for network calls, config changes, package installs and destructive file operations. A companion paper (DOI: 10.5281/zenodo.24524917) reports zero harmful actions passed and zero harmless actions blocked across 15,021 real tool calls, 7.7x fewer approval prompts than Claude Code's default permission mode, and 11 attacks from compromised hosts all blocked when paired with Enclaweder's hardware-backed attestation.", "body_md": "Enclawed Code wraps Claude Code in a deterministic security layer that checks every action before execution. The core insight: stop asking the LLM to judge safety. Instead, enforce boundaries at the infrastructure layer using a fixed rule that asks one question: can this action be undone?\n\nThe project ships as open source with a companion research paper showing zero harmful actions passed and zero harmless actions blocked across 15,021 real tool calls. It also claims 7.7x fewer approval prompts than Claude Code's default permission mode.\n\nClaude Code and similar agents execute shell commands, edit files, and call tools on your local machine. They read context along the way: README files, web pages, tool output. Anyone can plant instructions in those contexts.\n\nTraditional safeguards rely on the LLM to recognize malicious intent. This creates three failure modes:\n\nEnclawed Code moves the security boundary outside the model. It intercepts every action before execution and applies a deterministic rule. The LLM never sees the security decision.\n\nEnclawed Code runs as a wrapper around the standard Claude Code CLI. You type `ecwcode` instead of `claude`. The security layer sits between the agent's action planner and the host system.\n\nThe sealed space is a sandboxed environment where read operations, read-only commands, file edits (with automatic versioning), and tests execute without approval.\n\n| Action Type | Reversible? | Execution Path | \n|---|---|---|\n| File read | Yes | Runs in sealed space | \n| Read-only shell command | Yes | Runs in sealed space | \n| File edit | Yes | Runs after old version saved | \n| Test execution | Yes | Runs in isolated environment | \n| Network call | No | Requires approval | \n| System configuration change | No | Requires approval | \n| Package installation | No | Requires approval | \n| Destructive file operation | No | Requires approval | \n\nThe reversibility rule is not configurable by the LLM. It is a fixed policy enforced at the infrastructure layer.\n\nEnclawed Code uses three mechanisms to enforce boundaries:\n\nEvery tool call is parsed and classified before execution. The system extracts the operation type, target resources, and scope. This happens outside the LLM's control.\n\n``` python\n# Conceptual flow (not actual Enclawed Code source)\ndef intercept_action(action):\n    parsed = parse_tool_call(action)\n\n    if is_reversible(parsed):\n        old_state = snapshot_affected_resources(parsed)\n        result = execute_in_sealed_space(action)\n        log_action(action, old_state, result)\n        return result\n    else:\n        approval_code = generate_approval_code()\n        user_input = prompt_user(action, approval_code)\n        if user_input == approval_code:\n            result = execute_with_full_privileges(action)\n            log_action(action, None, result)\n            return result\n        else:\n            raise SecurityViolation(\"Action blocked by user\")\n```\n\nReversible actions run in isolated environments. File system changes are copy-on-write. Network access is restricted. The sealed space is torn down after execution, but state changes (like edited files) are committed back to the host with full audit trails.\n\nWhen paired with Enclaweder, the security key unlock uses hardware-backed attestation. This prevents a compromised host from bypassing the approval flow. The research paper reports 11 attacks from compromised computers, all blocked with Enclaweder present.\n\nThe companion paper (DOI: 10.5281/zenodo.24524917) tested three Claude models across four permission modes with 4,350 live runs. Key findings:\n\nThe benchmark does not test performance overhead. The paper focuses on security effectiveness, not latency.\n\nEnclawed Code is a local wrapper. It does not require cloud infrastructure or API changes. You install it on the same machine where you run Claude Code.\n\nThis makes it suitable for:\n\nIt is not suitable for:\n\nEnclawed Code preserves session state across security violations. If an action is blocked, the agent's conversation history, file snapshots, and sealed space state remain intact. The user can resume the session after reviewing the blocked action.\n\nThis is critical for long-running sessions where a single blocked action should not discard hours of work.\n\nThe current implementation logs every action, approval decision, and state snapshot. However, it does not expose metrics for:\n\nThese gaps make it hard to predict performance impact in production.\n\nThe fixed rule might incorrectly classify an action as reversible. For example, a file edit that triggers a build process with side effects (like uploading artifacts) would run without approval.\n\nMitigation: The sealed space restricts network access, so most side effects are contained. But this is not foolproof.\n\nIf the agent generates many irreversible actions, users still face approval prompts. The 7.7x reduction helps, but it does not eliminate the problem.\n\nMitigation: Tune the agent's system prompt to prefer reversible operations. This is a prompt engineering task, not a security fix.\n\nWithout Enclaweder, a compromised host can bypass the security layer. The approval prompt is just a UI element. An attacker with root access can modify the binary to skip checks.\n\nMitigation: Deploy Enclaweder for hardware-backed attestation. This adds cost and complexity.\n\n**Use Enclawed Code when:**\n\n**Avoid it when:**\n\nThe core idea is sound: move security decisions outside the LLM. The implementation is production-ready for local workflows but needs cloud deployment support and better observability before it scales to multi-tenant or high-throughput scenarios.", "url": "https://wpnews.pro/news/enclawed-code-how-deterministic-security-layers-harden-claude-code-agent", "canonical_source": "https://dev.to/mech_app_ai/enclawed-code-how-deterministic-security-layers-harden-claude-code-agent-execution-1hlo", "published_at": "2026-11-26 20:06:31+00:00", "updated_at": "2026-11-26 20:14:58.791565+00:00", "lang": "en", "topics": ["ai-agents", "ai-safety", "ai-tools", "developer-tools"], "entities": ["Enclawed Code", "Claude Code", "Anthropic", "Enclaweder"], "also_reported_by": [], "takeaway": "Enforcing a fixed reversibility rule outside the model — sandboxing reads, edits and tests while gating network, config, install and destructive operations behind approval — passed zero harmful actions and blocked zero harmless ones across 15,021 tool calls with 7.7x fewer prompts.", "recommendation": {"advice": "Enforce agent safety with a deterministic reversibility check outside the LLM: sandbox reversible actions and require approval codes for network, config, install and destructive operations.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/enclawed-code-how-deterministic-security-layers-harden-claude-code-agent", "markdown": "https://wpnews.pro/news/enclawed-code-how-deterministic-security-layers-harden-claude-code-agent.md", "text": "https://wpnews.pro/news/enclawed-code-how-deterministic-security-layers-harden-claude-code-agent.txt", "jsonld": "https://wpnews.pro/news/enclawed-code-how-deterministic-security-layers-harden-claude-code-agent.jsonld"}}