Skip to content

About

sleight - a path denotation auditor for agent workspace confinement policies: a confinement rule is a predicate over path strings, the filesystem is a many-to-one unstable naming function. Offline, LLM-free, zero dependencies.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Development Experiment 040 — sleight

A path denotation auditor for agent workspace confinement policies.

Offline. LLM-free. Zero dependencies. Pure Python 3.11+ standard library. 50 rules in 9 families, 5 modelled runtimes, 3 modelled volumes, 380 tests.


Thesis

A workspace confinement policy is a predicate over path strings. The filesystem is a many-to-one, unstable naming function. Those two sentences are the whole of it: a policy can only be sound where each string names exactly one object and keeps naming it, and on a real developer's machine neither half holds.

Three functions are supposed to agree about which object is in play when an agent touches a file:

judge(n)   the verdict the policy engine returns for the name n
show(n)    the string the runtime puts in front of the human for approval
open(n)    the object the kernel actually reaches

Every 2026 disclosure in this space is two of those three disagreeing. GhostApproval is show ≠ open — six coding assistants displaying a repository filename while writing to ~/.ssh/authorized_keys. CVE-2026-32232's hardlink bypass is judge making a statement about a name the object also has under another one. The rsync and OpenClaw races are judge and open evaluated at different instants against a tree somebody else can write. Cursor's git-metadata finding is judge matching a directory component that content-level indirection has moved. MagicDot, 8.3 aliases and trailing dots are the volume folding two spellings together after the string comparison has already happened.

sleight computes all three functions over every name a workspace admits and reports every name on which they disagree. The nine finding families are not a taxonomy of vulnerabilities; they are a taxonomy of how the three came apart, which is why one 50-rule catalog covers a symlink, an inode, a Unicode normalization form and a .git file that is not a directory.

The smallest thing that proves it is a tool that, given a captured tree and a policy, hands you a name you can paste into a shell that reaches somewhere the policy meant to exclude — and then tells you which of those names you can fix by deleting something and which you cannot fix at all.


Where this sits in the series

Experiments 001–010 audit a static manifest. 011–022 audit one MCP channel each. 023–024 audit a transport and a rendering surface, 025–026 an A2A artifact, 027–031 a client-side or protocol plane. 032–039 turned inward, to structure inside the agent system: the permission policy it consults (#032 warrant), the memory it writes (#033 revenant), who it may spawn (#034 satrap), the hooks on its tool calls (#035 deadlatch), where its bytes may go (#036 sluice), how its servers compose (#037 entrepot), what happens on retry (#038 reprise), what survives compaction (#039 halflife).

Every one of them shares an assumption sleight exists to attack: that a path is a name for one object.

  • #017 cordon is the nearest neighbour and the clearest contrast. It replays a captured MCP session and asks whether a URI in a message escaped the client-declared roots — a string containment question, correctly answered. It has no tree, no link graph, no inodes, no notion that two strings might be one file. sleight's subject is precisely the assumption cordon has to make.
  • #032 warrant audits the permission policy as an admitted-language question over command patterns, and cites GhostApproval as motivation without being able to reach it: warrant never models a filesystem. sleight is the object side that warrant explicitly does not cover.
  • #036 sluice asks where the bytes may go on the network, and its mechanism is delegation — the allowlist grants a namespace, the attacker rents a leaf. sleight's mechanism is aliasing — the rule names an object, the attacker uses another name for it. Sibling questions, unrelated machinery.
  • #035 deadlatch audits hook definitions. sleight's IND003/IND005 are not about what a hook says; they are about a path rule failing to protect the file that holds it.

Firsts for the series: the first entry whose unit of analysis is the filesystem naming function; the first to compute an escape set and a minimum remediation cut over it; the first to report findings it explicitly cannot remediate.


Quick start

No install, no dependencies.

python -m sleight audit --tree examples/plausible/tree.json \
                        --policy examples/plausible/policy.json \
                        --runtime lexical

or make run. Everything below is reproducible from the shipped fixtures.

sleight capture <dir> -o tree.json    walk a real directory into a portable document
sleight scan    --tree ...            inventory: links, inode groups, alias spellings
sleight audit   --tree ... --policy ...   the report (text | json | sarif)
sleight diff    --tree ... --policy ...   the same input under every modelled runtime
sleight cut     --tree ... --policy ...   what to delete, and what deleting cannot fix
sleight rules | profiles | explain <CODE>

Exit codes: 0 clean, 1 findings at or above --fail-on (default high), 2 bad input. Suitable as a CI gate as-is.


Sample run

$ python -m sleight audit --tree examples/plausible/tree.json \
                          --policy examples/plausible/policy.json --runtime lexical

==============================================================================
sleight -- path denotation audit
  tree      plausible - a repository a careful engineer would ship  (57 objects)
  policy    app workspace - as reviewed and approved  roots=/c/work/app, /c/work/app/packages
  volume    ntfs
  runtime   lexical
==============================================================================

VERDICT   score 0/100   grade F
          24 critical  19 high  16 medium  4 low
          NOT confined: 5 of 33 reachable objects lie outside the boundary or under a deny rule

------------------------------------------------------------------------------
REACH
------------------------------------------------------------------------------
  reachable inside the boundary   28
  reachable outside the boundary  3
  denied objects still reached    2
  reached only behind a prompt    3
  names that did not resolve      1

  escaped objects:
    - /c/etc/passwd
    - /c/home/dev/.ssh/authorized_keys
    - /c/work/app/.env
    - /c/work/app/secrets.json
    - /c/work/shared

------------------------------------------------------------------------------
WITNESSES  (each name below reaches the object on its right)
------------------------------------------------------------------------------
  [CRITICAL] /c/work/app/data/passwd.txt
             -> /c/etc/passwd   (outside-root, via symlink)
             crossing: symlink:/c/work/app/data/passwd.txt
  [CRITICAL] /c/work/app/config/project_settings.json
             -> /c/home/dev/.ssh/authorized_keys   (outside-root, via symlink)
             crossing: symlink:/c/work/app/config/project_settings.json
  [MEDIUM  ] /c/work/app/.ENV
             -> /c/work/app/.env   (denied-object, via case)
             volume folds: case
  [MEDIUM  ] /c/work/app/.env.
             -> /c/work/app/.env   (denied-object, via trailing)
             volume folds: trailing
  [MEDIUM  ] /c/work/app/.env::$DATA
             -> /c/work/app/.env   (denied-object, via stream)
             volume folds: stream
  [MEDIUM  ] /c/work/app/build/cache.bin
             -> /c/work/app/.env   (denied-object, via hardlink)
             volume folds: hardlink
  [MEDIUM  ] /c/work/app/SECRET~1.JSO
             -> /c/work/app/secrets.json   (denied-object, via shortname)
             volume folds: shortname
  ...

And the remediation, which is the half most tools do not attempt:

$ python -m sleight cut --tree examples/plausible/tree.json \
                        --policy examples/plausible/policy.json

escapes: 14
minimum cut of 4 object(s) closes 5 escape(s); 9 escape(s) CANNOT be closed by
deleting anything in the tree

delete:
  /c/work/app/docs/shared                     (junction)
  /c/work/app/config/project_settings.json    (symlink)
  /c/work/app/data/passwd.txt                 (symlink)
  /c/work/app/vendor/active                   (symlink)

cannot be closed by deleting anything in this tree:
  /c/work/app/.ENV
    case-insensitive volume: a property of the volume, not an object in the tree;
    fix by folding the matcher the same way the volume folds
  ...
  /c/work/app/SECRET~1.JSO
    8.3 short-name alias: a property of the volume, not an object in the tree;
    fix by folding the matcher the same way the volume folds
  /c/work/app/build/cache.bin
    hardlink: the object has two directory entries of equal standing and deleting
    either leaves the other; fix by comparing device+inode after open
  ...

cut re-verified against the escape list: consistent

Two things in that output are worth pausing on. The cut is four objects, not five: lib/current -> vendor/active -> /c/work/shared is a two-hop chain, and cutting the second hop closes the chain and the direct link, which is why this is a minimum hitting set rather than "delete every link". And nine of the fourteen escapes have no cut at all — the tool's own remediation vocabulary does not reach them, and it says so instead of proposing something that would not work.


The differential

The same tree, the same policy, five modelled runtimes:

$ python -m sleight diff --tree examples/plausible/tree.json \
                         --policy examples/plausible/policy.json

  runtime              score grade  crit  high  esc-obj  reach
  ------------------------------------------------------------
  deny-by-name             0     F    20    20        5     33
  lexical                  0     F    24    19        5     33
  reference                0     F     5    10        1     28
  resolve-then-check       0     F     5    12        1     28
  win32-naive              0     F     5    12        1     28

  Identical bytes. Under reference this configuration lets 1 object(s) out of the
  boundary; under lexical it lets 5 out, with 24 critical finding(s) against 5.
  Nobody edited a line between those two rows.

This is not a thought experiment. GhostApproval was fixed in three of six products, which means that as of today, handing the same repository to two different coding agents produces two different confinement outcomes. diff is the command that makes that visible.

The reference row is the important one, and it is the result the tool exists to be able to state: a correctly built runtime still does not confine this workspace. One object escapes — /c/work/app/.env, reached through build/cache.bin, its hardlink sibling. Nothing about the checker can fix it, because the escape is a property of the tree.


The nine families

Family Rules The disagreement
LINK 9 an object in the tree redirects: symlink, junction
ALIAS 9 the volume admits a second spelling: case, form, 8.3, stream, inode
INDIRECT 6 file content redirects: gitdir pointer, host-consumed config
DISPLAY 5 show ≠ open — the human approved a string denoting something else
TIMING 4 judge and open ran at different instants against a mutable tree
BOUNDARY 5 the root is not the boundary the policy assumes
DENY 4 a deny rule blocks a spelling rather than terminating access
WRITE 3 the read model and the write model are not the same model
SHAPE 5 the rule set cannot mean what its author meant

sleight rules prints all 50 with explanations and remedies; sleight explain <CODE> prints one.

Confidence is split. CERTAIN when the disagreement follows from the captured tree and the declared policy alone. LIKELY when it additionally rests on a modelled runtime or volume behaviour — and every such finding names the profile whose provenance string a reader should check, printed verbatim by sleight profiles. sleight is modelling behaviour it deliberately refuses to execute, so a reader must be able to check the model rather than trust it.


Architecture

capture.py ──> tree.json ──┐
                           ├──> resolve.py ──> analyze.py ──> reach.py ──> report.py
policy.json ───────────────┘        ▲              ▲            cut.py
                                    │              │
                            profiles.py       catalog.py, corpus.py

capture.py is the only module that touches a filesystem. tests/test_architecture.py walks every other module's AST and fails the build if os, pathlib, io, socket, subprocess, time or random appears in it. The same test asserts that os.walk occurs in exactly one file, and that no module anywhere imports a network library.

That invariant does two jobs. It makes an audit a pure function of a portable document — a capture can be attached to a ticket and replayed in CI by someone who does not have the laptop it came from. And it is what stops sleight from ever testing an escape by attempting one. A dynamic prober was considered and rejected on the merits, not on effort (see RESEARCH.md): verifying that /w/settings.json reaches ~/.ssh/authorized_keys means performing the read the audit exists to prove is possible, from the machine where it matters, leaving it in whatever the local audit log is — and it would be a false comfort anyway, since a link that does not resolve today resolves fine once somebody creates the target. sleight reasons symbolically and says so.

The resolution automaton

resolve.py is the module that earns the tool. os.path.realpath gives you the destination and throws away the derivation; sleight keeps the derivation, because the derivation is what says whether a rule could have stopped it. Every step is classified into one of two kinds, and the distinction drives everything downstream:

  • Edges — symlinks, junctions, gitdir pointers. Objects that exist and can be deleted, so they can appear in a remediation cut.
  • Folds — case, Unicode form, 8.3 names, streams, trailing dots. Properties of the volume. There is nothing to delete.

Hardlinks are neither: the object simply has two directory entries of equal standing, so no traversal happens and no cut exists.

Constructive witnesses

sleight never says "case-insensitivity is dangerous." It synthesizes the specific other spelling, resolves it, and keeps it only if it lands on the object — so every finding carries a name a reader can paste into a shell. A claim it cannot construct a witness for is a claim it does not make. Two tests enforce this end to end: every emitted spelling must resolve back to its canonical target, and every escape witness in the shipped fixture must reach the referent the report names.

Severity comes from the corpus, not from the fixture

Fixtures do not label their own severity. The referent is matched against a corpus of target shapes carrying separate read_class and write_class values — frequently different, and the difference is the point. ~/.ssh/authorized_keys is nearly worthless to read and is remote code execution to write, which is exactly why the GhostApproval chain targeted a write, and why a confinement audit that modelled only reads would have called that repository clean.


Trade-offs

Capture-then-judge, or judge live? Live analysis needs no capture step and is one command shorter. It also makes every result unreproducible, ties the audit to the machine, and — decisively — puts filesystem access in the judgement path, where the temptation to "just check" an escape by opening it never goes away. Chosen: capture-then-judge, enforced by AST test rather than by discipline. Cost: a capture is a snapshot, and TIM001/TIM003 exist precisely to say that a snapshot is not a guarantee.

Hand-written glob engine, or fnmatch? fnmatch translates * to .*, which crosses /. Whether * crosses a separator is a question sleight has to answer both ways — real policies are written by people who assume it does not and evaluated by engines where it sometimes does, and SHP002 reports the gap. Delegating would have silently picked one answer. Cost: ~90 lines of matcher and its own tests. Memory is bounded by a memo table per match; CPU is O(|pattern| × |path|) per rule, negligible at tree sizes a workspace reaches.

Exact minimum cut, or greedy? Exact, by iterative deepening with pivot branching, up to 22 distinct cuttable edges; greedy above that, labelled approximate in the output. "Delete these two links" is advice somebody will follow; "delete these seven, four of which were unnecessary" is advice they will argue with. An approximate answer labelled approximate is useful; one labelled optimal is a lie the reader cannot detect.

Model runtimes, or audit only the policy file? Modelling is the part that cannot be verified from the artifact, and it is also where the entire GhostApproval class lives — a policy file alone cannot tell you whether the check runs before or after resolution. Chosen: model it, mark every dependent finding LIKELY, and print each profile's provenance so the model can be checked rather than trusted.


Two worked surfaces

Both fixtures sit on the same NTFS volume. The remedy is the policy, not a friendlier filesystem.

examples/plausible — a repository a careful engineer would ship and a reviewer would approve. A monorepo symlink, a git worktree layout that moved metadata off a synced volume, a build cache created by a script that used ln instead of cp, a shared docs junction, a group-writable build directory left over from a CI migration. Nothing in it is careless. It produces 63 findings across all nine families, 14 escape witnesses and 5 escaped objects.

examples/confined — the same workload, closed. Not shorter: different. Zero escapes under every runtime, zero critical, zero high, grade A. The monorepo symlink still works.

The single change that did it is the finding this experiment did not expect to produce:

On a folding volume, a deny list cannot be closed. An allow list can.

Every denied object on NTFS has case, trailing-dot, short-name and stream spellings. To close a deny list, the matcher would have to fold exactly as the volume folds, on all four axes, forever. An allow list carries no such obligation: an unrecognised spelling matches no allow rule and falls through to the implicit deny. confined has an empty deny array and no ** in its allow array, and tests/test_examples.py asserts both — along with every number quoted in this README, so the documentation cannot drift from what the tool reports.


Assumptions and limitations

  • A capture is a snapshot. Everything sleight concludes is true of the tree it was handed. TIM001–TIM004 exist to say that a tree anyone else can write is not a tree you can conclude things about, but they cannot tell you what changed after the capture.
  • writable_by is POSIX-only. Windows ACLs need win32security, and sleight ships with zero dependencies. On Windows the TIMING family under-reports; the capture stats say so rather than papering over it, and a Windows capture can be annotated by hand.
  • Runtime profiles are models of five behaviours, not five products. They are derived from published disclosures and vendor documentation, cited in profiles.py and printed by sleight profiles. Do not read a row in diff as a claim about a named product's current version.
  • The reference profile is not a shipped product. It is the runtime this experiment argues you would build if you took the 2026 disclosures as requirements. It exists to give the report a floor: findings surviving under reference are properties of the tree and the policy, not of anyone's implementation.
  • The corpus is curated, not exhaustive. An unmatched referent is graded on escape alone (MEDIUM for write, LOW for read) and describe() says plainly that it is not in the corpus. Escapes are never dropped for being unclassified.
  • 8.3 short names and alternate data streams are captured only when declared. Enumerating them for real needs Win32 calls; the fixtures declare them and a real Windows capture will under-report. FsProfile.shortnames is what tells the analysis they could exist.
  • Junction targets depend on os.readlink handling reparse points. Where it does not, the edge is recorded as unreadable and reported by LNK009 — an unmodelled edge is the one place a confinement claim silently stops being a claim, so it is reported rather than dropped.
  • Glob semantics are sleight's own, documented in policy.py: ** matches zero or more segments, * stops at a separator, a pattern without a leading / is implicitly **/-anchored. Where a real engine differs, SHP002 is the rule that says so.
  • The score saturates. A badly confined surface pins at 0/100, so diff ranks on escapes and criticals first — ranking on score alone would have reported "every runtime agrees" about a configuration letting 1 object out under one runtime and 5 out under another.

Tests

380 tests, green under both runners, no dependencies beyond the standard library:

make test            # pytest
make test-unittest   # python -m unittest, zero third-party packages

Four of them are load-bearing beyond ordinary coverage:

  • test_architecture.py — the purity invariant, by AST walk.
  • test_catalog.py — reads analyze.py's AST and fails if the catalog documents a rule no pass can emit, or if a pass emits a code the catalog does not define. It found LNK002 documented and unreachable during the build.
  • test_examples.py — every number in this README, asserted against the shipped fixtures, including that every witness reproduces.
  • test_hygiene.py — nothing in this repository is an actual symlink, and no directory in it is one a real agent runtime would load settings from. The fixtures describe links, junctions, gitdir pointers and world-writable directories as data; cloning this repository does not put a link to anybody's SSH directory on their disk.

License

MIT.

About

sleight - a path denotation auditor for agent workspace confinement policies: a confinement rule is a predicate over path strings, the filesystem is a many-to-one unstable naming function. Offline, LLM-free, zero dependencies.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages