Repository navigation
Description
permission-rule-check.sh fires an error on two rule forms its own criteria.md declares exempt and
the official docs present as correct, prints an eight-character fragment instead of the rule at fault,
misses the one non-portable form on this platform that genuinely violates the convention, and has no
check at all for the inert-grant shape that is the most common real defect in this fleet. All five sit
in one file and its test suite, and the suite passes 72/72 today because none of these cases is in it.
Rows
- A2 —
scripts/permission-rule-check.sh:153-159vsreference/criteria.md:64-65—criteria.mdsays//…forms are not flagged;P2_EREhas no//exemption, soRead(//Users/alice/secrets/**)— the docs' own literal example — produces a P2error. - A3 —
scripts/permission-rule-check.sh:174-175— P2 feedsgrep -oE "$P2_ERE"straight into the finding, so it prints an eight-character fragment (/Users/k) rather than the offending rule, violating the intent stated for P1 six lines earlier. - A19 —
scripts/permission-rule-check.sh:138,:144—P1_EREalternative 3 lets the required*sit arbitrarily far past the manager name, soBash(npm view ctx7 version*)is flagged as a bare package-manager wildcard although every meaningful token is pinned. - A12 —
scripts/permission-rule-check.sh:156—Bash(~kyle/scripts/x.sh:*)leaks a username and is not flagged.%USERPROFILE%/$env:USERPROFILEforms are also missed, but those are a different defect and must not be filed under P2 — see below. - A7b —
scripts/permission-rule-check.sh(no such check exists) — nothing detects the inert${CLAUDE_PLUGIN_ROOT}-in-allowed-toolsshape, which is the check that would have caught every one of the seven grants fix(plugins): paired body+rule rewrite for seven interpreter-led allowed-tools grants #2221/fix(plugins): pair seven allowed-tools grants with the invocations they must match #2225 had to fix by hand.
Evidence
A2 — the // exemption is claimed and does not exist
reference/criteria.md:64-65 at HEAD:
**How to check**: run the detector. `${CLAUDE_PROJECT_DIR}/…`, `~/…`, and `//…` forms are not flagged
(they expand or are portable anchors); only concrete usernames match.
scripts/permission-rule-check.sh:153-159 — the pattern, unchanged at HEAD:
_sl='/'
_bs='\'
_seg="[^${_sl}${_bs}*<>\${}~ ]"
P2_ERE="${_sl}Users${_sl}${_seg}" # macOS + POSIX-normalized Windows (/c/Users/…)
P2_ERE="${P2_ERE}|${_sl}home${_sl}${_seg}" # Linux
P2_ERE="${P2_ERE}|[A-Za-z]:[${_sl}${_bs}]Users[${_sl}${_bs}]${_seg}" # raw Windows drive
Reproduced by assembling the shipped fragments verbatim and piping through grep -oE:
$ printf '%s\n' 'Read(//Users/alice/secrets/**)' | grep -oE "$P2_ERE"
/Users/a
$ printf '%s\n' 'Read(~/Documents/*.pdf)' | grep -oE "$P2_ERE" # (no output — correctly exempt)
Mechanism: _seg excludes ~, $, {, < but not /, and the ERE is unanchored, so a leading
extra / is simply skipped over. The ~/ exemption works; the // exemption claimed on the same
criteria.md line does not exist.
https://code.claude.com/docs/en/permissions § Read and Edit, fetched 2026-08-11 — table row:
`//path` | Absolute path from filesystem root | `Read(//Users/alice/secrets/**)` | `/Users/alice/secrets/**`. The false positive fires on the documentation's own literal example, in
the check graded highest, and the two shipped files disagree with each other so a maintainer reading
criteria.md cannot predict the detector.
This row was recorded as corroborating evidence inside #2248 and was not fixed by it. #2248's fix
(merged as #2259) rewrote P2's rationale; P2_ERE is byte-identical to what it was before. Filing it
here so it does not stay parked inside a closed issue.
A3 — the finding prints a fragment, not the rule
scripts/permission-rule-check.sh:174-175 feeds grep -oE "$P2_ERE" straight into $m. Reproduced:
$ printf '%s\n' 'Bash(/c/Users/kyle/x.sh:*)' | grep -oE "$P2_ERE"
/Users/k
The stated intent is in the same file, scripts/permission-rule-check.sh:140-141, attached to P1_ERE
only:
# Each alternative captures the whole Tool(...) spec (trailing [^)]*\) ) so a
# finding reports the full offending rule, not a substring truncated at the *.
P2_ERE has no such trailing capture, so the error-tier finding is unactionable as printed: an
operator cannot tell which of several rules is at fault. Same-file fix as A2.
A19 — a fully-pinned package-manager rule is flagged
scripts/permission-rule-check.sh:138 and :144:
_runner='npx|bunx|uvx|pnpm dlx|yarn dlx|pipx run|uv run|npm|pnpm|yarn'
P1_ERE="${P1_ERE}|(Bash|PowerShell)\\([\"' ]*(${_runner})([\"' :][^)]*)?\\*[^)]*\\)"
The ([\"' :][^)]*)? group accepts a separator followed by any run of non-) characters, so the
required \* may sit arbitrarily far past the manager name. Bash(npm view ctx7 version*) therefore
matches even though every meaningful token is pinned. The script's own comment states the contract the
regex does not deliver — "A fixed subcommand (Bash(npm test), Bash(npm run build)) carries no *
and is not matched" — and reference/criteria.md:44-46 now restates it: "Each P1 alternative requires a
wildcard, so an exact narrow rule … is not flagged". A trailing * after a fully-pinned subcommand is
not the bare-wildcard shape the check aims at.
The rule being violated: docs/conventions/permission-rule-hygiene/README.md:99-100 — "A fixed
package-manager subcommand … carries no wildcard, carries over into auto mode, and is not flagged."
https://code.claude.com/docs/en/permission-modes, fetched 2026-08-11: "Narrow rules like
Bash(npm test) carry over." npm view is not a run command and grants no arbitrary execution.
Why this row exists at all: the originating item filed a defect against a live plugin
(context7/setup, Bash(npm view ctx7 version*)) that turned out to be a non-defect — the flag was
this regex over-reach, not the rule. Its real cost is auditor credibility, and without this row nothing
in the ledger carries the fix.
Fix shape: bound the intervening span so Bash(npm *), Bash(npm:*), and Bash(npx *) still match
while Bash(npm view ctx7 version*) does not, and add both a positive and a negative case — the suite
has neither, which is why 72/72 passes today.
A12 — one real miss, and two that need a convention change first
Reproduced against the shipped P2_ERE; all three produce no output:
$ printf '%s\n' 'Bash(%USERPROFILE%/scripts/x.sh:*)' 'Bash($env:USERPROFILE\scripts\x.sh:*)' 'Bash(~kyle/scripts/x.sh:*)' | grep -oE "$P2_ERE"
(no output)
The detector does scan PowerShell(...) (P1_ERE at :142-145, scan_bare_tool at :191), so the
Windows surface is in scope.
Split the row, and do not file the whole of it under P2. Checked against
docs/conventions/permission-rule-hygiene/README.md:106-118, whose anti-pattern 2 is scoped to
"hardcoded absolute machine/user paths" that "leak a username into version control":
Bash(~kyle/scripts/x.sh:*)— does violate it. It leaks a username and~useris not expanded in a Bash rule. This is the P2 miss.%USERPROFILE%/$env:USERPROFILE— leak no username and are not absolute. They are a different defect (an unexpandable token making the rule inert, the same class as A7b), which no convention rule currently names. Filing them under P2 would be inventing a rule. Fold them into A7b's new inert-grant check instead.
https://code.claude.com/docs/en/permissions, fetched 2026-08-11 — the § Wrappers paragraph confirms
the only env handling in Bash rules is stripping a leading assignment of known-safe variables;
nothing expands %VAR% or $env:VAR mid-string, so those rules cannot match.
A7b — no check for the inert-grant shape
The detector has no such check by construction. _seg at scripts/permission-rule-check.sh:156
explicitly excludes $ and {:
_seg="[^${_sl}${_bs}*<>\${}~ ]"
so every ${…} form — correct or inert — is exempted from P2. P1_ERE matches the bash prefix but
says nothing about the variable. Confirmed empirically: the fleet's inert grants were flagged only as
P1.
The question the originating item left open is settled, and the fix should not carry the ambiguity.
https://code.claude.com/docs/en/skills, fetched 2026-08-11: "Claude Code substitutes
${CLAUDE_SKILL_DIR} and ${CLAUDE_PROJECT_DIR} in two places: the skill's markdown content, and Bash
rules in the allowed-tools frontmatter." ${CLAUDE_PLUGIN_ROOT} does not appear anywhere on that
page. https://code.claude.com/docs/en/plugins-reference § Environment variables scopes its broad row
to content, not frontmatter ("| Skill and agent content | Anywhere the placeholder appears |"), and
frontmatter is not content. This repo's own convention already ruled on it at
docs/conventions/permission-rule-hygiene/README.md:125-126: "${CLAUDE_PLUGIN_ROOT} is not among
them … so a rule written with it stays a literal string, never matches, and the grant is inert." The
item's contrary "working reading" rests on a third-party comment in anthropics/claude-code#55382 and
is not doc-supported.
Design constraint (from the packet's own correction, verified): the new check must branch, not
emit a flat remedy. If the referenced path resolves inside the scanned file's own skill directory →
recommend the ${CLAUDE_SKILL_DIR} form. Otherwise → recommend relocation, and not plugin bin/
(see the sibling issue in this batch on the remediation surface, and the Known gap at
docs/conventions/permission-rule-hygiene/README.md:177-179). The detector already knows which file it
is scanning, so the branch is computable.
Adjacent, deliberately not duplicated
- fix(claude-config): audit-permission-grants P2 states an unsupported no-expansion rule and emits it on rule classes that do expand #2248 (closed) rewrote P2's rationale text; fix(claude-config): permission-rule-check falls through to $PWD and sweeps the user profile, exiting 0 #2249 (closed) removed the
$PWDfallback. Neither touchedP2_EREorP1_ERE. - fix(plugins): paired body+rule rewrite for seven interpreter-led allowed-tools grants #2221 / fix(plugins): pair seven allowed-tools grants with the invocations they must match #2225 (closed) fixed the seven fleet grants by hand. A7b is the check that would have found them.
- repo-fleet-hygiene: allowed-tools grant uses a variable not substituted there, and the project-config rung is unreachable #1798 (closed) fixed one instance of the inert-variable shape; the generalized check was never built.
- fix(repo-hygiene): finish clean's invocation pairing in context/*.md, gated on ${CLAUDE_SKILL_DIR} substitution scope #2237 (open) is gated on the same
${CLAUDE_SKILL_DIR}substitution scope.
Provenance
Severity: MED · Provenance: AUDITOR_VERIFIED for A2, A3, A7b, A12. A19 is SELF_REPORTED — it was produced by the validation pass in the consuming session while disproving the item's context7 row, with no independent audit behind it; its mechanism was verified by reading the assembled ERE and by reproduction. Every reproduction above was re-run against the shipped fragments at HEAD.
Origin: handoff-inbox item 20260811-024628-claude-config-audit-permission-grants-defects-and-fleet-grant-hygiene
Ledger: .work/handoff-inbox-batch-4/ledgers/I10-permission-grants-fleet.md § A2, A3, A7b, A12, A19
Verified against repo HEAD 9b34a82a. Line anchors re-derived at that commit — #2259 added 52 lines to the detector, so every ledger anchor past line 76 has moved.
Activity
kyle-sexton commentedon Aug 12, 2026
Re-verification at
origin/main— all five rows reproduce, but A19's anchors movedAnchors here were taken at
9b34a82a.e48b141a(#2260) has since extracted the P1 rule vocabulary out of the detector into a new define-only library, so two of this issue'sfile:lineanchors are stale. The defects themselves are unchanged. Everything below is a command I ran atorigin/main, with its output.A19 — anchors moved to
plugins/claude-config/lib/permission-patterns.sh:59-61P1_EREis no longer built in the detector. It is assigned from the library:The over-reaching group the row names —
([\"' :][^)]*)?before the required\*— is intact on both the interpreter alternative (:59) and the runner alternative (:60). Fix it at the new location, and note the blast radius grew:lib/permission-patterns.shis now a shared library with a second consumer (audit-permission-state), so a change there is no longer scoped to one detector. It has its ownlib/permission-patterns.test.sh, which is where the positive/negative pair belongs.Reproduced against the shipped library, sourced verbatim:
So the contract the script's own comment states — "A fixed subcommand … carries no
*and is not matched" — holds for the no-wildcard case and fails for a trailing*after a fully-pinned subcommand, which is the shape the row is about.A2, A3, A12 — reproduce unchanged;
P2_EREis still built in the detectorP2_EREwas not extracted; it is still assembled atscripts/permission-rule-check.sh:152-155, so those anchors are only slightly shifted. Reproduced by assembling the shipped fragments verbatim:All three land exactly as filed.
A7b — no change
Still no inert-grant check by construction:
_segexcludes$and{, so every${…}form is exempt from P2.One sequencing consequence. Because
P1_EREnow lives in a sharedlib/with two consumers, A19's fix touches a file outsideskills/audit-permission-grants/. That is still insideclaude-config, so it stays in this lane, but it is worth knowing before the diff is written.Verified at
origin/main(post-#2301). Lane CC, handoff-inbox batch 4 wave 2.kyle-sexton commentedon Aug 12, 2026
Correction to my own comment above — A2's premise does not survive the docs
In my re-verification comment I reproduced A2 and reported it as confirmed:
The reproduction is correct —
Read(//Users/alice/secrets/**)does produce a P2error, andcriteria.md:64-65does claim//…forms are exempt. What I did not do is check whethercriteria.md's claim is true. It is not, and that changes which side of the inconsistency should move.criteria.md:64-65groups three forms together and gives one shared rationale:That rationale holds for the first two and fails for the third. https://code.claude.com/docs/en/permissions, raw markdown fetched 2026-08-12, line 279:
//pathRead(//Users/alice/secrets/**)/Users/alice/secrets/**~/pathRead(~/Documents/*.pdf)/Users/alice/Documents/*.pdf~/expands per user — portable.//is the absolute anchor: it resolves to/Users/alice/secrets/**, hardcoding the username. Line 285 of the same page is explicit that this is//'s whole purpose:So
//Users/alice/…is not an exception to "hardcoded machine path" — it is the canonical spelling of one. P2's own finding text says the rule "names a concrete user home, so it breaks on other machines and usernames and leaks a username into source control", and the documentation's example leaksalice.What this means for A2
The inconsistency A2 reports is real:
criteria.mdand the detector disagree, and a maintainer readingcriteria.mdcannot predict the detector. That part stands and is worth fixing.The direction the row implies is, I now think, backwards. A2 is written as "the
//exemption is claimed and does not exist", which reads as make the exemption real. Doing that makes P2 blind to the docs' own canonical hardcoded-path spelling — a false negative on anerror-tier check whose entire purpose is catching a leaked username. The alternative resolution is to drop//fromcriteria.md's exemption list, leaving the detector's current behavior correct and fixing the document instead. That lands naturally in #2284, which ownscriteria.md's staleness.I am not editing the row unilaterally; this is a maintainer call, and it is now raised on the PR that implements it.
Where this is live
#2382 implements A2 in the make-the-exemption-real direction. I have left it a COMMENT review with two unresolved inline threads (GitHub refuses
REQUEST_CHANGESon a same-account PR), covering this premise plus two things I measured on that branch:P2_RULE_EREanchors on(Read|Edit|Write|Bash|PowerShell)\(, so a hardcoded machine path in aWebFetch(...),Agent(...),Glob,Grep,NotebookEdit, ormcp__*rule is no longer flagged at all. The pattern it replaces matched the path regardless of tool, and this file has a dedicatedscan_agent(), soAgentis unambiguously in scope. Not requested by A2 or A3.[[ "$m" == *"(//"* ]], a substring test on the whole rule, soRead(//opt/data/../Users/kyle/secrets)is silently clean despite naming a concrete user home.A3 and A19 on that PR I verified by execution and they are correct.
Recording the class, since this batch has been counting them: this is a fourth instance of a real symptom paired with a false stated mechanism — and the first one I introduced myself, by re-verifying a reproduction without re-verifying its rationale. Reproducing the symptom is not the same as checking the mechanism.
Lane CC, handoff-inbox batch 4.
fix(claude-config): tighten permission-rule-check P1/P2 precision
fix(claude-config): keep machine-path fixtures and doc quotes free of…
fix(claude-config): tighten permission-rule-check P1/P2 precision (#2382