Skip to content

feat(security): agent trust-surface detection — planted AGENTS.md/CLAUDE.md, endpoint/MCP drift (#2538) - #2539

Merged
jinon86 merged 2 commits into
mainfrom
feat/2538-agent-trust-detect
Oct 26, 2026
Merged

jinon86 merged 2 commits into
mainfrom
feat/2538-agent-trust-detect

Conversation

@jinon86

@jinon86 jinon86 commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Refs #2538 (part 1/2 — detection). Part 2 (non-blocking SessionStart/config-drift warning hook) follows in a separate PR.

Why

forever.security (2026-10-22): a web page drops AGENTS.md/CLAUDE.md into ~/Downloads; Codex/Claude Code started there follow it. Reproduced: MCP added to ~/.codex/config.toml + npm function-color; ANTHROPIC_BASE_URL rewrite → OAuth token leak.
Fleet variant: A2A analysis sessions run under /tmp/a2a-analysis-* and Claude Code loads CLAUDE.md from every ancestor → one /tmp/CLAUDE.md reaches every worker session on a node.

Fleet sweep 2026-10-26 (seoseo, read-only, 12/12): 0 IOC. See #2538.

What (detection only — TM-1306 unchanged, no guard / no permissions.deny)

  • claude/hooks/lib/agent_trust.py — stdlib collector, schema ccc.agent-trust.v1. Emits hosts/paths/sha12 only; never file contents or secret values.
    • danger: agent file in a download dir (outside git), AGENTS.md/CLAUDE.md directly in /, /tmp, /var/tmp, $PREFIX/tmp, home parent; function-color in global node_modules or launched by an MCP entry.
    • warn: endpoint override to a non-allowlisted host (CCC_AGENT_TRUST_ENDPOINT_ALLOW), unpinned npx -y MCP, unmanaged home AGENTS.md/CLAUDE.md (ccc-node managed marker is quiet), config at an ancestor root, sessions run from Downloads.
  • scripts/ccc-security-audit.sh — new agent trust rows (위험 → exit 1 as before).
  • scripts/agent-trust-audit-fleet.sh — pipes the collector to each node over ssh (python3 - --json, no remote checkout dependency), baseline diff like tunnel-audit (ops(security): 공개 터널 정례 감사 — 플릿 터널 등록부·주기 자동 점검 (TM-2370 P0 잔여) #1366). DANGER fails even after acceptance; NEW/UNREACHABLE/ERROR fail.
  • scripts/install-agent-trust-audit-cron.sh — hub-only weekly (Mon 06:40), registered in installer-gen-stamp.sh and ccc_doctor.py cron drift (doctor test 11 → 12 rows).
  • docs/security-audit.md section, changelog fragment.

Verification

  • scripts/ccc-security-audit.test.sh PASS=30 (planted Downloads//tmp file, git-checkout downgrade, endpoint host-only + secret not printed, npx pin, known-bad npm dir + MCP arg, managed vs unmanaged home file, Codex toml, missing collector)
  • scripts/agent-trust-audit-fleet.test.sh PASS=12 (stubbed ssh + real collector self path)
  • scripts/install-agent-trust-audit-cron.test.sh PASS=36, scripts/ccc-doctor.test.sh PASS=183
  • CCC_HARNESS_PHASE=static bash scripts/validate-harness.sh → PASS; ruff check . → clean
  • Live dry run of the collector via ssh <node> python3 - --json on all 12 nodes: 0 danger; warn = unpinned npx MCP (7 nodes), nosuk unmanaged /root/CLAUDE.md, seoseo /home/.claude/settings.json ({"existing": true} test residue, 2026-07-17). ~0.2s per node.

Not in this PR

  • Installing the cron / accepting baselines on seoseo (operational follow-up after merge).
  • Blocking guard/deny (would reverse TM-1306 — separate owner decision).

🤖 Generated with Claude Code

…UDE.md, endpoint/MCP drift (#2538)

forever.security (2026-10-22) showed agents hijacked by an AGENTS.md/CLAUDE.md
dropped into ~/Downloads (MCP added to ~/.codex/config.toml + npm
function-color; ANTHROPIC_BASE_URL rewrite -> OAuth leak). The fleet variant is
sharper: A2A analysis sessions run under /tmp/a2a-analysis-* and Claude Code
loads CLAUDE.md from every ancestor, so one /tmp/CLAUDE.md reaches every worker.

Detection only (TM-1306 keeps blocking guards out):
- claude/hooks/lib/agent_trust.py: stdlib collector (ccc.agent-trust.v1);
  hosts/paths/hashes only, never contents or secret values.
- ccc-security-audit.sh: "agent trust" rows (위험/경고/정상).
- scripts/agent-trust-audit-fleet.sh: pipes the collector over ssh, diffs a
  per-node signature against an accepted baseline; DANGER always fails.
- scripts/install-agent-trust-audit-cron.sh: hub-only weekly cron, registered
  in installer-gen-stamp + ccc_doctor cron drift.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jinon86
jinon86 requested a review from seoseo-ai as a code owner October 26, 2026 12:27
…n the hub crontab (#1451, #2538)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@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 26, 2026
Merged via the queue into main with commit 83d93b1 Oct 26, 2026
14 checks passed
@jinon86
jinon86 deleted the feat/2538-agent-trust-detect branch October 26, 2026 13:56
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