Repository navigation
fix(host): a tightened deny or ask rule is not a widening; lifted denials rate by what they restricted (#1036) - #1136
Merged
Conversation
…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.
…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
added a commit
that referenced
this pull request
Nov 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes for users
diff,verify's host comparison, drift andcheckstop calling a tightened Claude Code deny or ask rule a widening, rate a lifted denial by what it restricted, readWebFetch(domain:*)as the whole tool, and name the directory on anadditionalDirectoriesrow.deny: Bash(git push *)→deny: Bash(git *)low removed … 1 widening;checkrequire_review+SHIP-HOST-BOUNDARY-PERMISSION-DENY-REMOVEDdeny: Bash(git *), which this source still declares, matches everything it matched, so no denial is removed;checkallow(host_settings_narrowed)ask: Bash(git push *)→deny: Bash(git push *)⚠ low moved … 1 widening;checkrequire_review(SHIP-AGENT-BOUNDARY-PROTECTED-SURFACE-UNCLASSIFIED)movedchange, 0 widenings,checkallowWebFetch→WebFetch(domain:*)high narrowed …, 0 widenings,checkallow⚠ high added allow: WebFetch(domain:*),checkblock(…-WILDCARD-ALLOW, as for adding a bareWebFetch)deny: Bash(*)beside two additionslow, sorted lastcritical, sorted first;deny: Read(./.env)ismediumadditionalDirectoriesadditional_pathrows../shared,~/x,<external-path:…>, each with a whyRead 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.jsonbut 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.jsonto.claude/settings.local.jsondrops 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.jsonis 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, plus1036_moved_to_local_still_lifts/1036_moved_to_shared_still_liftsin the rule-model table). If the owner wants the two project files treated as one source anyway, that is a one-line relaxation inrestriction_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
26bfa733b3and here.restriction_holderincore/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, orsubsumes(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.heldrecords it;restriction_keptreads it (drift signals, rowsexpands), theliftedset that withholds allow coverage reads it, and the rowwhynames the holder (not oncheck's redacted rows).host_boundary._claude_removed_restrictionscalls the same predicate forcheck'sSHIP-HOST-BOUNDARY-PERMISSION-DENY-REMOVEDandsettings_change_only_narrows.tests/test_host_diff_permission_direction.py::test_restriction_edits_agree_across_routes(wider deny, ask→deny, cross-source move), a sibling oftest_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 assertsdiff.review == verify.review, row shapes equal acrossdiff/verify/check, the widening count,check's decision and violation, drift's signals and the text's ⚠ count.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_removedand1036_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 tabletest_1036_restriction_holder(18 cases, including tool-name case, padding, a*holder, shell syntax).domain:*treated as scoped.Rule.whole_toolis true forWebFetch(domain:*)(Rule.every_domain), and_is_wildcard_allowreads that property, so the grant iswildcard/high.subsumesdecides WebFetchdomain:pairs on their own (_domain_subsumes):domain:*covers every other domain rule; a bareWebFetchand adomain:rule are undecided both ways (only thedomain: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", soexample.*does not matchexample.evil.com, which the old text-prefix reading claimed it did). The bare-vs-domain:and wildcard rules go beyond the issue's "between bareWebFetchandWebFetch(domain:*)": without them the new holder predicate would have helddeny: WebFetch(domain:example.com)bydeny: WebFetch(sandbox denial lifted) anddeny: WebFetch(domain:example.evil.com)bydeny: WebFetch(domain:example.*)— both fail-opens. Side effect, stricter: an addedWebFetch(domain:example.com)beside an allowed bareWebFetchis now a widening (it opens the sandbox to that host).tests/test_permission_lattice.py::TestWebFetchDomainRules(incl. a 1.3.0-baseline re-rating case), rule-model cases1036_every_domain_is_not_a_narrowing,1036_domain_deny_not_kept_by_the_bare_tool,1036_domain_allow_under_the_bare_tool_is_new.host_grants.lifted_restriction_risk: a row that lifts a restriction (expandson 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 belowmedium. Themediumfloor is my reading of the AC "deny Read(./.env)… sorted ahead of low rows":Readislowwhole or scoped, so without a floor that row cannot sort ahead of low rows. Added restrictions and held removals keep the grant'slow. Grants are unchanged (deny/ask grantriskis stilllow).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._grant_valuerenders anadditional_pathgrant's publishedpath(kind-specific, soinstruction_trust_rootrows, which also carrypath, are unchanged), and_whyhas kind-specific text for added and removed.tests/test_capability_diff.py::test_an_additional_directory_row_names_the_directory[added|removed](text and--json).Baselines, fingerprints, goldens
tests/golden/**): none changed.before/afterandwhyfeed no fingerprint or row identity; grant ids andconfig_sha256are unchanged.checkviolations change only where the decision does (a held removal raises noDENY-REMOVED; an addedWebFetch(domain:*)raisesWILDCARD-ALLOWinstead ofALLOW-EXPANDED).origin/main(1.3.0 engine) on a repo holdingallow WebFetch(domain:*), deny/ask rules, a carve-out andadditionalDirectoriesloads and compares ascomparableon this branch: onechangedgrant (the re-ratedWebFetch(domain:*),medium→high,wildcardfalse→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 ofhost_grant_expansion_signalsnow also covers this rule). A tightening edit against that baseline yields no signal.README.mdanddocs/quickstart.mdquote adiffblock whose removeddeny: Bash(rm -rf:*)row is now⚠ mediuminstead of⚠ low(tests/test_host_diff_entry_docs.pypins them).tests/test_host_diff_review_changes.pyexpected three lifted-deny rows atlow; they aremediumnow.Docs
CHANGELOG.md:### Host comparisonunder## 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.txtrebuilt.docs/distribution-surfaces.mdcapability_diffrow and its comment intests/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_policyare untouched (#1133 edits them): the two new reads there are function-local imports ofparse_ruleandrestriction_holder, which can be hoisted once #1133 merges.Out of scope, noticed
checkcompares raw rule text and the rows compare published text (URL permission redaction erases wildcard and closing delimiter, collapsing distinct curl rules #922); for a Bash rule whose URL path is redacted,checkcan decide a cover the rows leave undecided. Same pre-existing split as allow coverage; the rows are the conservative side.Verification
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/ignorelists**/.claude/settings.local.json), and twotest_ci_timing.pycases whose child pytest hit its 60 s timeout at load average ~87; once the load dropped, both pass onorigin/mainand all oftests/test_ci_timing.pypasses 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.jsonis 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../shipgate diff/check --format agent-boundary-json, onorigin/mainand here, give the before/after table above.Closes #1036
🤖 Generated with Claude Code