Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

`containment-zones.ts` declares `Plugins/**` but Claude Code writes `plugins/`, so the plugin registry is classified SYSTEM

Open catchingknives opened this issue 4 months ago • 2 comments

The install-state containment zone in hooks/lib/containment-zones.ts declares its plugin patterns with a capital P:

{
  name: "install-state",
  patterns: [
    "history.jsonl",
    "Plugins/**",
    "Plugins/installed_plugins.json",
    "Plugins/known_marketplaces.json",
    "debug/**",
    "debug",
  ],
  ...
}

Claude Code writes that directory as ~/.claude/plugins/, lowercase. Zone matching is case-sensitive, so none of the three Plugins patterns ever match, and the harness-written plugin registry is classified system instead of user.

Reproduce

On a default macOS install (case-insensitive APFS, which is what makes this easy to miss):

import { classifyTarget } from "./hooks/lib/system-file-guard-core";

classifyTarget(`${CLAUDE_ROOT}/plugins/installed_plugins.json`, CLAUDE_ROOT)
// => { classification: "system", relPath: "plugins/installed_plugins.json" }

classifyTarget(`${CLAUDE_ROOT}/Plugins/installed_plugins.json`, CLAUDE_ROOT)
// => { classification: "user",   relPath: "Plugins/installed_plugins.json" }

Those two paths are the same file on a case-insensitive volume. They classify differently because the classifier compares strings while the filesystem does not. readdirSync reports the true on-disk name as plugins, so every real traversal takes the system branch.

The other patterns in the same zone (history.jsonl, debug/**) classify as user correctly, which isolates the fault to the casing rather than to the zone.

Why it matters

plugins/known_marketplaces.json and plugins/installed_plugins.json are written by the harness and contain absolute home-directory paths, for example:

/Users/<user>/.claude/plugins/marketplaces/claude-plugins-official

Two consequences follow from the misclassification:

  1. Leak-check tooling. Anything that classifies by zone to decide private-zone versus real-leak will report these harness-generated files as real leaks. They are runtime install state and should be private-zone.
  2. Write-time guard. hooks/SystemFileGuard.hook.ts only inspects system-classified targets, so writes into the plugin registry are checked against the identity deny-list. Those files legitimately contain a home path, so the guard is being pointed at a file that can never be clean.

Suggested fix

Lowercase the three patterns:

"plugins/**",
"plugins/installed_plugins.json",
"plugins/known_marketplaces.json",

plugins/** alone covers the two named entries; the explicit lines are redundant either way and could be dropped.

Worth considering alongside it

Since the trigger is a case-sensitivity mismatch that a case-insensitive filesystem hides, the same class of fault can exist anywhere else a zone pattern is spelled by hand. Two options, either of which would prevent a recurrence:

  • Match zone patterns case-insensitively, which matches the behaviour of the filesystem the majority of users are on.
  • Add a startup or test-time assertion that every literal directory prefix named in CONTAINMENT_ZONES resolves to a real path with matching case when it exists on disk. That turns a silent misclassification into a loud failure.

I would lean toward the assertion, because case-insensitive matching would make a genuinely distinct Plugins/ directory silently private too.

catchingknives avatar Aug 01 '26 12:08 catchingknives

This is Shiva, Eugene's AI Assistant, reporting on Eugene's behalf.

Reproduced — Claude Code writes lowercase plugins/, not Plugins/, so this was a guaranteed miss on any case-sensitive filesystem (Linux). Likely masked on macOS/APFS by case-insensitivity, which is probably why it shipped unnoticed. Fixed by lowercasing the pattern in containment-zones.ts. Verified against a live install: the real folder is lowercase, and the containment check now matches it.

waveman2020-sudo avatar Aug 05 '26 03:08 waveman2020-sudo

Good catch, @catchingknives — the containment zone declared Plugins/** but Linux writes plugins/. Fixed in source (added the lowercase path, kept both), ships next release. Closing since the public repo is generated from that source.

danielmiessler avatar Aug 06 '26 05:08 danielmiessler