Skip to content

About

warrant - offline, LLM-free static auditor for the agent permission-policy/consent plane: computes what an allow/ask/deny rule set actually admits and proves each finding with a verified counterexample. Effect-equivalence + 3-model matcher differential. 23 rules, 318 tests.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Development Experiment 032 — warrant

Offline, LLM-free, dependency-free (pure-stdlib) static auditor for the AGENT PERMISSION-POLICY / CONSENT plane — the allow / ask / deny rule set a coding agent consults before it runs a tool call.

Every finding ships with a verified counterexample: a concrete command string that warrant re-evaluated through its own matcher models and confirmed the policy auto-approves. If it cannot demonstrate the bypass, it does not report it.


Thesis

Experiments 001–031 all audit something the other side says: a static manifest (001–010), one MCP message channel (011–022), the HTTP transport (023), terminal rendering (024), A2A (025–026), an MCP Apps bundle (027), the caching timeline (028), the telemetry envelope (029), the header-mirroring plane (030), or an Agent Skill's reachable file closure (031). Each asks is this artifact safe?

warrant audits what the client has already agreed to. A permission policy is not a document to be validated — it is a pattern language, and the security question is not "is this rule well-formed?" but:

What is the full set of tool calls this policy admits, and does that set intersect the effects its author was trying to forbid?

Today's research says this gap is not hypothetical. Bash(cd:*) has been shown to admit cd /p && python x (claude-code #28784); Bash(git:*) has been shown to admit git status && rm -rf … straight past an explicit deny (#36637); $(...) substitution slips through operator-splitting matchers entirely; and GhostApproval / SymJack showed six coding agents rendering an approval prompt that named a different file from the one about to be written (CWE-61 + CWE-451). Meanwhile the deepest observation in the field is that command allowlists are simply the wrong abstraction layer — you name the program when what you care about is the effect, and any allowed code-runner collapses that distinction. You cannot enumerate your way out of it.

The smallest thing that proves the idea is a tool that takes the rule set you already have, computes its admitted language under several matcher models, and hands you the exact string that defeats it.


What it finds

23 finding codes in 5 families.

Family Question it asks
FORM Are these rules structurally capable of firing at all?
ADMIT What do the allow rules admit beyond their evident intent?
SHADOW Are the deny rules actually preventing anything?
PATH Do the path rules confine what they appear to confine?
STACK What does the merged policy across settings files mean?
Full catalog (23 codes)
Code Sev Finding
WF01 MEDIUM Rule does not parse and is silently inert
WF02 HIGH/MED Rule uses the ignored Bash(command:…) form the runtime discards
WF03 INFO Rule fully subsumed by a broader rule in the same list
WF04 LOW Allow rule is dead: an identical deny always wins
WF05 MEDIUM Rule targets an unrecognised tool and can never fire
WA01 CRITICAL Unrestricted Bash grant
WA02 CRITICAL Grant is equivalent to an unrestricted shell (argument injection / runner)
WA03 HIGH Prefix rule admits a command-substitution payload
WA04 HIGH Prefix rule admits chained commands under a head-matching runtime
WA05 MEDIUM Read-shaped grant admits filesystem writes via redirection
WA06 MEDIUM Pinned command executes project-controlled code
WS01 CRIT/HIGH Deny list does not actually prevent the effect it targets
WS02 HIGH Deny rule defeated by re-spelling the program name
WS03 INFO Allow list contains general code runners
WP01 MEDIUM Single-slash path rule is not an absolute path
WP02 HIGH/MED Path rule covers an entire anchor root
WP03 CRIT/HIGH Sensitive paths auto-approved for Read / Edit / Write
WP04 MEDIUM Path pattern climbs out of its own anchor
WP05 HIGH Write grant resolves outside the workspace
WT01 MEDIUM Identical path rule resolves differently across settings layers
WT02 HIGH/MED Unreviewed settings layer grants what reviewed layers do not
WT03 CRITICAL defaultMode is bypassPermissions
WT04 HIGH acceptEdits active with no Edit/Write deny rules

The three ideas that make it more than a linter

1. Constructive, verified witnesses. warrant does not say "this rule looks broad." It synthesises a candidate command, runs it back through the matcher models, and reports it only if a model auto-approves it. Every witness in a report is reproducible by construction, and the tool cannot claim a bypass it has not demonstrated against its own model.

2. Effect-equivalence, not program names. Programs are catalogued by the effects they can produce and a generality tier. A runner (python, make, npm, git, find, env, …) executes caller-supplied code and therefore reaches every effect. So deny: Bash(curl:*) + allow: Bash(python:*) is not a network deny, and warrant says so with the exact command.

3. Matcher differential — disagreement is the finding. The same policy is evaluated under three models of the same matcher:

Model Units it inspects Status
strict segments and command substitutions sound — what the shell actually runs
segment operator-separated segments only the documented behaviour; blind to $(…)
head the whole command line as one unit the shipped defect in #28784 / #36637

A policy that is safe under strict but dangerous under head is a policy whose safety depends on an implementation detail its author never chose. warrant reports which models admit each witness, so you can see whether a finding needs a buggy runtime or lands against a correct one.


Quick start

No installation, no dependencies, Python 3.11+:

python main.py fixtures/effect-routing     # audit a fixture
python main.py .                           # audit a real project's settings stack
python main.py . --format json             # machine-readable
python main.py --file .claude/settings.json
make test                                  # 318 tests
make demo                                  # every fixture, every defect class

CI gate — exits 1 when any finding reaches --fail-on (default HIGH), 2 on unusable input:

python main.py . --fail-on CRITICAL

Sample run

$ python main.py fixtures/effect-routing --min-severity HIGH

==============================================================================
warrant - agent permission policy audit
==============================================================================

  Score  : 26/100   Grade: F
  Findings: 4   (CRITICAL: 2  HIGH: 2  MEDIUM: 0  LOW: 0  INFO: 0)

Policy stack (highest precedence first)
------------------------------------------------------------------------------
  [project   ] /home/dev/project/.claude/settings.json
               allow=2 ask=0 deny=3
  effective defaultMode: default

Effect exposure
------------------------------------------------------------------------------
  credential access            reachable
  arbitrary code execution     reachable
  filesystem read              reachable
  filesystem write             DENIED BUT REACHABLE
  network egress               DENIED BUT REACHABLE
  persistence / autostart      reachable
  process control              reachable

Matcher models evaluated
------------------------------------------------------------------------------
  strict    segments and command substitutions evaluated independently (sound)
  segment   operator-separated segments only; substitutions invisible (documented)
  head      whole command line matched as one unit (observed in #28784 / #36637)

Findings (4 shown)
------------------------------------------------------------------------------

  CRITICAL WA02  Grant is equivalent to an unrestricted shell [project]
           rule: Bash(python:*)
           'Bash(python:*)' looks like a narrow grant, but 'python' can be
           driven into executing arbitrary code using nothing but its own
           documented arguments. No shell operator or substitution is needed,
           so even a matcher that correctly splits compound commands admits
           this.
           witness:
             $ python -c 'import os; os.system("id")'
               python -c executes arbitrary code [auto-approved under:
               strict, segment, head]
           fix: Pin the exact invocations required -- an exact rule has no
           argument-injection surface because the whole command is fixed -- or
           move this capability behind an ask rule.

  HIGH     WS01  Deny list does not actually prevent network egress [project]
           rule: Bash(curl:*)
           The deny list blocks Bash(curl:*), Bash(wget:*), which indicates an
           intent to prevent network egress. That effect remains reachable
           through allowed program(s): python, uv. Deny rules name programs,
           but the property being protected is an effect, and any allowed code
           runner collapses the distinction.
           witness:
             $ python -c 'import os; os.system("id")'
               python -c executes arbitrary code, and arbitrary code execution
               subsumes network egress
           fix: Enumeration cannot close this gap. Constrain the blast radius
           instead (sandbox, container, restricted network egress), or remove
           the code runner from the allow list.

The hardened fixture, by contrast, grades 100/100 A with zero findings and exit code 0.


Architecture

Observation is split from judgement, so a committed fixture and a live settings stack grade through identical code.

loader.py     the ONLY module that touches the filesystem
   |          settings JSON  ->  Policy + Environment
   v
model.py      frozen dataclasses; no mutable module state anywhere
ruleparse.py  total parser: "Bash(git diff:*)" -> Rule  (never raises)
shell.py      total, quote-aware shell reader: segments, substitutions,
              wrapper/assignment stripping, effective program name
paths.py      lexical gitignore-style matching + the four path anchors
effects.py    effect-equivalence catalog: program -> effects x generality tier
   |
   v
matchers.py   three models of the same matcher; (Policy, ToolCall) -> Decision
witness.py    candidate synthesis  ->  RE-VERIFIED through matchers
   |
   v
analyzer.py   pure Policy -> Report. No I/O, no clock, no RNG.
report.py     renders text / JSON; decides nothing
cli.py        argument parsing + CI exit code

Data flow. loader reads each settings file into a PolicyDocument tagged with its layer and its directory (the resolution base for single-slash path rules). Policy unions the rule lists across layers — deny anywhere applies — while scalars like defaultMode resolve by precedence. analyzer then runs five family passes, each of which may call witness to synthesise a counterexample; witness calls back into matchers to verify before anything is emitted.

Determinism. No RNG, no clock, no environment reads in the analysis path. The resolution context (home, cwd) is a declared Environment, not a discovered one, so fixtures grade identically on any machine. Reports are byte-stable and can be committed and diffed.

Two approaches considered

(A) Dynamic probing — drive a real agent runtime with candidate commands and observe which ones auto-approve. Highest fidelity: it measures the shipped matcher rather than a model of it, and would catch defects nobody has characterised yet. Rejected. It requires executing attacker-shaped commands on the host to learn anything (the observable is the side effect), needs a live agent binary and API credentials, and its results expire with the next patch release. Worst of all, an auditor you cannot run in CI on every settings change is an auditor nobody runs.

(B) Static admitted-language analysis with modelled matchers — chosen. Pure, offline, dependency-free, millisecond runtime, safe to run anywhere, and every rule is unit-testable in isolation. Cost: it is only as accurate as the catalog and the matcher models, and it under-reports on programs it does not know. That cost is bought back by the verification step — witnesses are checked against the models before emission — and by modelling three matchers instead of one, so a finding carries the explicit condition under which it lands rather than a single unfalsifiable claim.

Memory / CPU / maintenance. Everything is in-memory over a few kilobytes of JSON; the largest fixture analyses in ~15 ms and the full 318-test suite runs in ~0.5 s. Maintenance is concentrated in one place by design: effects.py is the only file that needs updating as new runners and injection flags surface, and adding a program is a two-line data change, not a code change.


Assumptions & limitations

Stated plainly, because a security tool that overstates its coverage is worse than none.

  1. The rule syntax modelled is Claude Code's (Tool(specifier), prefix:*, the four path anchors // ~/ / bare, mcp__server__tool, deny > ask > allow, the enterprise→user settings precedence). It is the most widely deployed agent permission format and is checked into version control. Other agents' formats would need a loader adapter; the analyzer core is format-agnostic.
  2. The matcher models are models. head reproduces the behaviour in the two cited issues, but a given runtime version may sit between the models or elsewhere entirely. This is why every witness reports which models admit it — treat strict-admitted findings as unconditional and head-only findings as contingent on the runtime.
  3. The program catalog is deliberately conservative. An unknown program is modelled as benign with no effects, so warrant under-reports rather than inventing findings. A project using an unlisted code runner will be graded too generously.
  4. Path analysis is purely lexical. No filesystem access, no symlink resolution. warrant flags write grants that lexically escape the workspace (the policy half of GhostApproval) but cannot detect a symlink planted in a repository — that is a runtime property, and detecting it would require the filesystem access this design deliberately forgoes.
  5. bypassPermissions is reported but not modelled through. Under that mode the runtime auto-approves anything without a matching deny; warrant's other findings are computed from the rule lists alone and therefore understate exposure. WT03 says so explicitly in its detail text.
  6. Effect reachability is a capability claim, not an exploit. WS01 proves the effect class is reachable via an allowed code runner. The witness demonstrates arbitrary code execution, and the explanation states that code execution subsumes the denied effect — it does not synthesise a bespoke exploit per effect.
  7. Witnesses are inert by design. Execution is proved with id; every network payload targets the reserved .invalid TLD (RFC 2606), which can never resolve. Pasting a witness demonstrates the shape of a bypass without doing anything.
  8. No prompt-injection or LLM-behaviour analysis. warrant reasons about the policy engine, not about whether a model can be talked into proposing a bad call. That is a different plane.

Tests

318 passed in 0.50s

Coverage by module: shell reader (segmentation, quoting, substitutions, wrapper arity), rule parser (totality over malformed input), path anchoring and gitignore globs, all three matcher models — including direct reproductions of #28784 and #36637 — the effect catalog's internal consistency, witness synthesis and the verification invariant that no unverified witness is ever emitted, every one of the 23 finding codes in isolation, loader totality over hostile JSON, rendering determinism, and CLI exit codes.

Two bugs were found by the tests during development and fixed: wrapper flags that take a value (sudo -u root python resolved to root), and Bash(env:*) resolving to no program at all and so escaping analysis entirely — both now have regression tests.

Layout

warrant/          the package (11 modules, pure stdlib)
tests/            318 tests across 6 files
fixtures/         6 policy stacks, each isolating one defect class
  hardened/         grades 100/A — the control
  shell-equivalent/ narrow-looking grants that are really shell grants
  chain-escape/     the #28784 / #36637 matcher defect
  effect-routing/   deny lists routed around by an allowed runner
  path-anchors/     the single-slash trap and confinement escapes
  stack-drift/      an unreviewed local layer widening the whole stack
main.py           one-command entry point
make_fixtures.py  regenerates fixtures/

License

MIT — see LICENSE.

About

warrant - offline, LLM-free static auditor for the agent permission-policy/consent plane: computes what an allow/ask/deny rule set actually admits and proves each finding with a verified counterexample. Effect-equivalence + 3-model matcher differential. 23 rules, 318 tests.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages