Skip to content

feat(hooks): agent-trust-watch — non-blocking untrusted instruction-file and config-drift warnings (#2538) - #2540

Merged
jinon86 merged 1 commit into
mainfrom
feat/2538-agent-trust-watch
Oct 27, 2026
Merged

jinon86 merged 1 commit into
mainfrom
feat/2538-agent-trust-watch

Conversation

@jinon86

@jinon86 jinon86 commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Refs #2538 (part 2/2 — non-blocking warnings). Stacked on #2539; retarget to main after #2539 merges.

What

claude/hooks/agent-trust-watch.sh (+ helpers in claude/hooks/lib/agent_trust.py). Never blocks — TM-1306 unchanged.

  • SessionStart — warns when the session would load an AGENTS.md/CLAUDE.md the harness did not write:
    • in a shared ancestor root (/, /tmp, /var/tmp, $PREFIX/tmp, home parent) — A2A analysis sessions run under /tmp/a2a-analysis-*, and Claude Code loads CLAUDE.md from every ancestor;
    • in a download directory outside git, or when the cwd itself is in a download directory.
      The context tells the model to treat them as untrusted data, not to edit agent config / install packages / add MCP servers because of them, and to tell the owner. Also reports endpoint/MCP changes since the previous session.
  • PostToolUse (Bash|Write|Edit|MultiEdit) — shell mtime fast path over ~/.claude/settings.json, settings.local.json, ~/.claude.json, ~/.codex/config.toml; python runs only when one moved, then warns once on endpoint/MCP additions/removals (non-security edits stay silent).
  • State $CCC_STATE_DIR/agent-trust/ = fingerprint (endpoint scheme://host, MCP name → command basename/host) + mtimes. No contents, no secret values. Off switch CCC_AGENT_TRUST_WATCH=0. Fail-open.
  • Wiring: settings.base.json SessionStart; enforcement-overlay.json + hooks.json PostToolUse.
  • Codex lane has no hooks → covered by the weekly sweep from feat(security): agent trust-surface detection — planted AGENTS.md/CLAUDE.md, endpoint/MCP drift (#2538) #2539.

Verification

  • claude/hooks/agent-trust-watch.test.sh PASS=21 — /tmp-root CLAUDE.md reaches an A2A cwd, Downloads loose vs git-checkout file, cwd-in-Downloads, PostToolUse endpoint injection (host only, ?key= never printed, warned once), between-session Codex MCP addition, non-security edit silent, off switch, malformed stdin, unknown event, no contents in state.
  • scripts/setup.test.sh PASS=249, scripts/ccc-security-audit.test.sh PASS=30, CCC_HARNESS_PHASE=static bash scripts/validate-harness.sh PASS, ruff clean.
  • Latency on seoseo (real HOME, temp state): SessionStart 0.15–0.16 s, PostToolUse fast path 0.02–0.03 s.

Rollout

Lands through the normal self-update path (setup.sh hook-tree walk + settings merge). First PostToolUse/SessionStart on a node seeds the fingerprint silently.

🤖 Generated with Claude Code

@jinon86
jinon86 requested a review from seoseo-ai as a code owner October 26, 2026 12:58
…ile and config-drift warnings (#2538)

SessionStart: if the session would load an AGENTS.md/CLAUDE.md from a shared
ancestor root (/, /tmp, /var/tmp, $PREFIX/tmp, home parent — A2A analysis
sessions run under /tmp) or from a download dir outside git, or the cwd is in a
download dir, tell the model to treat those files as untrusted data and to
report them; also report endpoint/MCP changes since the previous session.

PostToolUse(Bash|Write|Edit|MultiEdit): shell mtime fast path (~0.03s) over
the four agent config files; on change, recompute the fingerprint (endpoint
scheme://host, MCP name -> command basename/host) and warn once.

Never blocks (TM-1306), fail-open, no contents/secret values stored, off
switch CCC_AGENT_TRUST_WATCH=0. Wired in settings.base.json (SessionStart) and
enforcement-overlay.json + hooks.json (PostToolUse).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jinon86
jinon86 force-pushed the feat/2538-agent-trust-watch branch from 3329600 to 1613eb1 Compare October 26, 2026 13:55
@jinon86
jinon86 changed the base branch from feat/2538-agent-trust-detect to main October 26, 2026 13:55
@jinon86 jinon86 closed this Oct 27, 2026
@jinon86 jinon86 reopened this Oct 27, 2026

@seoseo-ai seoseo-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved after exact-head validation and fresh operator authorization using the relay-held seoseo-ai credential.

@jinon86
jinon86 added this pull request to the merge queue Oct 27, 2026
Merged via the queue into main with commit 587b09f Oct 27, 2026
14 checks passed
@jinon86
jinon86 deleted the feat/2538-agent-trust-watch branch October 27, 2026 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants