Skip to content
Hiep Lam
Go back

Shrinking the Agent Loop, Part 2: Living Inside the Trust Boundary

Edit page 🇻🇳 Tiếng Việt

“Shrinking the Agent Loop: RTK vs Caveman” - Part 2 of 3. A full security review of both tools as agent-loop interceptors - where the danger is structural, where it’s tool-specific, and what to actually do about it. Part of a series auditing rtk-ai/rtk and JuliusBrussee/caveman from source.


This review treats both tools as interceptors inside the agent’s trust boundary. It separates the inherent architectural exposure - shared by both, severe if abused - from the tool-specific findings, which are mostly low–medium. Severity is attacker-model-scoped and reflects a point-in-time read of public source; a future version can change every rating. (rtk-ai/rtk @ master (Rust) · JuliusBrussee/caveman @ main / v1.9.0 (Node+Python).)

1. The headline

Neither tool, as currently written, contains an obvious remote-code-execution or data-exfiltration backdoor - and both show genuine, above-average defensive engineering (RTK’s quote-aware command lexer + fail-closed checksums; Caveman’s O_NOFOLLOW symlink-hardened flag files + pinned, SHA-256-verified hooks).

The real, high risk is structural and identical for both: a hook/skill runs with your full user privileges, with no sandbox, and anything it emits is injected into the model’s context unsanitised. So a compromised future version (malicious update, stolen maintainer token, MITM during install) equals total agent compromise: it can read every secret the agent can read and rewrite/inject every command. The threat you must manage is supply-chain integrity, not today’s code. Caveman is the higher supply-chain risk of the two.

2. Why interceptors are inherently dangerous

A Claude Code hook is not a sandboxed plugin - it is an OS process running as you, wired into events that feed the model. Per Anthropic’s own docs (adversarially verified):

That is precisely the machinery RTK and Caveman use - and the same machinery an attacker would.

3. Risk-class severity matrix

Risk classRTKCaveman
0 · Inherent trust-boundary exposure (compromised build → full agent compromise)🟧 HIGH (structural, shared)🟧 HIGH (structural, shared)
1 · Context / prompt injection (hook stdout & additionalContext)🟩 LOW (rules-file text only)🟨 MEDIUM (behavioural: can drop caveats)
2 · Command-rewriting safety🟩 LOW (quote-aware, fail-closed)- N/A (doesn’t rewrite commands)
3 · Supply chain (install/update)🟨 MEDIUM (fail-closed checksum ✔)🟧 HIGH (unpinned bootstrap)
4 · MCP proxy / tool-poisoning- N/A🟨 LOW–MED (NUL-sentinel bug, PoC)
5 · Sensitive-data exposure / exfiltration🟨 LOW–MED (cmd args in SQLite)🟨 MEDIUM (compress → file to LLM)
6 · Local file write · symlink · TOCTOU🟩 LOW (runtime integrity ✔)🟩 LOW (O_NOFOLLOW hardened ✔)
7 · Code-eval in loaders⬜ INFO (none)🟩 LOW (local-only eval)

4. RTK - findings

Command-rewrite injection - LOW

Project filter (.rtk/filters.toml) context-injection - MEDIUM

Supply chain (install / update) - MEDIUM

Data exposure - telemetry & data-at-rest - LOW–MEDIUM

5. Caveman - findings

Supply chain - unpinned bootstrap - HIGH

Behavioural safety - “drop the caveats” - MEDIUM

caveman-compress - file contents → LLM - MEDIUM

caveman-shrink MCP proxy - NUL-sentinel bug - LOW–MEDIUM

Code-eval & install spawn - LOW

6. External threat landscape

These published facts establish that the interceptor risk class is real and actively exploited - the backing for risk-class 0 and 3. (A fabricated “Shai-Hulud May 2026” claim that surfaced in search was refuted and dropped.)

Primary sources: docs.anthropic.com/claude-code/hooks · github.com/anthropics/claude-code/issues/49778 · docs.anthropic.com/claude-code/security · owasp.org/www-project-mcp-top-10 (MCP03) · invariantlabs.ai/blog/mcp-security-notification-tool-poisoning-attacks · flatt.tech (poisoning-claude-code) · research.checkpoint.com (CVE-2025-59536).

7. Verdict & hardening checklist

If you must rank them: Caveman carries more residual risk (bigger surface: Node + 30+ integrations + MCP proxy + on-disk rewrites; unpinned bootstrap; a no-checksum install path; behaviour that can suppress safety text). RTK is tighter (single checksummed binary, deterministic, no LLM/network in the hot path, fail-closed install; sharpest edges are the rtk trust social-engineering vector and command args at rest in SQLite). Both are only as safe as their next update.

Do these regardless of which you run:

  1. Pin everything. Install Caveman from a tag/commit, not curl|bash of main; install RTK via a checksummed release (never RTK_SKIP_CHECKSUM=1). Avoid the --with-init/--all no-checksum path.
  2. Audit the hooks at rest. After install, read ~/.claude/settings.json (and project .clinerules/.windsurfrules) - nothing flags that hooks exist. Re-check after updates.
  3. Never rtk trust a .rtk/filters.toml you haven’t read - treat trusted filters as code review.
  4. Don’t run caveman-compress on secret-bearing files; the denylist is advisory. Review in-place rewrites before committing.
  5. Only put caveman-shrink in front of MCP servers you trust (it doesn’t sanitise a hostile upstream).
  6. Don’t treat caveman-mode answers as authoritative on risk - ask for full detail before irreversible/security-sensitive actions.
  7. Pin versions in shared/CI environments and watch the upstream repos for ownership/maintainer changes.

Key idea: the code in front of you today is not the risk - the code that replaces it tomorrow is. Treat both tools as supply-chain dependencies, not static artifacts, and pin accordingly.

The next post drills into the two findings above that deserved more rigor than a one-line severity rating: Caveman’s NUL-sentinel forgery and RTK’s SQLite data-at-rest exposure - each with a working proof of concept.


Method: source-level audit (parallel auditor agents + firsthand verification incl. a live PoC) cross-checked against an adversarially-verified web pass (6 angles, 31 sources, 16/25 claims confirmed, 9 refuted).


Next: Part 3 - A NUL Sentinel, a ReDoS, and a Secret Left in Plaintext →

The series - Shrinking the Agent Loop: RTK vs Caveman: 1 · How They Work · 2 · Living Inside the Trust Boundary (you are here) · 3 · A NUL Sentinel, a ReDoS, and a Secret Left in Plaintext


Edit page
Share this post:

Previous Post
Shrinking the Agent Loop, Part 1: How RTK and Caveman Attack Opposite Ends of the Pipe
Next Post
Shrinking the Agent Loop, Part 3: A NUL Sentinel, a ReDoS, and a Secret Left in Plaintext

Keep reading

A few more pieces in the same vein.

Rather read on your own time? Subscribe via RSS