Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:1ay1 Agentty sandbox provenance

From Leeroopedia
Knowledge Sources
Domains Security, Provenance_Tracking
Last Updated 2026-10-28 12:00 GMT

Overview

Concrete provenance tracking system that records which files the agent wrote during a turn and intersects them with host-trusted execution paths to detect trust-handoff escape attempts.

Description

The sandbox_provenance module (in `domain/sandbox_provenance.hpp`) implements the defense against the sandbox escape class identified by Pillar Security (July 2026): the agent writes a file that a trusted component outside the sandbox later runs. The agent never breaks the sandbox; it moves the boundary.

Three parts:

  1. Provenance records: every path the sandbox writes is recorded, per turn, with the command that wrote it. This is the provenance record — a fact about which writes were the agent's own.
  2. Host-trusted set: paths the host later trusts (hooks.json, .vscode/tasks.json, .git/config, venv interpreters, .envrc) are a known set.
  3. The intersection is the alarm: an agent-authored file that a host component will execute escalates from "approve this hash" to a named warning — and by default, refuses.

Usage

  • During sandbox execution: record every write path in the provenance set.
  • After tool execution: intersect agent-written paths with the host-trusted set and apply the HandoffPolicy.

Code Reference

Source Location

  • Repository: agentty
  • File: include/agentty/domain/sandbox_provenance.hpp

Signature

namespace agentty::sandbox_cfg::provenance {

// A record of one agent-written file: path, turn, command.
struct Record {
    std::string path;
    std::string turn_id;
    std::string command;
    std::chrono::steady_clock::time_point written_at;
};

// The host-trusted execution paths — known set of files the
// host runs that the agent could write to escape the sandbox.
// (hooks.json, .vscode/tasks.json, .git/config, venv interpreters, .envrc)
[[nodiscard]] bool is_host_trusted(std::string_view path) noexcept;

// Record an agent write (called by the sandbox spawn path).
void record_write(const std::string& path, const std::string& turn_id,
                  const std::string& command);

// All paths the agent wrote in a given turn.
[[nodiscard]] std::vector<Record> writes_for_turn(
    const std::string& turn_id) const;

// The intersection: agent-written files the host will execute.
[[nodiscard]] std::vector<std::string> dangerous_writes(
    const std::string& turn_id) const;

} // namespace agentty::sandbox_cfg::provenance

Import

#include "agentty/domain/sandbox_provenance.hpp"

I/O Contract

Inputs

Name Type Required Description
path string Yes File path the agent wrote
turn_id string Yes Turn identifier
command string Yes Command that wrote the file

Outputs

Name Type Description
dangerous_writes vector<string> Agent-written paths that intersect host-trusted set

Usage Examples

Detecting a Trust Handoff

#include "agentty/domain/sandbox_provenance.hpp"
using namespace agentty::sandbox_cfg::provenance;

// After a turn where the agent ran bash commands:
// The sandbox spawn path recorded every write:
//   record_write(".claude/hooks.json", turn_id, "echo '...' > ...");

// Check for dangerous intersections:
auto dangerous = provenance.dangerous_writes(turn_id);
if (!dangerous.empty()) {
    // Agent wrote a file the host will execute!
    for (const auto& path : dangerous) {
        if (cfg.handoff == HandoffPolicy::Refuse) {
            refuse("agent wrote host-trusted file: " + path);
        } else {
            warn("agent wrote host-trusted file: " + path);
        }
    }
}

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment