Skip to content

Syntax is daemon-owned (G4.6): docs, program-word rejection, quoted Resolves (#89 step 4) - #122

Open
cuihtlauac wants to merge 7 commits into
mainfrom
docs/g4.6-daemon-owned-syntax
Open

cuihtlauac wants to merge 7 commits into
mainfrom
docs/g4.6-daemon-owned-syntax

Conversation

@cuihtlauac

@cuihtlauac cuihtlauac commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Step 4 of the 1.3.1 plan in #89: the Phase 1 claims, written before the code steps (5–9) that discharge them. It started as docs only. An independent review then found claims the code did not meet; they are fixed in the code where that was cheap, and stated precisely where not.

Docs

Assurance case

  • G4.6 / Sn4.6, syntax is daemon-owned. Every piece of shell syntax in Command: and Steps: is written by the daemon: operators, parentheses, redirections, sudo, cd/export, the accepted-exit-codes wrapper and its # exit N accepted comment.
    • A request string appears only quoted by shquote.
    • A setenv key appears only as a shell name, which shquote would leave bare anyway.
    • A program word that would read as syntax is rejected.
    • Unknown plan keys are rejected at any depth.
    • The shell op's script appears as one quoted argument, flagged opaque.
    • Widened to Resolves:.
    • Sn4.6 is [partial]; its residuals name Display fidelity: daemon-owned syntax, runtime self-check and echo (tracking) #89 step 5, step 9 and Phase 2, plus zsh's reserved words.
  • Sn4.5 split into Sn4.5a, the syntactic half ([discharged]), and Sn4.5b, the semantic half ([partial]).
  • G3.1 restated. "No shell is invoked on the privileged path" was false for a privileged shell op, which runs as sudo -- sh -c SCRIPT. It now says what the code does:
    • The daemon never builds a shell command line; each step execs its argv word for word, with program words replaced by their pinned paths.
    • An escalated step is sudo [-u user] [K=V…] -- program args or pkexec … env -C dir -- program args.
    • A shell runs only where the request names one; that step is flagged opaque and refused under no_shell.
    • Sn3.1 drops the retired shell_escape evidence.
  • Notation: [discharged] now allows residuals that name planned strengthening, as Sn4.3 and Sn3.2 already did.

Elsewhere

  • Threat model: a B1 row "caller supplies the syntax shown" (blocked by design) and attack-tree leaf 3.10. The unknown-plan-key row now cites G4.6.
  • Roadmap ("Display fidelity"): the two halves of G4.5 and the G4.6 claim, the echo and runtime self-check entries, and the step-9 lint at Rung 1.
  • Text callers read: security.md, protocol.md and the MCP schema now state the program-word rule and the corrected no-shell claim.
  • Smaller fixes: the slides and the dated 0.11.2 audit drop or annotate the old claims, and the backlog and changelog record step 4.

Code

Behaviour changes

  • Program words that read as shell syntax are rejected (protocol::check_command_word): NAME=…, NAME+=… and the bash reserved words, in a plan at any depth and in the flat pipeline. Before, argv: ["FOO=bar", "true"] showed as FOO=bar true ("set FOO, run true") while the daemon ran a program named FOO=bar. With --inherit-path and a user-writable PATH directory, such a program can exist. It is still reachable by path (./FOO=bar, /usr/bin/time).
  • Resolves: quotes request words and paths with shquote: program and wrapper names, the words opaque reasons quote, and filesystem paths after escaping. A name holding blanks, or a path holding ->, can no longer pass for a second column or a symlink arrow. Ordinary names and paths are unchanged, and no golden moved.
  • "command not found" errors quote the program word, and the wrapper's name in the (run by …) form (found during the live run).

New property tests (they replace the retired shell_escape one)

  • prop_shquote_reads_back_as_one_word: in sh and in bash, shquote(w) reads back as the single word w. Inputs include every metacharacter, quote, blank and non-ASCII sample in fixed positions, and brace and glob words run where the globs match. It was checked against mutants of shquote's safe set: it catches every one that changes how a shell reads the word.
  • prop_built_command_is_the_argv_word_for_word: over random run-as, hostile argv and env, the sudo/pkexec argv equals the expected form exactly, and a direct leaf passes argv[1..] unchanged. It was checked against an injected extra argument in each escalation mode.

Text only: the MCP schema description and the Plan and executor comments no longer claim "no shell on the privileged path" or "literal argv".

Checks

  • cargo test --release passes; cargo fmt --check and clippy are clean; --no-default-features builds.
  • concurrency::burst_connections_above_cap_get_busy_response failed once and passed on two reruns. It is the known flaky test, which also fails on a clean main.
  • Live run against the branch daemon (sudo-request --plan, unprivileged):
    • FOO=bar true (plan and pipeline) and time ls were refused before prompting.
    • A program path with a double space, and one under a directory named a -> , showed quoted in Resolves:.
    • ssh h 'x ) y' showed opaque — runs a command string remotely ('x ) y').

The branch was rebased on main, so it also carries the backlog entry for #123.

🤖 Generated with Claude Code

The GUI dialog's Command: line and its timeout landed with #95; step 7
now lists only the Sn4.8 residuals, matching the plan in #89.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Cuihtlauac ALVARADO <cuihtlauac@tarides.com>
@cuihtlauac cuihtlauac changed the title Docs: syntax is daemon-owned (G4.6), split Sn4.5 (#89 step 4) Docs: syntax is daemon-owned (G4.6), split Sn4.5, restate G3.1 (#89 step 4) Nov 27, 2026
cuihtlauac and others added 5 commits November 27, 2026 10:07
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Cuihtlauac ALVARADO <cuihtlauac@tarides.com>
Step 4 of the 1.3.1 plan: state the Phase 1 claims before the code
steps that discharge them.

- Assurance case: new G4.6/Sn4.6. The daemon writes all shell syntax
  in the command slot; a request string appears only as a shquote'd
  word. The one bare string is a setenv key, which validation limits
  to a shell name, so it reads as its quoted form would. Sn4.6 is
  [partial]; its residuals name the #89 steps that close them.
- Sn4.5 split into Sn4.5a (syntactic: both texts parse to one tree,
  [discharged], bash as oracle) and Sn4.5b (semantic: that tree runs
  like the executor, [partial]). The GFM table no longer splits on the
  `||` of the accepted-exit-codes spelling.
- Threat model: B1 row "caller supplies the syntax shown" (blocked by
  design), attack-tree leaf 3.10; the unknown-plan-key row now cites
  G4.6.
- Roadmap, display fidelity: the two halves and G4.6, the echo and
  runtime self-check entries, and the step-9 lint at Rung 1. Dropped
  the retired shell_escape property from the Rung 2 mapping row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Cuihtlauac ALVARADO <cuihtlauac@tarides.com>
Sn3.1 cited the shell_escape round-trip fuzzing as evidence, but the
structured-plan executor removed shell_escape and that property with
it. G3.1 also overclaimed: "no shell is invoked on the privileged
path" is false for a privileged `shell` op, which runs as
`sudo -- sh -c SCRIPT`.

- G3.1 now states the invariant the code keeps (executor.rs): the
  daemon never assembles a shell command line; every step execs its
  literal argv, an escalated one as `sudo -- argv`; a shell runs only
  where the request names one, flagged opaque and refused under
  no_shell.
- Sn3.1 cites build_command,
  escalated_leaf_is_literal_argv_never_a_shell_wrapper and
  tests/no_shell.rs instead of the retired property.
- security.md, threat-model.md (B4 row, leaf 2.1) and the roadmap's
  Rung 2 list use the same wording; the dated 0.11.2 audit gets a
  note that shell_escape was later removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Cuihtlauac ALVARADO <cuihtlauac@tarides.com>
Code:
- Reject a program word that shquote leaves bare but a shell reads as
  syntax: NAME=…, NAME+=…, bash reserved words (check_command_word, plan
  and flat pipeline). argv ["FOO=bar","true"] showed as `FOO=bar true`
  ("set FOO, run true") while the daemon ran a program named FOO=bar.
- Resolves: quotes request words and paths with shquote (names, wrapper
  names, opaque-reason words, escaped paths), so a name with blanks or a
  path with " -> " cannot pass for a column or a symlink arrow. Ordinary
  names and paths are unchanged; no golden moved.
- prop_shquote_reads_back_as_one_word and
  prop_built_command_is_the_argv_word_for_word replace the retired
  shell_escape property; both checked against mutants.
- MCP schema text, Plan and executor comments: no "no shell on the
  privileged path" or "literal argv" overclaims.

Docs:
- G3.1 states exactly how argv is passed and where a shell can run;
  Sn3.1 cites the new property.
- G4.6 lists the `# exit N accepted` comments, the program-word and
  unknown-key rejections, the shell op as quoted text, and Resolves:;
  Sn4.6 cites the new evidence, drops the echo residual, names zsh's
  reserved words as a residual.
- Notation: [discharged] allows residuals that name planned work.
- Threat model, roadmap, security.md, protocol.md, slides and the audit
  summary match; Sn4.5b and the roadmap list file coverage precisely.
- Backlog and changelog record step 4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Cuihtlauac ALVARADO <cuihtlauac@tarides.com>
The live run of PR #122 showed `error: command not found: x  /usr/bin/ls`
on the TTY after an approved request: a request word printed unquoted.
Both not-found messages now quote the program (and the wrapper) with
shquote. Changelog records the live run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Cuihtlauac ALVARADO <cuihtlauac@tarides.com>
@cuihtlauac
cuihtlauac force-pushed the docs/g4.6-daemon-owned-syntax branch from 2c3d4bb to 8d3c7c3 Compare November 27, 2026 16:22
@cuihtlauac cuihtlauac changed the title Docs: syntax is daemon-owned (G4.6), split Sn4.5, restate G3.1 (#89 step 4) Syntax is daemon-owned (G4.6): docs, program-word rejection, quoted Resolves (#89 step 4) Nov 27, 2026
CI's Kani job ran for almost two hours and was cancelled (it used to
take 6 minutes): plan_run_leaf_matches_dangerous_char_spec put a
symbolic character in argv[0], and the new program-word check (string
search, reserved-word comparisons) does not finish on a symbolic word.

- The harness puts the symbolic character in argv[1] behind a fixed
  program word: the dangerous-character gate is the same for every argv
  element; check_command_word is covered by unit tests.
- Reserved words are a `matches!` instead of a slice search, so no
  17-iteration loop exceeds the harness's unwind bound.

All four harnesses verify locally (cargo kani 0.67), the leaf harness
in 26 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Cuihtlauac ALVARADO <cuihtlauac@tarides.com>
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.

1 participant