taintd Documentation

Complete technical guide to agent-taint (deterministic runtime information-flow guard), agent-gate (cryptographically signed repo config gate), and taintd cloud (self-hosted Ed25519 fleet control plane).

1. Install & Harness Matrix

Install the static Rust binary (Linux & macOS, x86_64 / arm64, SHA256-verified) or build from crates.io:

# Prebuilt release binary (recommended)
curl -fsSL https://taintd.dev/install.sh | bash

# Or build from crates.io
cargo install agent-taint
cargo install agent-gate   # optional signed repo config gate

Wire hooks into your coding harness

agent-taint install <harness> installs hooks globally at the user level (not per repository), so launching your harness in any folder is automatically guarded. It also installs the in-harness /taint-setup and /taint-review checklists and runs a short onboarding wizard (pass --no-setup for non-interactive/MDM installs).

HarnessCommandInstalled FilesFail-Closed?
Claude Code agent-taint install claude ~/.claude/settings.json (PreToolUse, PostToolUse, SessionStart) + /taint-setup, /taint-review commands YES Non-zero exit or missing binary exits 2 (block)
Cursor agent-taint install cursor ~/.cursor/hooks.json (preToolUse, postToolUse) YES failClosed: true
VS Code / Copilot agent-taint install vscode ~/.copilot/hooks/agent-taint.json YES Hook deny payload on block
Antigravity agent-taint install agy ~/.gemini/config/plugins/agent-taint/ (native plugin + taint-setup / taint-review skills) YES Native deny / force_ask
OpenCode agent-taint install opencode ~/.config/opencode/plugins/agent-taint.ts YES Throws on non-zero exit or spawn error

Recommended zero-friction rollout

# 1. Start in non-blocking audit/learn mode for a day
agent-taint mode audit

# 2. Discover local stdio MCPs & ~/.ssh/config hosts (read-only)
agent-taint discover

# 3. Review what would have been tainted/blocked & interactively approve
agent-taint review -i

# 4. Flip to blocking enforcement
agent-taint mode enforce

2. How Taint Tracking Works

Instead of scanning prompts with brittle regexes or a second LLM, agent-taint maintains a tiny per-session state file in ~/.cache/agent-taint/sessions/<session-id>.json and enforces deterministic information-flow rules on every tool call in <5ms.

Two-phase hook lifecycle

  1. PostToolUse (agent-taint hook <harness> post) records state transitions after a tool runs:
    • If the tool fetched untrusted external content (web, untrusted MCP, PR/issue read, git fetch/pull, untrusted path/repo), the session is marked tainted = true with timestamp and reason.
    • If the tool read a credential file or secret manager in a clean session, the session is marked secrets_accessed = true.
  2. PreToolUse (agent-taint hook <harness> pre) evaluates every subsequent tool call before execution:
    • Clean session (tainted == false, secrets_accessed == false): normal dev work runs untouched. Self-protection still applies (an agent cannot silently disable hooks, edit policy.json, or clear taint without confirmation).
    • Tainted session (tainted == true): blocks credential reads, vault CLIs, persistence edits, untrusted egress, and obfuscated shell execution. Spawning subagents (Agent, Task, invoke_subagent, swarm, run_workflow) and git push / gh pr|issue require explicit confirmation (Ask) to prevent subagent taint laundering.
    • Reverse trifecta (secrets_accessed == true): even if the session was clean when it read .env or a key, any later untrusted web fetch, untrusted MCP call, or outbound egress to a non-allowlisted host is blocked — stopping secret-first exfiltration chains.
    • Corrupt / unreadable state file: always loads as tainted (fail closed).

Inspecting & clearing session state

agent-taint status                        # list all active sessions & taint/secret flags
agent-taint status <session-id>           # show full taint event history for one session
agent-taint taint <session-id> --reason "pasted external log"
agent-taint clear <session-id>            # clear after manual review
agent-taint clear --all                   # reset all local session states

3. Threat Model & 3 Defense Layers

Prompt injection becomes dangerous when the lethal trifecta converges in one session: untrusted input + access to secrets + outbound egress. agent-taint provides three progressive defense layers so you can match enforcement strength to the risk of each repository:

LayerHow to EnableWhat It StopsName-Bound?
Layer 1
Default Hook
Default (strict_shell: false) Credential file reads (~/.ssh, .env*, /proc/*/environ), vault CLIs (bws, bw, op, vault, sops, kubectl get secret -o), persistence edits, obfuscated exec (base64 -d | sh, eval), and known egress tools (curl, wget, ssh, scp, rsync, nc, inline Python/Node/Ruby HTTP) once tainted. Yes — low-friction day-to-day guard; a renamed binary (cp /usr/bin/curl /tmp/x) or freshly compiled Go/Rust binary is not caught by command name alone.
Layer 2
Strict Allowlist
strict_shell: true (global or per-repo profile) or install --strict Flips tainted sessions to default-deny for shell commands: every command is blocked/asked unless its prefix is in allow_commands (git status, cargo test, ls, rg, etc.). Stops renamed binaries and custom scripts. No (allowlist-only when tainted).
Layer 3
OS Kernel Sandbox
agent-taint sandbox -- <cmd> Linux bwrap --unshare-net or macOS Seatbelt (deny network*): removes network namespace, masks credential directories, and scrubs secret env vars at the kernel boundary. No (kernel-enforced — renamed or compiled binaries cannot escape).

4. Repo Approval vs. PR / Issue Reads

Approving a repository in agent-gate does NOT exempt GitHub PR or issue reads from tainting the session.
  • agent-gate approve . cryptographically pins your local checked-out config files (CLAUDE.md, AGENTS.md, .mcp.json, hooks, SKILL.md) using BLAKE3 + GPG/SSH. Clean subdirectories inside an approved repo inherit approval automatically; nested .git repos or subdirectories carrying their own agent configs still require explicit approval.
  • gh pr view, gh pr diff, gh issue view, gh api are allowed to execute (even under strict_shell: true), and they always taint the session — because PR descriptions, reviews, and issue comments on an approved repo can come from external contributors and carry hidden prompt injection.
  • After reading an external PR or web page, either finish your read-only review in the tainted session, start a fresh session, or run agent-taint clear once you've verified no untrusted instructions remain.

5. Policy Schema, Precedence & Wildcards

Local user policy lives at ~/.config/agent-taint/policy.json (generate a starter file with agent-taint init-policy).

Top-level policy.json fields

FieldType & DefaultBehavior
audit_onlybool (false)Log would-be blocks to audit.jsonl without blocking tool execution.
audit_omit_detailbool (false)Privacy mode: strip command/argument snippets from local audit.jsonl.
taint_all_mcpbool (true)Treat every mcp__* / mcp_* tool as a taint source unless its prefix is in trusted_mcp_prefixes.
strict_shellbool (false)Layer 2 default-deny: when tainted, block/ask on all shell commands except allow_commands.
ask_on_git_pushbool (true)Downgrade git push / gh pr|issue to confirmation (Ask) instead of hard Deny when tainted.
allowed_hostsstring[] (["localhost","127.0.0.1","::1"])Destination hosts/IPs (or *.domain.tld wildcards) allowed for egress even when tainted. Credential reads stay blocked.
trusted_mcp_prefixesstring[] ([])Local MCP server prefixes (e.g. "plur", "mcp__plur__") that do not taint sessions.
allowed_gh_api_prefixesstring[] ([])Read-only gh api GET endpoint prefixes allowed when tainted (e.g. "repos/myorg/"). Mutating calls stay denied.
untrusted_reposstring[] ([])Repo paths or globs (/tmp/*, ~/external/**) where sessions start tainted automatically.
repo_profilesmap<path, RepoProfile>Per-repository capability overrides (exact/prefix or */** glob).
deny_commandsstring[] (built-in list)Command prefixes hard-denied in tainted sessions (e.g. gh secret, kubectl delete).
ask_commandsstring[] (built-in list)Command prefixes requiring confirmation in tainted sessions (e.g. git push, kubectl apply).
allow_commandsstring[] (built-in list)Safe read-only/build prefixes allowed without confirmation under strict_shell: true.
extra_taint_toolsstring[] ([])Additional tool name substrings that taint a session.
extra_credential_pathsstring[] ([])Additional path substrings treated as sensitive credentials.
extra_untrusted_pathsstring[] ([])Additional path substrings treated as untrusted taint sources.
managed_pathsstring[] ([])Fleet-only: path/glob patterns (e.g. ~/work/**) scoping where fleet-policy.json applies. Empty = global.
managed_remotesstring[] ([])Fleet-only: git remote globs (e.g. github.com/acme/*) catching work repos even if cloned outside managed_paths.
lock_local_policybool (false)Fleet-only: ignore local policy.json inside managed scopes (strict cloud-only lockdown).

Per-repository RepoProfile fields

FieldTypeEffect inside matching repo
untrustedboolSession starts tainted automatically.
strict_shellbool?Override global strict_shell for this repo.
deny_networkboolClears global allowed_hosts and allowed_gh_api_prefixes when tainted (total egress lockdown).
allowed_hostsstring[]Extra hosts/subdomains allowed only in this repo.
allowed_gh_api_prefixesstring[]Extra read-only gh api prefixes allowed only in this repo.
trusted_mcp_prefixesstring[]Extra trusted MCP prefixes allowed only in this repo.
deny_commands / ask_commands / allow_commandsstring[]Repo-scoped additions to the global command lists.

Complete example policy.json

{
  "audit_only": false,
  "taint_all_mcp": true,
  "strict_shell": false,
  "ask_on_git_push": true,
  "allowed_hosts": ["localhost", "127.0.0.1", "::1", "*.internal.example"],
  "trusted_mcp_prefixes": ["plur"],
  "allowed_gh_api_prefixes": ["repos/myorg/"],
  "untrusted_repos": ["/tmp/*", "~/external/**"],
  "repo_profiles": {
    "/home/*/work/**": {
      "strict_shell": true,
      "allowed_hosts": ["*.corp.internal"]
    },
    "~/work/prod-infra": {
      "deny_network": true,
      "deny_commands": ["kubectl delete", "terraform destroy"]
    }
  }
}

Wildcard & precedence rules

  • Host wildcards (allowed_hosts): exact match or *.domain.tld subdomain wildcard. Requires at least two DNS labels after *. — bare * and *.com are rejected to prevent accidental open egress.
  • Path globs (repo_profiles & untrusted_repos): supports leading ~/, single-segment *, and multi-segment **. Exact/prefix matches always outrank wildcard globs; ties break by longest pattern.
  • Credential paths: intentionally kept to explicit patterns and substrings (no broad wildcards) to prevent bypasses.
  • Fleet merge floor: on enrolled developer workstations, signed fleet-policy.json is merged with local policy.json so local config can tighten rules or add personal allowlists, but can never weaken fleet strict_shell: true or flip fleet enforce back to audit_only. On standalone agents (--kind agent), local policy.json is ignored completely.

6. Built-in Sources, Credentials & Egress Rules

CategoryBuilt-in Coverage
Taint sources WebFetch, WebSearch, search_web, browser_*; all mcp__*/mcp_* tools (unless in trusted_mcp_prefixes); shell fetches (curl, wget, git fetch, git pull, gh pr/issue view|diff, gh api); untrusted paths (node_modules/, /tmp/, vendor/) and untrusted_repos.
Protected credentials ~/.ssh, ~/.aws, ~/.gnupg, ~/.kube, .env / .env.*, *.key, *.pem, id_rsa/id_ed25519, .netrc, .npmrc, .pypirc, /proc/*/environ, agent-taint/sync.env, agent-taint/device.key, env dumps (env, printenv, export -p), and secret CLIs (bws, bw, op, vault, sops, kubectl get secret -o).
Egress & obfuscation curl, wget, ssh, scp, rsync, nc/ncat/socat, /dev/tcp/, cargo/npm/poetry publish, inline python/node/ruby HTTP/socket calls, base64 -d | sh, eval $(...), and side-effecting gh writes (gh secret, gh ssh-key, gh auth token, gh repo delete, gh release create).
Persistence & self-protection Blocks tainted edits to ~/.bashrc, ~/.zshrc, ~/.profile, authorized_keys, crontab, and harness configs (~/.claude/, ~/.cursor/, ~/.gemini/, ~/.config/opencode/). Even in clean sessions, modifying agent-taint / agent-gate binaries, policies, state, or hooks requires confirmation.

7. OS Kernel Sandbox (agent-taint sandbox)

Layer 3 enforces network and credential boundaries in the OS kernel using bubblewrap (bwrap) on Linux and Seatbelt (sandbox-exec) on macOS.

# Default: network disabled (--unshare-net), credential dirs masked, secret env scrubbed
agent-taint sandbox -- cargo test

# Allow network when tests need it, while keeping credentials & secret env isolated
agent-taint sandbox --allow-net -- npm test

# Inspect the exact bwrap / sandbox-exec invocation without running it
agent-taint sandbox --print -- python3 script.py
  • Network: isolated via --unshare-net (Linux) or (deny network*) (macOS) unless --allow-net is passed.
  • Filesystem: bind-mounts the current workspace while masking ~/.ssh, ~/.aws, ~/.gnupg, ~/.kube, and agent-taint device keys with empty read-only tmpfs mounts.
  • Environment: scrubs secret-bearing variables (*TOKEN*, *SECRET*, *API_KEY*, AWS_*, GITHUB_TOKEN, BWS_*, etc.) before exec.

8. Signed Repo Config Gate (agent-gate)

Prevents repository-level supply-chain attacks where a cloned repo hides malicious shell commands or exfiltration MCPs inside CLAUDE.md, AGENTS.md, .claude/settings.json, .mcp.json, or SKILL.md.

Whenever agent-taint is on PATH, agent-gate approve automatically pins the agent-taint binary BLAKE3 hash, hooks, and plugin files against tampering by default.

agent-gate scan .             # inspect agent configs + static skill capability risk (INFO/MED/HIGH)
agent-gate approve .          # BLAKE3 hash + GPG/SSH sign + auto-pin agent-taint binary & hooks
agent-gate install claude     # wire PreToolUse / SessionStart verification into Claude Code
agent-gate check .            # verify repo signature & pinned guard hashes (agent-free via gpgv)

# After upgrading agent-taint to a new version, re-pin the new binary hash:
agent-gate refresh-guards
agent-gate refresh-guards --allow-hash <64-char-blake3>   # pre-approve an upgrade hash
Agent-free signature verification: agent-gate verifies GPG approvals with gpgv against a dedicated exported keyring (never touching gpg-agent or your private key during hook checks) and supports SSH signing with hardware YubiKey / FIDO2 keys.

9. Zero-Token Fleet Enrollment (taintd cloud)

Enrolled endpoints never store a long-lived plaintext API bearer token on disk. An operator mints a short-lived, single-use join token (atj_…, default 15m TTL) in the SSO-gated Cloud UI, and agent-taint enroll generates a per-machine Ed25519 keypair in OS-native secret storage:

PlatformSecret Store PrerequisiteHow the Private Key Is Stored
macOS/usr/bin/security (built-in)macOS Keychain (piped via security -i stdin — zero key file on disk, never in argv)
Linux (systemd)systemd-creds (systemd ≥ 256)Sealed in ~/.config/agent-taint/device.key.cred; decrypted into ephemeral RAM-only $CREDENTIALS_DIRECTORY/device_key via LoadCredentialEncrypted=
Linux desktopsecret-tool (libsecret)GNOME Keyring / KWallet via stdin
Containers / CIExplicit --allow-file-key flag0600 key file protected by agent-taint's built-in credential denylist

Enroll & verify sync

# 1. Enroll once using a single-use join token from the Cloud UI
agent-taint enroll \
  --server https://taint.corp.example \
  --kind developer \
  --join-token atj_...

# 2. Zero-flag sync (reads cloud.json + OS secret store automatically)
agent-taint sync --push-discover --push-audit --apply-grants

Protocol security (device:v2 / policy:v2 / grant:v2)

  • Every sync request is signed with the endpoint's Ed25519 device key over method + path + query + body SHA-256 + timestamp + random nonce (replay window + nonce cache enforced server-side).
  • Every downloaded policy and remote grant is signed by the control plane's Ed25519 key with monotonic version binding (anti-rollback).
  • Lost or compromised endpoints can be revoked in one click from the Fleet UI (POST /api/v1/machines/{machine}/revoke), immediately invalidating their device key.

Linux systemd user timer (recommended)

# ~/.config/systemd/user/agent-taint-sync.service
[Unit]
Description=Sync agent-taint fleet policy and telemetry

[Service]
Type=oneshot
LoadCredentialEncrypted=device_key:%h/.config/agent-taint/device.key.cred
ExecStart=%h/.local/bin/agent-taint sync --push-discover --push-audit --apply-grants

# ~/.config/systemd/user/agent-taint-sync.timer
[Unit]
Description=Run agent-taint-sync every 5 minutes

[Timer]
OnBootSec=1m
OnUnitActiveSec=5m

[Install]
WantedBy=timers.target

10. Developers vs. Standalone Agents

taintd cloud models human workstations and autonomous bots as distinct entity classes:

PropertyDeveloper (--kind developer)Standalone Agent (--kind agent)
Console viewDevelopers tab (grouped by user)Standalone Agents tab (grouped by bot + Owner)
Local policy.jsonMerged additively under the fleet floor (can tighten or add personal hosts/MCPs)Ignored completely — only signed fleet-policy.json is loaded
Local mutating CLIsAllowed (cannot weaken fleet floor)Refused (allow-host, trusted-mcp, mode, repo-profile, etc.)
Owner fieldDeveloper OS username ($USER)OS user running the bot service ($USER)

Workspace-Scoped Fleet Policies & Developer Privacy

When a company wants strict lockdown on work repos without restricting or monitoring personal projects on the same laptop, add managed_paths, managed_remotes, and optionally lock_local_policy: true to fleet-policy.json:

{
  "audit_only": false,
  "audit_omit_detail": true,
  "lock_local_policy": true,
  "managed_paths": ["~/work/**", "~/clients/acme/**"],
  "managed_remotes": ["github.com/acme/*", "gitlab.acme.internal/**"]
}
  • Inside managed folders / remotes: fleet-policy.json enforces (ignoring local policy.json when lock_local_policy: true), and decision metadata syncs to taintd cloud.
  • Outside managed folders: fleet-policy.json is skipped completely. Developers keep full autonomy via their own local policy.json, and events from unmanaged folders are tagged fleet_managed: false and never uploaded by agent-taint sync (neither plaintext nor E2EE).
  • Cross-zone escalation: if an AI session started in an unmanaged personal folder reads or targets any path inside managed_paths, agent-taint immediately engages the managed fleet policy and marks the session managed_zone: true for the remainder of the session.

11. Learn → Confirm → Enforce, Remote Grants & E2EE Audit

  • Starter Policy Templates: one-click profiles for Audit/Learn, Developer Balanced/Strict, Standalone Agent Audit/Enforce, and CI Lockdown.
  • Learn → Confirm → Enforce: while endpoints run in audit_only, the control plane aggregates observed hosts and Shadow MCPs into a checkbox draft. Operators review, check off legitimate items, and publish a new Ed25519-signed enforce profile in one click.
  • Remote Control Queue: blocked headless agents submit metadata-only approval requests (endpoint, tool, target host — never prompt text or file contents). Operators approve in the SSO UI (with Slack / Mattermost / Discord webhook notifications), issuing a short-lived Ed25519-signed single-use allow_once or clear_taint grant.
  • Deduplicated E2EE Audit: agent-taint sync --push-audit tracks a byte watermark in ~/.cache/agent-taint/audit_sync.offset (with truncation reset) so events are never duplicated. Pass --encrypt-audit age1… to encrypt audit blobs client-side before upload; the server stores ciphertext only and supports formula-safe SOC2 CSV export.

12. Files & Disk Layout

PathPurpose
~/.config/agent-taint/policy.jsonLocal user policy (ignored when enrolled as --kind agent).
~/.config/agent-taint/fleet-policy.jsonEd25519-verified fleet policy written by agent-taint sync.
~/.config/agent-taint/cloud.jsonEnrollment metadata (server URL, pinned server pubkey, machine ID, kind, secret-store backend).
~/.config/agent-taint/device.key.credsystemd-creds encrypted Ed25519 device key (Linux).
~/.cache/agent-taint/sessions/*.jsonPer-session taint & secrets_accessed state files.
~/.cache/agent-taint/audit.jsonlLocal append-only audit log of taint events and blocks.
~/.cache/agent-taint/audit_sync.offsetByte cursor used by sync --push-audit to prevent duplicate uploads.
~/.config/agent-gate/approvals.json (+ .asc/.sig)Signed repo config hashes & pinned agent-taint binary/hook hashes.

13. Full CLI Reference

agent-taint

# Install & onboarding
agent-taint install <claude|cursor|vscode|agy|opencode> [--strict] [--no-setup]
agent-taint setup              # re-run guided walkthrough (mode, folders, MCPs, hosts)
agent-taint discover [--apply-local-mcp] [--apply-ssh] [--json]
agent-taint init-policy [-o <path>]
agent-taint mode <audit|enforce>

# Session inspection & audit review
agent-taint status [session-id]
agent-taint taint <session-id> [--reason "..."]
agent-taint clear [session-id | --all]
agent-taint review [-i] [--clear] [--json] [--nudge]

# Local policy allowlists & repo profiles
agent-taint allow-host <add|remove|list> <host-or-*.domain> [--global]
agent-taint trusted-mcp <add|remove|list> <prefix> [--global]
agent-taint allow-gh-api <add|remove|list> <prefix> [--global]
agent-taint allow-cmd <add|remove|list> <prefix>
agent-taint untrusted-repo <add|remove|list> <path-or-glob>
agent-taint repo-profile <set|remove|list> <path-or-glob> [--strict-shell true|false] [--deny-network] [--allow-host ...]

# OS kernel sandbox
agent-taint sandbox [--allow-net] [--print] -- <command...>

# Fleet control plane
agent-taint enroll --server <URL> --join-token <atj_...> [--kind developer|agent] [--machine <name>] [--allow-file-key]
agent-taint sync [--push-discover] [--push-audit] [--encrypt-audit <age1...>] [--apply-grants] [--dry-run]

agent-gate

agent-gate scan [path]
agent-gate approve [path] [--sign gpg|ssh|none] [--force]
agent-gate check [path]
agent-gate install <claude|cursor|vscode|agy>
agent-gate refresh-guards [--allow-hash <blake3>]

14. Troubleshooting & FAQ

  • Every tool call is blocked after upgrading agent-taint: agent-gate detected that the agent-taint binary hash changed. Run agent-gate refresh-guards to re-pin the upgraded binary.
  • Why was my session tainted? Run agent-taint status (or /taint-review inside Claude Code / Antigravity) to see the exact tool call that triggered taint and approve trusted local MCPs or hosts.
  • Standalone agent refuses allow-host / mode locally: Expected behavior for --kind agent. Manage its policy from the taintd cloud console so a compromised bot cannot weaken its own guard.
  • Reverse proxy / SSO in front of taintd cloud: Keep the web UI and admin endpoints behind Google/OIDC SSO, and allow /api/v1/enroll plus requests carrying an X-Taintd-Signature header to reach the backend directly (always strip X-Auth-Request-Email on bypassed routes).
  • What if someone runs an unhooked CLI in another folder? agent-taint install hooks are user-global for supported harnesses, so launching Claude/Cursor/VS Code/agy/OpenCode in any folder is covered. Preventing an arbitrary unhooked binary from reading sibling folders requires OS-level isolation (dedicated UID, agent-taint sandbox, or container) — see the Roadmap below.

15. Roadmap — Defense Beyond Hooks

  • System-wide Managed Settings (agent-taint install --system): generate root-owned managed configs (e.g. /etc/claude-code/managed-settings.json with allowManagedHooksOnly: true, plus MDM templates for Cursor & VS Code) so hooks cannot be disabled per-folder or per-user.
  • Workspace-Jailed Harness Wrapper (agent-taint wrap <harness>): run the entire agent process inside bwrap / macOS Seatbelt with only the active repo bind-mounted RW and sibling folders / credential dirs hidden — works even for unhooked harnesses.
  • Fleet Cloud Unhooked Harness & Drift Alerts: webhook alerts when discover detects an installed harness without active hooks or when an enrolled endpoint stops syncing.
  • Linux Landlock / eBPF Kernel Enforcement: optional kernel-level path and egress rules so child processes cannot escape workspace or host allowlists even if renamed or statically compiled.