Skip to content

fix(host): a tightened deny or ask rule is not a widening; lifted denials rate by what they restricted (#1036) - #1136

Merged
pengfei-threemoonslab merged 5 commits into
mainfrom
claude/issue-1036-deny-tightening
Nov 14, 2026
Merged

pengfei-threemoonslab merged 5 commits into
mainfrom
claude/issue-1036-deny-tightening

Conversation

@pengfei-threemoonslab

Copy link
Copy Markdown
Contributor

What changes for users

diff, verify's host comparison, drift and check stop calling a tightened Claude Code deny or ask rule a widening, rate a lifted denial by what it restricted, read WebFetch(domain:*) as the whole tool, and name the directory on an additionalDirectories row.

Edit Before After
deny: Bash(git push *) → deny: Bash(git *) low removed … 1 widening; check require_review + SHIP-HOST-BOUNDARY-PERMISSION-DENY-REMOVED 2 rows, 0 widenings; removed row says deny: Bash(git *), which this source still declares, matches everything it matched, so no denial is removed; check allow (host_settings_narrowed)
ask: Bash(git push *) → deny: Bash(git push *) ⚠ low moved … 1 widening; check require_review (SHIP-AGENT-BOUNDARY-PROTECTED-SURFACE-UNCLASSIFIED) one moved change, 0 widenings, check allow
WebFetch → WebFetch(domain:*) high narrowed …, 0 widenings, check allow ⚠ high added allow: WebFetch(domain:*), check block (…-WILDCARD-ALLOW, as for adding a bare WebFetch)
remove deny: Bash(*) beside two additions low, sorted last critical, sorted first; deny: Read(./.env) is medium
add 3 additionalDirectories three identical additional_path rows ../shared, ~/x, <external-path:…>, each with a why

Read this first: one acceptance criterion is answered differently

The issue asks that "a cross-source move" produce no widening, from a holder in "any source". I checked which sources Claude Code applies together, as the brief asked, and did not accept it. Claude Code's settings page (https://code.claude.com/docs/en/settings, read 2026-11-08) says a cloud session reads .claude/settings.json but not .claude/settings.local.json ("User and project local settings … not read"), and that a session started in a subdirectory reads the local file from the repository root and the shared file from where it started. So moving a deny from .claude/settings.json to .claude/settings.local.json drops it in cloud sessions, and the reverse move drops it in subdirectory sessions. User and managed settings are one machine's; a nested .claude/settings.json is not a source the inventory reads. In repository scope, then, no other source holds a restriction everywhere the removed rule applied, so the holder must be in the same source (any disposition at least as strict). The routes-agree test pins the move as a lifted denial on every route (moved_to_another_source, plus 1036_moved_to_local_still_lifts / 1036_moved_to_shared_still_lifts in the rule-model table). If the owner wants the two project files treated as one source anyway, that is a one-line relaxation in restriction_holder's caller, but it would fail open for cloud sessions.

The four defects and their tests

Each defect was reproduced with a failing test before the fix; the controls (cases that must still widen) and the 1.3.0-baseline guard pass on 26bfa733b3 and here.

  1. Tightenings reported as widenings. One predicate, restriction_holder in core/claude_permission_rules.py: a removed deny rule is held by a deny rule of the same source, a removed ask rule by a deny or ask rule of that source, when the holder is the same text, the same spelling, or subsumes(holder, rule) is True. Never a carve-out, an unconsulted rule, a padded or differently cased rule, another tool's rule, or a holder a ! rule of its own list could carve (order-independent, so it over-reads). PermissionRuleAssessment.held records it; restriction_kept reads it (drift signals, rows expands), the lifted set that withholds allow coverage reads it, and the row why names the holder (not on check's redacted rows). host_boundary._claude_removed_restrictions calls the same predicate for check's SHIP-HOST-BOUNDARY-PERMISSION-DENY-REMOVED and settings_change_only_narrows.
    • Routes agree: tests/test_host_diff_permission_direction.py::test_restriction_edits_agree_across_routes (wider deny, ask→deny, cross-source move), a sibling of test_review_cases_agree_across_routes, which is shaped around allow replacements (before/after = allow: …) and has no slot for deny/ask edits or a second file. It asserts diff.review == verify.review, row shapes equal across diff/verify/check, the widening count, check's decision and violation, drift's signals and the text's ⚠ count.
    • Rule-model table (tests/test_claude_permission_rule_model.py, every route): 1036_wider_deny, 1036_ask_to_deny, 1036_ask_to_wider_deny, 1036_wider_ask, 1036_redundant_deny_removed and 1036_ask_under_an_unchanged_deny_removed (holder unchanged, so only the head inventory knows it), 1036_whole_tool_deny_over_a_path, 1036_kept_restriction_leaves_a_covered_addition_covered; negatives that still widen: 1036_deny_to_ask_still_lifts, 1036_narrower_deny_still_lifts, 1036_undecided_cover_still_lifts (**), 1036_carved_cover_still_lifts, 1036_moved_to_local_still_lifts, 1036_moved_to_shared_still_lifts; and a unit table test_1036_restriction_holder (18 cases, including tool-name case, padding, a * holder, shell syntax).
  2. domain:* treated as scoped. Rule.whole_tool is true for WebFetch(domain:*) (Rule.every_domain), and _is_wildcard_allow reads that property, so the grant is wildcard/high. subsumes decides WebFetch domain: pairs on their own (_domain_subsumes): domain:* covers every other domain rule; a bare WebFetch and a domain: rule are undecided both ways (only the domain: form changes the sandbox's domain lists, per the permissions page); two literal domains never cover each other; any other domain wildcard is undecided (the page: outside a leading *. or bare *, "the wildcard matches only the text between two dots", so example.* does not match example.evil.com, which the old text-prefix reading claimed it did). The bare-vs-domain: and wildcard rules go beyond the issue's "between bare WebFetch and WebFetch(domain:*)": without them the new holder predicate would have held deny: WebFetch(domain:example.com) by deny: WebFetch (sandbox denial lifted) and deny: WebFetch(domain:example.evil.com) by deny: WebFetch(domain:example.*) — both fail-opens. Side effect, stricter: an added WebFetch(domain:example.com) beside an allowed bare WebFetch is now a widening (it opens the sandbox to that host).
    • Tests: tests/test_permission_lattice.py::TestWebFetchDomainRules (incl. a 1.3.0-baseline re-rating case), rule-model cases 1036_every_domain_is_not_a_narrowing, 1036_domain_deny_not_kept_by_the_bare_tool, 1036_domain_allow_under_the_bare_tool_is_new.
  3. Lifted denials rate low. host_grants.lifted_restriction_risk: a row that lifts a restriction (expands on a deny/ask permission row: a removed rule nothing holds, or a widening carve-out) is rated as an allow rule of the same text is (allow_rule_rating, now shared with the grant reader), a carve-out as the paths it excepts, never below medium. The medium floor is my reading of the AC "deny Read(./.env) … sorted ahead of low rows": Read is low whole or scoped, so without a floor that row cannot sort ahead of low rows. Added restrictions and held removals keep the grant's low. Grants are unchanged (deny/ask grant risk is still low).
    • Tests: tests/test_host_diff_permission_direction.py::test_a_lifted_denial_rates_by_what_it_restricted (the issue's repro; diff, verify, check rows and text order), test_a_lifted_path_denial_is_not_filed_with_routine_reads, test_an_added_or_kept_restriction_stays_low; tests/test_capability_diff.py::test_a_lifted_restriction_rates_by_what_it_restricted (7 cases), test_a_restriction_that_lifts_nothing_keeps_its_own_rating, test_a_carve_out_that_lifts_part_of_a_denial_rates_by_what_it_excepts.
  4. Paths missing. _grant_value renders an additional_path grant's published path (kind-specific, so instruction_trust_root rows, which also carry path, are unchanged), and _why has kind-specific text for added and removed.
    • Tests: tests/test_capability_diff.py::test_an_additional_directory_row_names_the_directory[added|removed] (text and --json).

Baselines, fingerprints, goldens

  • Goldens (tests/golden/**): none changed.
  • Fingerprints: none changed. Row severity, before/after and why feed no fingerprint or row identity; grant ids and config_sha256 are unchanged. check violations change only where the decision does (a held removal raises no DENY-REMOVED; an added WebFetch(domain:*) raises WILDCARD-ALLOW instead of ALLOW-EXPANDED).
  • A host-grants baseline saved with origin/main (1.3.0 engine) on a repo holding allow WebFetch(domain:*), deny/ask rules, a carve-out and additionalDirectories loads and compares as comparable on this branch: one changed grant (the re-rated WebFetch(domain:*), medium→high, wildcard false→true) with no expansion signal, as Rate exec-equivalent Bash allow rules (interpreter -c/-e, npx, uv run, docker exec, xargs, env) as reaching arbitrary code #824 did for launcher rules (the Rate exec-equivalent Bash allow rules (interpreter -c/-e, npx, uv run, docker exec, xargs, env) as reaching arbitrary code #824 branch of host_grant_expansion_signals now also covers this rule). A tightening edit against that baseline yields no signal.
  • Quoted output: README.md and docs/quickstart.md quote a diff block whose removed deny: Bash(rm -rf:*) row is now ⚠ medium instead of ⚠ low (tests/test_host_diff_entry_docs.py pins them). tests/test_host_diff_review_changes.py expected three lifted-deny rows at low; they are medium now.

Docs

  • CHANGELOG.md: ### Host comparison under ## Unreleased, above ### Packaging.
  • STABILITY.md: Migration Note: Unreleased — a tightened deny or ask rule is not a widening, and a lifted denial is rated by what it restricted (#1036), at the top of the migration notes where the Unreleased notes go (fix(trust): treat manifest-declared policy packs as trust roots (#1075) #1127's placement).
  • docs/host-boundary-support.md § Claude Code permission rules: held restrictions, every domain, a lifted restriction's severity, additional directories.
  • docs/checks.md (SHIP-HOST-BOUNDARY-PERMISSION-DENY-REMOVED, …-WILDCARD-ALLOW), llms-full.txt rebuilt.
  • docs/distribution-surfaces.md capability_diff row and its comment in tests/test_distribution_surface_parity.py (no claim added: the surface restates the engine's answer).

Protected paths

None. host_boundary.py's imports block and _load_packaged_default_policy are untouched (#1133 edits them): the two new reads there are function-local imports of parse_rule and restriction_holder, which can be hoisted once #1133 merges.

Out of scope, noticed

Verification

  • Full gate at bb18c34862, pytest -m "not perf" -n auto -rfEs --ignore=tests/test_adapter_static_only.py: 23542 passed, 4 failed, 16 skipped, 120 xfailed. The failures are environmental: test_check_unmodelled_host_config_keys.py[local_settings_enabled_plugins-worktree|git_range] (the machine's ~/.config/git/ignore lists **/.claude/settings.local.json), and two test_ci_timing.py cases whose child pytest hit its 60 s timeout at load average ~87; once the load dropped, both pass on origin/main and all of tests/test_ci_timing.py passes on this branch. The second commit adds two rule-model cases; the four touched host test files pass at the head (341 passed).
  • tests/test_adapter_static_only.py: passed. ruff check .: clean. scripts/generate_schemas.py --check: clean.
  • tests/shard_seconds.json is unchanged: a serial JUnit run of the grown files (rule model 271.1 s / 75 cases, permission direction 176.7 s / 34, capability diff 30.2 s / 43) is below their committed weights (305.4, 198.1, 35.6), so no increment was recorded.
  • The issue's reproductions with ./shipgate diff / check --format agent-boundary-json, on origin/main and here, give the before/after table above.

Closes #1036

🤖 Generated with Claude Code

…ials rate by what they restricted (#1036)

Four defects in how host diff rows read Claude Code deny/ask rules and paths.

Held restrictions. A removed deny or ask rule was kept only when unconsulted,
a carve-out or respelled, so replacing `deny Bash(git push *)` with
`deny Bash(git *)`, or moving a rule from ask to deny, was a widening on
every route and `check` required review. One predicate,
`restriction_holder` in core/claude_permission_rules.py, now holds a removed
deny rule by a deny rule of the same source, and a removed ask rule by a
deny or ask rule of that source, when the holder is the same text, the same
spelling or a decided `subsumes(...) is True`; never a carve-out, an
unconsulted, padded or other-tool rule, or a holder a `!` rule of its list
could carve. PermissionRuleAssessment.held feeds restriction_kept (drift
signals, row `expands`), the lifted set that withholds allow coverage, and
the row `why`; host_boundary's `_claude_removed_restrictions` calls the same
predicate for check. A holder in another settings source does not count:
Claude Code's settings page says a cloud session reads .claude/settings.json
and not .claude/settings.local.json, and a subdirectory session reads the
two from different directories, so a cross-source move stays a lifted
denial on every route.

Every domain. `WebFetch(domain:*)` is the whole tool (Rule.every_domain), so
its allow grant is wildcard/high and adding it blocks as bare WebFetch does.
A bare WebFetch and a `domain:` rule are undecided both ways (only the
`domain:` form changes the sandbox domain lists), and a domain wildcard
other than `domain:*` is undecided rather than a text prefix, so neither
can hold a denial it does not. A 1.3.0 baseline's scoped reading of the rule
is a re-rating with no expansion signal, as #824's was.

Severity. A row that lifts a deny or ask rule is rated as an allow rule of
the same text (allow_rule_rating, shared with the grant reader), a carve-out
as the paths it excepts, never below medium; added and held restrictions
stay low. Grants are unchanged.

Paths. An additional_path row renders the published path, with its own why.

Tests: rule-model table cases (tightenings, and controls that must still
widen), a routes-agree test for the issue's three edits, lattice WebFetch
cases, severity and additional-directory rows. README and quickstart quote a
lifted deny row now rated medium. CHANGELOG, STABILITY migration note,
host-boundary support, checks (llms-full.txt rebuilt) and the distribution
surfaces row are updated.
…t lifted (#1036)

The holder is known only from the head inventory, so this pins that every
route passes it: a redundant deny removed under an unchanged wider deny, and
an ask rule removed under an unchanged deny.
Conflicts: CHANGELOG.md keeps both Unreleased entries (Host comparison,
then #1130's Changes); STABILITY.md keeps both migration notes, #1036's
above #1128's. llms-full.txt auto-merged and matches a rebuild.
…put, not yet released

With #1131 merged, these pages quote the published 1.3.0, which rates the
removed deny: Bash(rm -rf:*) row low, the rating it gives every deny and ask
grant. This tree rates a row that lifts a deny or ask rule by what the rule
restricted, never below medium (#1036), so the examples are labelled as
source-tree output until the next release.
@pengfei-threemoonslab
pengfei-threemoonslab merged commit 442a7cb into main Nov 14, 2026
16 checks passed
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.

host diff: tightened deny/ask is not widening; rate lifted denials by what they restricted

1 participant