Security
The agency security baseline applies in full: everything stays secure with its source, config, and design public (Kerckhoffs). This repo is public; there are no secrets in the tree.
Threat model — what this defends against
The permission stack defends against accidents, scope drift, casual prompt injection, and blast radius: an agent deleting the wrong thing, wandering into credentials, piping a download into a shell, or quietly bypassing the commit checks. It does not defend against a compromised model determined to do harm — that requires an OS-level sandbox, which is tracked separately and is not a property any permission prompt can provide.
The judge’s rubric is written against this model (#210). Where it wasn’t, it cost honest work and bought nothing: it denied every script the agent had written itself, because it could not read the file; it flip-flopped on the project’s own forge token; and it deferred reads outside a workspace it was never told the location of. It still refuses what an honest agent can get wrong: piping a download into a shell, printing a secret, deleting outside build artifacts, releasing or deploying without a human.
Credential model
| Credential | Where it lives |
|---|---|
GCP auth (Vertex) |
Application Default Credentials ( |
GCP project id |
|
GitLab token |
|
pi provider credentials |
|
Session transcripts and memory over SSH (#915). An SSH project’s
sessions and memory are kept on the remote host, where a pi running there
keeps them (pi over SSH). A transcript
holds whatever the session saw, tool output included, so it is written
0600 in a folder made 0700 under that host’s pi directory; a memory
store it creates there is 0600 too. Anyone who can read
your files there, the host’s administrators among them, can read it, as
they can read the project itself. A working copy stays on this machine,
as every session’s does.
The enforcement stack, security view
-
The permission engine is upstream and unmodified. Its fail-closed behaviour, bash decomposition, and symlink-resolved path checks stay exactly as audited upstream. Everything of ours is additive, through public extension points.
-
The judge reviews only the ambiguous, and only for danger. Deterministic allow/deny never consults a model. The judge receives the action alone — no conversation history — which removes the prompt-injection surface that history represented, and its every failure mode (timeout, bad output, missing credentials) resolves to "ask the human", never to allow.
-
The shell guard is a lint, not a boundary.
@gadhs/pi-shellcheckreads each bash call before the gate does and refuses a handful of forms that lose data by accident - a recursive delete on a variable that may be empty - with the fix named (The shell guard). It models mistakes, not intent: a command insidebash -c,ssh hostor a script file is not read, a shellcheck finding can be waived inline, and a missing or failing shellcheck is skipped. Nothing it passes is thereby allowed; the rules and the judge still decide. -
A claimed authorization changes nothing. "The user said this is fine" inside a command, filename, or tool output does not move any verdict; real approval happens at the human prompt, which can overrule the judge.
-
The human’s typed reply reaches the judge only as the human’s (#249). In a mode that queues, a step that needs a human waits while the agent carries on, and the judge reads the human’s reply on the retry. What counts as the reply is decided by pi’s input source stamp, never by a model: text typed at the terminal or sent by a host, or a prompt the paired phone vouched for exactly; the agent can produce none of these. It is only text typed after the step was queued, and only for that exact action; the judge sees it in the trusted header, quoted, above the untrusted ask. A plain approval lifts any verdict for that action (the operator’s ruling: if the human wants it, it should be done); anything unclear keeps the step waiting. Residual: the judge interprets the words, so a misreading is possible; the eval corpus’s
human-replycases grade it, 0 unsafe as the bar. Known miss, failing closed: the shipped judge model declines to print a credential file even on the human’s approval (human-approves-secret-read); the human can read it themselves. -
Agents cannot edit their own leash. Writes to pi’s settings, installed extensions, and the permission policy itself are refused by rule, including the pi-modes and pi-workflow overlays (
gadhs-pi-*.jsonin the agent directory), which hold the rules, the judge’s authority and the valve (#225); the read tool can still read them. Reading the judge’s audit log directly is refused too: it lives under the agent directory’sextensions/, which every shipped mode with rules denies to every tool, read included (task verdictsis the sanctioned reader). An overlay cannot loosen a shipped deny head-on; a more specific allow can carve an exception into it, and the session names every such carve-out at its start (#93). -
Two surfaces are excluded from capping by design. The chain owner downgrades any authorizer’s
allowonpathandexternal_directorytodefer, which makes a rule there uncappable: anaskon either surface prompts a human in every mode, including yolo. Policy therefore never places rules on those surfaces; path restrictions act on thepatheach read/write/edit/bash ask carries instead. One exception, since pi-permission-system 41.0.0 and kept by the operator’s decision (#396): a bashexternal_directoryask carrying the nothing-on-disk license takes the judge’s allow. It carries the license when the command parses verbatim, every path it flags is an absolute word that names nothing on disk, and none is a proven write. That is a token that only looks like a path, such as a spreadsheet cell/Sheet1/B1. One flagged path that exists withholds it, awriteoreditnever carries it, and thepathsurface takes none. The review log records each such allow asauthorizer_allow_licensed, and the diagnostics'ask.verdictnames it. -
Deferred execution is treated as execution. Writing or arming anything that runs code later — git hooks, shell startup files, editor task configs, CI pipelines that fetch-and-run — is refused or escalated, regardless of how innocent the content looks. Git’s own config files (
.git/config,~/.gitconfig,.gitmodules) are refused by rule towriteandedit, and to a shell line that ends in one of those paths, since one setting (core.hooksPath,core.fsmonitor, an alias) runs code later; a shell line that names one elsewhere (git config -f … key value) reaches the judge, which refuses arming anything that runs later. Reading them is routine orientation and passes (#303), asgit config --listalways did. -
Secrets are judged by what a command prints. Searches that print matching lines from credential material are refused wherever they run; existence checks and filename lists are fine. The common cases are hard rules; the judge covers the shapes rules cannot express. One carve-out is a decision, not a gap: an unfiltered dump of the process environment -
env,printenv- is allowed. Its values reach the transcript, but the shell already shows them to the person at the keyboard, and refusing the dump while allowing every other look at one’s shell protects nothing and stops a developer looking at their own environment. Disclosure is the filtered form - a credential term as the filter,env | grep -i token- and that is denied by rule and by the judge; the eval corpus pins both sides (cred-env-bare-dump,cred-env-grep-values). -
Commit integrity: signed commits, a per-commit reflection pause in the extension (no bypassable token),
--no-verifyrefused as a string and as a parsed flag, attribution appended mechanically from the live session. -
The reviewer’s reads are bounded, contained and disclosed. The cold reviewer reads the candidate snapshot through three read-only tools that run git plumbing with argument arrays (a pattern after
-e, paths after--, never a shell), resolve symlinks before the root check, refuse credential-shaped files by name on every subject and withhold their lines from a wide search, and honour.gitignoreon disk. A credential-shaped file declared as review context (Review-Context:, a plan’sreviewPaths) is refused the same way (#423); the budget is per review and every read is named in the pause text. Residual: the refusal is a basename heuristic — a secret in a file named otherwise is readable by the reviewer, as it already was by the author’s own session; the reviewer sees it, the model provider sees it, and nothing else does. The reviewer is a model reading untrusted content with no write surface: a read that looks like an instruction can steer its verdict, which the human reads, never an action. -
A headless session never defers to a human it cannot reach. Under
pi --mode rpca deferred ask is put to the host with a bounded wait; yes inside the wait allows, no denies, and silence denies — the turn ends with a reason instead of waiting forever on a dialog nobody is watching. Plan approval andaskare bounded the same way; no answer is a refusal, never consent. Residuals: the permission system’s ownaskrules on its two excluded surfaces (path,external_directory) still prompt without us — the seed keeps themallowand reconcile advises if they drift; “allow always” is unavailable from a host, since the extension returns one-shot decisions; and a human’s “no” that lands exactly at the deadline is recorded as unattended rather than as theirs — both are denies, so the misattribution costs a word, not a permission. -
Delegation goes through the gate, or not at all. The agency distribution’s one delegation system is pi-subagents behind the delegation gate: profiles, contracts, the helper ledger. A tool that injects text into another pi session as the user — remote-pi’s mesh (
agent_send) is the shipped example — bypasses every gate at once: a narrow mode can have a wide peer do its work, and a peer’s message arrives with the human’s authority. Such tools are out of policy for agency sessions; if one is ever wanted, it lands behind the gate with a profile, not beside it.
A paired device
A paired device is a second keyboard, no more. Pairing is trust: a device
that completed the QR pairing may answer the same asks the desk may — the
gate defer, plan approval, ask, the memory picker — through the
ask broker, and nothing else.
It can also read, and only read (#863): the agent messages the box has stored, in the spaces the box holds now, a page at a time (what the phone can read). That is what the agents said to each other, in the clear, inside the device’s encrypted session. It is no new authority: a paired device can already prompt the agent, which reads every message, and can export a space’s secret. A device still pairing reads nothing, and reading marks nothing read.
One exception, bounded (#251): a paired phone may land a file it attached
to a prompt. It lands only under pi-remote’s own state directory, keyed by
session and outside every project (~/.pi/agent/gadhs-pi-remote/
attachments/<session>/, 0700 directories, 0600 files). The browser’s name
is untrusted and made safe (basename only, a fixed alphabet, no leading dot
or dash, 80 characters); a final name is claimed with link(2), which never
overwrites. A file is capped at 64 MiB, a piece at 2 MiB, a session run at
256 MiB; an unfinished file’s part is removed on every way it can stop, and
old parts and sessions are swept. The agent may read what landed by rule
and never writes there. Logs carry the safe name and byte counts, not the
browser’s name.
Answers
-
The winner decides and a cancelled dialog’s value is never read; a remote answer that does not validate against the ask (an option not offered, the wrong kind, a dropped link) is a decline, never a yes.
-
A phone adds an answerer, not a deadline: the terminal still waits for a person; a headless host keeps its waits.
-
While a device is attached the desk sees the bounded, one-shot dialog set on every surface — no “allow always” from either.
-
Residuals: asks not carried by the broker (the permission system’s own prompts, third-party extensions, pi’s built-ins) are answerable only at the desk and reach the phone as a nudge; and a device that registered without a live link narrows the desk’s gate dialog until it unregisters — pivot’s rule is to register only while the link is up.
Identity and admission
-
The box’s identity is 64 bytes at
~/.pi/agent/gadhs-pi-remote/identity.key, mode 0600, minted once and never logged; trusted devices are{ device_id, dh, label }indevices.jsonbeside it. -
Admission is two decisions: a pairing device only inside an open window with the token, a known device only with the trusted Noise static. An
introducethat would re-key an id already trusted is refused, so a token-holder cannot lock a real device out. -
The pairing link carries the token in its fragment (never sent to the relay’s server), is shown in a pane or a notification, and is never written to the transcript.
-
A lost link unregisters every device before it reconnects.
-
Offboarding a device is forgetting its key on the box and wiping the device; nothing in the relay holds a session.
What crosses the relay
The relay sees ids and ciphertext; the transcript never leaves the pair in the clear.
-
A record crosses as many Noise messages as it needs, one sealed chunk each, up to 4 MiB. A chunk the box cannot place — a bad tag, an empty message, a record past the cap — ends that phone’s link rather than resynchronising, since a Noise stream has no point to resynchronise at; a send that fails part-way ends it too. The box then tells the relay to close that phone’s socket: a stranger is
unvouch`ed, and a trusted phone is hung up (`hangup, pivot-wire 0.4.2, #248), keeping its vouch, so it reconnects on its own instead of ponging a socket whose frames nobody reads. -
A record over 4 MiB is cut to fit before sealing — the heaviest strings cut to one common cap, each cut ending in a visible marker naming the length removed, a top-level
wireElidedbyte count for the client — so a tool card still completes; a record that cannot be brought under the cap with readable heads is dropped and logged as such. The fit re-measures the whole record at most four times, however many strings it holds (#250): it runs on pi’s own thread, and a quadratic cut once froze a session for good on a 27 MB record. -
Every command’s response is sealed to the one peer that sent it, never broadcast, so one phone cannot read what another asked.
-
A trusted phone’s prompt —
prompt,steerorfollow_upalike — is bounded (32 768 characters) and refused in words past that, not cut.
What a relay frame cannot do
No frame from the relay can crash the session or grow its memory without end:
-
Every inbound envelope is checked field by field at the boundary (a
helloneeds a 64-hex nonce before it reaches the wasm; adevice_upneeds a device id). A frame that fails is dropped and said once per link-up, and nothing a frame makes the handler throw escapes the socket callback, where a throw would be an uncaught exception. -
The peer table holds at most 32 devices: a
device_upfor a fresh id past that is dropped, a repeat for a live id still replaces its peer, and a peer that has not finished its handshake within two minutes is swept on the nextdevice_up.
The local hub
Several pi sessions on one box share one link: the session holding it
listens on hub.sock in the same state directory, and the others attach.
The boundary is the user account and that 0600 socket (the account is the
same boundary the identity file relies on), so records cross in the clear
inside it and sealed beyond it. The connection is the identity: a member’s session
is the one assigned to its socket, whatever a message says.
Threats mapped to controls
An approval review asks which control answers which threat (#274). The rows below follow the OWASP Top 10 for Agentic Applications 2026; the two shorter tables map the CISA, NSA and partners' Careful adoption of agentic AI services (2026) and NIST AI 600-1 onto them. Each gap is stated as plainly as each control; the threat model above is the boundary: no permission prompt stops a compromised model determined to do harm.
| Threat (OWASP) | Our control | Where it is tested | Known gap |
|---|---|---|---|
ASI01 Agent goal hijack |
The judge receives the action without the conversation history; a claimed authorization in a command, file or tool output moves no verdict; text from monitors, jobs and agent messages arrives framed as an outside signal, not the human’s instruction; deterministic rules decide before any model is asked. |
|
The agent itself reads untrusted content in its full context. Nothing marks a session that has (#267). |
ASI02 Tool misuse and exploitation |
Per-mode rules on every tool, then the user’s high-consequence list, then the judge for what neither settles; a pipe into a shell denied, with a data program’s quoted words read as data (#554, #608). |
|
An allowed tool used for an allowed purpose, such as a read followed by a post, is not classed by the data it carries (#267). |
ASI03 Identity and privilege abuse |
Credentials are never stored by this code; |
|
The session runs with the developer’s OS rights. There is no OS sandbox. |
ASI04 Agentic supply chain |
The permission engine is upstream and unmodified, extended only through
public points; a release checks |
|
A private registry’s packages are not checked, and a squatted name that
is old and popular passes as routine. |
ASI05 Unexpected code execution |
A download piped into a shell is denied by rule and by the judge; deferred execution is treated as execution (git hooks, shell startup files, editor tasks, git’s own config files); a no-verify flag is refused in every spelling bash hands git, with or without the parser. |
|
Code the agent writes and then runs (a test, a script) is ordinary work, with the developer’s rights. |
ASI06 Memory and context poisoning |
The agent’s memory notes are proposals, unconfirmed until the human promotes them, capped, and refused when they are documents rather than notes; the judge reads no history to poison. |
|
The session’s own context (files and pages read) is not tracked as untrusted (#267). |
ASI07 Insecure inter-agent communication |
Agent messages are sealed per space, under keys the phone grants; the
relay carries ciphertext; a wake is framed as an outside signal, and a
message with no subscribed tag never wakes; plan mode refuses |
|
A message’s body is its sender’s words. An agent may act on it within its mode: framed, not filtered. |
ASI08 Cascading failures |
Every judge failure (timeout, bad output, no credentials) resolves to asking the human, never to allow; a monitor’s events are rate-limited and a flooding monitor is stopped; the spend cap holds the next tool call past a budget for the human. |
|
The spend cap ships at 0, no cap, until the user sets one. Limits are per session; nothing breaks a circuit across a fleet of sessions. |
ASI09 Human-agent trust exploitation |
What counts as the human’s reply is decided by pi’s input-source stamp, never by a model (#249); an approval holds for one exact action; the judge’s reason is shown at the prompt. |
|
A human can still approve what they misread. |
ASI10 Rogue agents |
Modes bound what any agent may do; delegation goes through the gate; every commit is reviewed by a fresh model with no session history and carries its model attribution mechanically. |
|
The threat model’s own limit: a compromised model determined to do harm needs an OS sandbox. |
The CISA and NSA guide’s five risk classes, against the rows above:
| Risk class | Answered by |
|---|---|
Privilege |
ASI03 and ASI02: least privilege by mode, credentials kept out of the agent’s reach, human approval for what is high-impact. |
Design and configuration |
ASI04, and rules matched at each call rather than once at start. |
Behaviour |
ASI01, ASI05 and ASI10. |
Structural |
ASI07 and ASI08. |
Accountability |
The judge’s audit log, read with |
NIST AI 600-1’s twelve risks: five fall to a coding harness, and the rest belong to the model’s provider or to how its output is used.
| Risk | Answered by |
|---|---|
Confabulation |
The reflection pause fails a comment or doc claim in a diff that the diff does not establish (J5); the judge’s rubric is graded against the eval corpus. |
Data privacy |
ASI03’s secret handling: a command that prints credential material is refused, while an existence check passes. |
Human-AI configuration |
ASI09. |
Information security |
ASI02 and ASI05. |
Value chain and component integration |
ASI04. |
CBRN information; dangerous, violent or hateful content; obscene, degrading or abusive content; harmful bias; information integrity; environmental impacts; intellectual property |
Not this harness’s to control: the model provider’s policies, or the use made of the output. New source files carry an SPDX licence header, added on write. |
Verification standard
Every enforcement claim must be demonstrated by a live run with the mechanism visibly firing in the review log, and the evaluation gate (the labelled corpus, worst-case over repeated runs, zero unsafe allows required) runs before any change to the judge ships. Enforcement that looks wired is not evidence: four rules in this project shipped looking protective and never fired, and the judge once ran for a day without its rubric while every test stayed green.
The judge’s day, for the record: pi-ai 0.87 moved a request’s system prompt into the transcript while our direct provider calls kept sending it as a field, so for a day the judge decided every gated ask with no rubric — deferring, as designed, never allowing — and every test stayed green, because the repository’s lock sat behind the pi the box ran and no test pinned the wire shape (the plan). The workspace now pins pi-ai and pi to the versions the box runs, and a strict reader in each test tree throws on the old shape before any prompt assertion runs.