Consuloji: Deep Dives into Overseas AI日本語

Physical Containment for Autonomous AI: Inside Claude Code v2.1.325 Permission Hardening, Code Mode Synthesis, and Kernel Boundaries

Published: November 14, 2026

Listen or watch on YouTube

A technical analysis of Anthropic’s transition from unprompted sandbox Bash execution to mandatory permission gates, multi-tool JavaScript synthesis via Code Mode, 8x token reduction in code-driven loops, and multi-tier OS containment.

Japanese Edition: Read the original Japanese article on Substack

Video Episode (Japanese Audio): Watch on YouTube

Disclaimer: This publication provides objective technical, architectural, and security analysis. It does not constitute commercial endorsement or investment advice.


1. Introduction: Bridging Autonomous Agency and Kernel-Level Containment

Across modern software engineering organizations and cloud infrastructure teams, the deployment of autonomous coding agents capable of executing commands in host terminals, refactoring legacy codebases, running test suites, and orchestrating deployments has transitioned from experimental curiosity to daily standard practice. Systems such as Anthropic’s Claude Code operate directly within developer environments, autonomously traversing directories, inspecting ASTs, modifying source files, and executing shell workflows.

However, engineering leadership and enterprise security architects face a profound systemic dilemma: how to empower autonomous agents with operational agency without exposing mission-critical production systems, source repositories, and sensitive credentials to irreversible destruction.

Regardless of how sophisticated an underlying frontier reasoning model appears, the statistical nature of generative token prediction guarantees that the probability of error is non-zero. When an autonomous agent encounters hallucinated paths, ambiguous instructions, indirect prompt injections embedded within third-party dependencies, or relative directory misattributions following shell commands, natural language guardrails evaporate. An inadvertent recursive deletion command (rm -rf) or an exfiltration routine targeting .env files, SSH private keys (~/.ssh), and cloud credentials (~/.aws, ~/.azure) cannot be reliably prevented through conversational prompting alone.

On November 13, 2026, Anthropic instituted a watershed architectural revision with the release of Claude Code v2.1.325: turning off the unprompted execution of sandboxed Bash commands by default. Concurrently, version 2.1.323 introduced Code Mode, an execution model where the AI synthesizes JavaScript programs to chain and parallelize multiple tool calls in a single round-trip. Simultaneously, the Model Context Protocol (MCP) steering group drafted out-of-band HTTPS file transport specifications (io.modelcontextprotocol/files), while empirical benchmarks from the open-source Swamp Project demonstrated an 89% reduction (8.8-fold compression) in token consumption when code governs orchestration loops.

Together, these synchronized developments mark a paradigm shift: agent governance has migrated away from fragile turn-by-turn chat prompting toward multi-layered physical defense, combining programmatic tool synthesis with deterministic OS kernel containment.

Slide 01: Physical Containment and Code Synthesis Overview


2. Architectural Philosophy: The Obsolescence of Scaffolding

Boris Cherny’s Warning on Scaffolding vs. Raw Intelligence

When designing autonomous agent workflows, software engineers frequently invest hundreds of hours constructing complex scaffolding: intricate prompt chains, elaborate wrapper classes, custom JSON-RPC routers, and hand-tuned decision state machines.

In an in-depth interview broadcast on February 17, 2026, on Y Combinator’s official program “The Lightcone,” Boris Cherny, the creator of Claude Code at Anthropic, provided a remarkably candid assessment regarding the longevity of external scaffolding:

“You can build for the model and then you can build scaffolding around the model in order to improve performance a little bit, and depending on the domain you can improve performance maybe 10 to 20% something like that, and then essentially the gain is wiped out with the next model. You either rebuild the scaffolding or you just wait for the next model and get that performance for free.”

Cherny revealed that Claude Code’s internal codebase reflects this rapid obsolescence:

  • Not a single line of code authored six months prior survived in the active production codebase.
  • Tools and operational primitives are aggressively un-shipped and replaced on a multi-week cadence.
  • Engineering effort focuses on observing how frontier models naturally interact with tools and streamlining their ergonomics, rather than constraining them within rigid abstractions.

Ergonomic Tooling vs. Physical Isolation

Cherny articulated the foundational rule of agent tool design:

“The way you don’t do it is you put it in a box and you’re like ‘here’s the API, here’s how you interact with me, and here’s how you interact with the world.’ The way you do it is you see what tools it wants to use, you see what it’s trying to do, and you enable that the same way that you do for your users.”

However, Cherny drew a decisive boundary between developer tooling ergonomics and execution safety. When developing desktop and terminal automation capabilities for non-technical users and enterprise workloads, software guardrails alone proved entirely inadequate:

  • Execution must occur inside isolated virtual machines (VMs) or kernel-enforced sandboxes.
  • Deterministic deletion protection mechanisms must interlock with write operations.
  • Explicit human-in-the-loop permission prompts must gate destructive operations.

The overarching insight is clear: while cognitive tool use should adapt flexibly to model intelligence, filesystem and network containment must be delegated strictly to deterministic kernel infrastructure.

Slide 02: Boris Cherny on Scaffolding vs Model Capability


3. Technical Hardening: Default Gating in Claude Code v2.1.325

Inverting the Default: autoAllowBashIfSandboxed

Prior to version 2.1.325, Claude Code operated under a design pattern common across developer tooling: once an operator enabled the operating system sandbox (via macOS Seatbelt or Linux bubblewrap), commands executed within that sandboxed subshell were automatically permitted without interactive confirmation prompts. The operating assumption was that the sandbox boundary itself provided sufficient safety.

Version 2.1.325 completely inverted this behavior. By default, sandboxed Bash commands now require explicit interactive user approval, exactly like unsandboxed commands. Autonomous execution without interactive prompts is treated as an exceptional posture requiring explicit opt-in configuration:

{
  "sandbox": {
    "autoAllowBashIfSandboxed": true
  }
}

In enterprise environments utilizing centrally managed settings hierarchies (managed-settings.json), this property is enforced only when originating from the highest-priority corporate administrative source, preventing local developer overrides from accidentally lowering security gates.

Furthermore, version 2.1.325 reinforced guardrails around autonomous loops and scheduled routines. When periodic tasks or /loop sessions invoke skills declaring allowed-tools or custom hooks, the runtime mandates prior human authorization before granting operational access.

Slide 03: Permission Hardening and Default Prompting in v2.1.325


4. Forensic Analysis: Six Critical Permission Bypass Vulnerabilities Resolved

The necessity of kernel-level containment is underscored by six severe permission bypass vectors remediated in Claude Code v2.1.325. Each vulnerability demonstrates how conversational or application-layer permission checks fail under edge conditions:

Vulnerability Vector Pre-Fix Behavior & Exploitation Mechanism v2.1.325 Remediation & Enforcement
Compound Bash Commands Chained commands utilizing semicolons (;), logical operators (&&, `
Directory Traversal Invalidation When an agent executed cd <subdir>, relative permission rules (e.g., deny ./.env) failed to resolve, exposing sensitive parent or child files. Canonical absolute path resolution tracks dynamic working directory transitions, ensuring path-based deny rules persist regardless of cd state.
Asymmetric Write on Read-Denied Paths Files explicitly marked with deny policies for the Read tool could still be modified, corrupted, or overwritten via Write or Edit tools. Enforced strict access symmetry: any path denied for read operations is automatically and immutably blocked across all file modification primitives.
Checkpoint Disclosure Sandboxed processes could traverse parent settings directories to inspect snapshot checkpoints, exposing prior code states and secrets. Strict kernel filesystem isolation namespaces block sandboxed child processes from accessing host configuration trees and version control metadata.
Settings Misattribution When invoked from nested subdirectories, the runtime misidentified local repository configuration boundaries, loading unintended .claude/settings.local.json files. Scoping hierarchy strictly verifies repository root boundaries via Git anchoring before loading local configuration overlays.
Binary Identity Mismatch Custom allow rules targeting specific binary names could be spoofed by colocated executables or PATH manipulations matching broad naming patterns. Cryptographic hashing and canonical path verification validate binary identity prior to rule matching.

The relative path invalidation vulnerability (cd evading .env protection) and asymmetric write vulnerability (overwriting files that cannot be read) represent classic architectural blindspots. Relying on application-level filtering without continuous canonical path resolution creates immediate compromise vectors.

Slide 04: Permission Bypass Vulnerabilities and Remediations


5. Code Mode: High-Efficiency Tool Synthesis via JavaScript

Moving from Conversational Turn-Taking to Programmatic Synthesis

Introduced in version 2.1.323 under the opt-in environment variable CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1, Code Mode fundamentally restructures how autonomous agents orchestrate multi-tool workflows.

Under legacy agent paradigms, multi-step tasks require sequential JSON-RPC round-trips:

  1. Agent emits tool call JSON (e.g., GlobTool).
  2. Client executes tool and returns file list.
  3. Agent analyzes list and emits second tool call JSON (e.g., ReadFile).
  4. Client returns file content.
  5. Agent emits shell test execution JSON (e.g., BashTool).

This conversational ping-pong accumulates massive prompt history, multiplies network latency, and rapidly exhausts model context limits.

flowchart TD
    subgraph Traditional ["Legacy Multi-Turn Architecture"]
        M1["Frontier Model"] <-->|"Turn 1: GlobTool Request / Response"| C1["Host Runtime"]
        M1 <-->|"Turn 2: ReadFile Request / Response"| C1
        M1 <-->|"Turn 3: Test Execution Request / Response"| C1
    end

    subgraph CodeMode ["Code Mode Programmatic Synthesis"]
        M2["Frontier Model"] -->|"Synthesizes Single JS Script / (Parallel Glob + Filter + Transform)"| REPL["Sandboxed REPL Engine"]
        REPL -->|"Aggregated Structured Output"| M2
    end

In Code Mode, the model synthesizes a complete JavaScript script executed inside an internal REPL tool. The script programmatically invokes APIs, filters results in memory, branches conditionally, and returns a single consolidated output back to the model.

Boundary Limitations of Auto-Mode Classifiers

Anthropic’s documentation explicitly highlights critical security boundaries when operating in Code Mode:

  1. Invisibility of Runtime Dynamic Variables:
    • The Auto-mode classifier inspects only the static JavaScript source text prior to execution.
    • Dynamic values resolved at runtime—such as file paths returned by an external API or constructed via string concatenation—are invisible to pre-execution inspection.
  2. Mandatory Defense-in-Depth:
    • Critical resource boundaries cannot rely on auto-classifiers. Organizations must implement static deny/ask configuration rules.
    • Operators should implement deterministic PreToolUse hooks that inspect tool_input.code via regular expressions to block unauthorized system calls.
  3. Enterprise Compliance Exclusions:
    • Code Mode is currently unavailable in environments subject to strict compliance constraints, including Amazon Bedrock, Google Cloud Agent Platform, Microsoft Foundry, proxy gateways, HIPAA-compliant endpoints, and Zero Data Retention (ZDR) profiles.

Slide 05: Code Mode JavaScript Synthesis vs Turn-Taking


6. Empirical Validation: The Swamp Project Benchmark

Quantitative Metrics: An 8.8x Reduction in Token Consumption

The architectural superiority of code-driven orchestration over conversational multi-turn agent loops was quantitatively demonstrated by empirical benchmarks from the open-source Swamp Project.

In an exhaustive comparative trial evaluating automated, iterative code review workflows across complex multi-file pull requests, researchers contrasted a conversational multi-agent loop against a code-governed loop (Swamp):

Performance Dimension Conversational Agent Loop (Codex Paradigm) Code-Governed Loop (Swamp Architecture) Quantitative Delta
Token Consumption ~4,600,000 tokens ~506,000 tokens 89% Reduction (8.8x compression)
Agent Instances Invoked 23 agents 3 agents 87% Reduction
Total Task Duration 12.8 minutes 6.6 minutes 48% Speedup (2x faster)

Deconstructing Quadratic Context Bloat

When an autonomous agent executes a loop through conversation, each iteration appends system messages, tool parameters, raw CLI outputs, and reasoning traces to the conversational context. The model reprocesses this accumulating history on every single turn, creating quadratic ($O(N^2)$) growth in token processing costs.

By offloading state tracking, iteration counters, and error-handling branches into deterministic JavaScript or Python scripts, the context window remains pristine. The frontier reasoning model is summoned exclusively at high-leverage decision nodes—such as semantic diff evaluation or vulnerability classification—slashing operating expenditures while halving execution latency.

Slide 06: Quantitative Benchmark: 8x Token Reduction in Swamp


7. OS Sandboxing Boundaries and Out-of-Band Data Transport

Physical Limits of OS-Level Sandboxing

While OS-level sandboxing (macOS Seatbelt and Linux bubblewrap) provides robust process isolation, security architects must understand the exact perimeter boundaries documented by Anthropic:

graph TD
    subgraph HostOS ["Host Operating System (Unconfined Direct Execution)"]
        Builtin["Built-in Tools<br>(Read / Edit / Write / WebFetch)"]
        LocalMCP["Local MCP Servers"]
        Hooks["Custom Hooks / Extensions"]
        Proxy["Network Proxy<br>(Evaluates Hostname Only / No TLS Decryption)"]
    end

    subgraph SandboxedEnv ["OS Sandbox Perimeter (Seatbelt / bubblewrap)"]
        Bash["Bash / Shell Commands"]
        Subprocess["Spawned Child Subprocesses"]
    end

    Builtin -.->|"Executes directly on host"| HostOS
    LocalMCP -.->|"Executes outside sandbox"| HostOS
    Bash -->|"Contained by kernel syscall filters"| SandboxedEnv
  1. Host-Level Tool Execution:
    • The OS sandbox confines only shell processes (Bash) and their direct child processes.
    • Built-in primitives (Read, Edit, Write, WebFetch), local Model Context Protocol (MCP) servers, custom hooks, and shell extensions execute directly on the host operating system. A compromised MCP server operates with full host user permissions.
  2. Network Proxy Blindspots:
    • Standard transparent HTTP/SOCKS proxies evaluate only client-declared SNI hostnames. Without TLS decryption and deep packet inspection, encrypted exfiltration channels remain vulnerable to domain fronting.
  3. Platform Availability:
    • Native Windows environments lack kernel sandbox support, requiring WSL2 or virtual containerization to establish equivalent guarantees.

MCP Out-of-Band File Transfers (io.modelcontextprotocol/files)

To solve the dual challenges of context window exhaustion and data leakage during large-payload processing, the Model Context Protocol governance group drafted the Out-of-Band File Transfer Extension (io.modelcontextprotocol/files).

Under legacy JSON-RPC workflows, transferring large documents (PDFs, multi-gigabyte log files, binaries) requires Base64 encoding payloads directly into prompt context, flooding token budgets and exposing sensitive raw data to the model.

sequenceDiagram
    autonumber
    participant Client as MCP Client / Coding Agent
    participant Server as MCP Tool Server
    participant Storage as Cloud Object Storage (S3 / GCS / R2)

    Client->>Server: Request file analysis (Metadata only: path, size)
    Server->>Client: Return upload_required + Pre-signed URL + requestState
    Note over Client,Storage: Direct HTTPS stream bypasses LLM context & JSON-RPC
    Client->>Storage: Direct HTTPS PUT payload (credentials: omit)
    Client->>Server: Notify upload complete with requestState proof
    Server->>Client: Return concise analytical summary

The architectural security properties of this protocol extension include:

  • Zero Context Contamination: File content streams directly between client storage and cloud endpoints via pre-signed HTTPS URLs, completely bypassing the model’s conversational context.
  • Credential Segregation: The credentials: omit directive prevents leakage of primary MCP bearer tokens or session cookies to third-party storage hosts.
  • Cryptographic State Integrity: Mutual verification via cryptographically signed requestState tokens guarantees payload provenance and prevents replay or tampering attacks.

Slide 07: OS Sandbox Scope and Out-of-Band File Transfers


8. Conclusion: Enterprise Implementation Playbook

The technical advances embodied in Claude Code v2.1.325, Code Mode, and the Model Context Protocol lead to a definitive architectural conclusion: enterprise security for autonomous development cannot rely on conversational compliance or model self-policing; it demands deterministic physical boundaries enforced by operating system kernels and cryptographic protocols.

Engineering organizations deploying autonomous agents should immediately enforce three operational directives:

Action 1: Mandatory Upgrade to v2.1.325+ and Sandbox Configuration Auditing

  • Enforce company-wide upgrades to Claude Code v2.1.325 or later across all developer workstations and CI runners.
  • Validate local sandbox integrity by running /sandbox and claude doctor in terminal sessions.
  • In managed-settings.json, explicitly configure sandbox.credentials to deny read and write access to sensitive paths:
    {
      "sandbox": {
        "denyPaths": [
          "~/.ssh",
          "~/.aws",
          "~/.azure",
          "~/.gnupg",
          "**/.env",
          "**/.env.*"
        ]
      }
    }
    

Action 2: Multi-Layered Defense-in-Depth for Code Mode Adoption

  • When enabling Code Mode (CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1), do not rely exclusively on the Auto-mode classifier.
  • Maintain comprehensive static deny policies in .claude/settings.json that apply symmetrically across all filesystem modification tools.
  • Deploy a deterministic PreToolUse hook script that inspects the raw code string within tool_input.code, rejecting dangerous invocations (e.g., child process spawning, socket binding, or obfuscated eval patterns) before the REPL executes.

Action 3: Architectural Migration to Out-of-Band Data Transport

  • Transition internal MCP servers and custom agent extensions away from inline Base64 data streaming.
  • Implement pre-signed HTTPS URL upload and download patterns for all artifacts exceeding 64KB, passing only concise analytical summaries and cryptographic checksums to the model context.
  • Audit network boundaries using containerized egress filters to restrict outbound connections exclusively to verified domain allowlists.

By decoupling creative reasoning from unconstrained execution, organizations can capture the transformative productivity of autonomous coding agents while maintaining an ironclad, kernel-enforced perimeter.

Slide 08: Three Architectural Directives for Enterprise Deployment

Back to articles