Skip to content

v0.43.0 small items: varve env quotes its root, a shim failure says it is one, no pin means no tool - #274

Merged
avrabe merged 9 commits into
mainfrom
feat/v043-small-items
Oct 20, 2026
Merged

avrabe merged 9 commits into
mainfrom
feat/v043-small-items

Conversation

@avrabe

@avrabe avrabe commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

One PR for three v0.43.0 items, replacing #262 and #263 (and the parked no-pin branch) so they go through CI once instead of three times.

requirement what is now true
REQ-ENVQUOTE-001 (#46) varve env writes every path it interpolates in that shell's literal quoting, so eval "$(varve env)" cannot run anything embedded in $VARVE_ROOT. Run under sh, bash, zsh and dash with a root carrying $(…), backticks, quotes and ; (zsh and dash where installed — the Ubuntu runner has no zsh).
REQ-NOPINNOTOOL-001 (#198) With no pin in scope, status, which, run and shim dispatch refuse with the same reason, and none reaches the legacy pre-realm store. varve list names pre-realm layers as belonging to no realm, and says nothing was deleted.
(shim) A failure while dispatching as a shim says so: "invoked as 'varve-bin', so this ran as the shim for a tool named 'varve-bin' …".

Verified locally on CI's own gates before opening (the rule now): fmt, clippy -D warnings, rivet validate, tools/trace-gate.py, tools/claim-check.py, workspace tests 1259 passed / 0 failed, and unfiltered cargo-mutants on the gated files touched (pin.rs, shellquote.rs): 85 tested, 76 caught, 9 unviable, 0 missed, 0 timeouts. The base was re-checked tree-identical to the one those gates ran on.

🤖 Generated with Claude Code

https://claude.ai/code/session_019TNtfRjLNhEz82G2ggeeNu

avrabe and others added 9 commits October 20, 2026 21:09
`varve env` prints a script and tells you to run `eval "$(varve env)"`.
It interpolated the store root — read from $VARVE_ROOT or $HOME, so
attacker-controlled in exactly the environments that matter (CI, a
container, a shared machine) — inside sh DOUBLE quotes, where `$`,
backticks and `"` stay live:

    $ VARVE_ROOT='/tmp/vr$(id>|/tmp/pwned)x' varve env --shell sh
      *) export PATH="/tmp/vr$(id>|/tmp/pwned)x/shims:$PATH" ;;

Eval'ing that line runs the attacker's command as whoever ran
`varve env`. `varve_core::env_lines` had the same defect for a declared
sourced export's script path.

Fixed with one small quoting helper per shell in a new module,
crates/varve-core/src/shellquote.rs (`quote_sh`, `quote_fish`,
`quote_powershell` — the last unused today but exercised by its own
unit test, ready for the day print_env gets a PowerShell branch), used
everywhere a path is interpolated for that shell: env_script_sh and the
fish branch of print_env in crates/varve/src/main.rs, and env_lines in
crates/varve-core/src/pin.rs.

Tests (crates/varve/tests/cli.rs):
- env_quotes_a_hostile_root_so_eval_cannot_run_embedded_commands: a
  VARVE_ROOT carrying both a $(...) and a backtick command substitution
  (plus ", ', \, space and ; for good measure), run for real under
  /bin/sh, /bin/bash, /bin/zsh and /bin/dash — the embedded commands
  must not run, and the literal root must still land on PATH.
- env_quotes_a_hostile_project_path_for_declared_sourced_exports: same
  class of defect in env_lines, exercised through a project directory
  whose own name carries a $(...).
- shellquote.rs's own unit tests pin the exact quoted output for
  quote_sh, quote_fish and quote_powershell (the latter two cannot be
  executed here — no fish or pwsh on this machine — so they are
  exact-output tests only).

Negative control: reverted env_script_sh's quoting call to raw
interpolation; env_quotes_a_hostile_root_so_eval_cannot_run_embedded_commands
failed (PATH came back with the embedded `$(...)` consumed rather than
the literal root), confirming the test fails for the right reason.
Restored, re-ran, green.

Also: added shellquote.rs to the "varve-core (trust)" mutation-gate
shard in ci.yml (REQ-MUTATE-003) — it is small and pure like
witclosure.rs, and used by pin.rs, which is already in that shard.
Updated crates/varve/docs/cmd-env.md's sample output to the new quoted
form.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019TNtfRjLNhEz82G2ggeeNu
varve env has no PowerShell branch, so quote_powershell was unused, and it
was incomplete as written: PowerShell also treats U+2018..U+201B as single
quotes, which doubling ASCII ' does not cover. Unused code with a known gap
is a trap for whoever wires it up later.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019TNtfRjLNhEz82G2ggeeNu
It required /bin/zsh, which the Ubuntu CI runner does not have — the test
failed there with "cannot run /bin/zsh" while passing on macOS. sh and
bash stay mandatory (every Linux and macOS host has them); zsh and dash
are exercised wherever they are installed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019TNtfRjLNhEz82G2ggeeNu
Under any name but `varve` this binary is the shim for a tool of that
name. covalent-layers installed it as varve-bin, so `varve-bin outdated`
ran as "the tool varve-bin" and failed with only "layer 2026.10.4 is not
installed" — true, and pointing nowhere near the cause. The error now
carries "invoked as 'varve-bin', so this ran as the shim for a tool named
'varve-bin' (varve is the CLI only when invoked as 'varve'). If you meant
varve itself, name the binary 'varve'."

Only varve-side failures are wrapped: a dispatched tool's own exit code
never comes back as an Err (exec on unix, process::exit elsewhere).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019TNtfRjLNhEz82G2ggeeNu
…old for REQ-NOPINNOTOOL-001

Clauses 1+2: a fixture lays an installed layer into the legacy pre-realm
store (<root>/core/...) and leaves the project directory unpinned, so any
resolution path that fell back to it when no varve.toml is found would be
able to find and report the tool. Four tests exercise status, which, run,
and dispatch through a hand-built shim symlink, and assert each one refuses
with the exact reason status gives and prints nothing from the legacy
store. Confirmed with a negative control: temporarily making `which` fall
back to the legacy store when no pin is found turned it into a success
(exit 0) that printed the legacy store's path on stdout, which the new test
caught immediately. The change was reverted before committing.

Clause 3: two tests for `varve list` — an all-realm listing carries no
note, and a listing with one legacy (realmless) entry prints exactly one
note naming the count. These two fail until the next commit implements the
note.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019TNtfRjLNhEz82G2ggeeNu
A layer `list` finds at the top of the core (no realm= tag) is one no
realm's root vouches for, and nothing resolves it except a realmless pin
naming it explicitly (REQ-NOPINNOTOOL-001 clauses 1 and 2). list already
showed these entries indistinguishably from realm-owned ones; it now also
prints one note, after the listing, naming how many such entries there are
and where the legacy store lives, saying plainly that they belong to no
realm and that varve has not deleted them. An all-realm listing is
unchanged — the note only appears when a legacy entry is actually present.

Also updates crates/varve/docs/cmd-list.md, which documents list's output.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019TNtfRjLNhEz82G2ggeeNu
…c it

It failed on the Ubuntu runner with "Text file busy" (ETXTBSY, os error
26): another test thread forked while std::fs::copy's write handle was
still open, and exec of the fresh copy was refused. macOS has no such
race, so it passed locally. A symlink named varve-bin is exactly the
covalent case — varve reads the name from argv[0] — and there is no
freshly written file to race on. The test still asserts "invoked as
'varve-bin'", so it still proves the shim path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019TNtfRjLNhEz82G2ggeeNu
…0381/0382

Both advisories concern distrusted emSign intermediates; cargo deny
fails every PR on them until the lock moves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019TNtfRjLNhEz82G2ggeeNu
ubuntu-latest moved to 26.04 and the shards began dying right after the
baseline with "Disk quota exceeded" writing cargo-mutants' worker trees
under /tmp. The same shard passed in 9m on 24.04 on 2026-10-16.
$RUNNER_TEMP sits on the work disk and is emptied per job.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019TNtfRjLNhEz82G2ggeeNu
@avrabe
avrabe merged commit b4b48ec into main Oct 20, 2026
34 checks passed
@avrabe
avrabe deleted the feat/v043-small-items branch October 20, 2026 22:21
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