Skip to content

A variable on the line can't run code during a check (1.2.3) - #187

Merged
paureis merged 15 commits into
mainfrom
fix/line-env-exec
Nov 5, 2026
Merged

paureis merged 15 commits into
mainfrom
fix/line-env-exec

Conversation

@paureis

@paureis paureis commented Nov 5, 2026

Copy link
Copy Markdown
Owner

The fix from 1.2.3 (released 2026-11-05, tag v1.2.3 on release/1.2.3), brought to main in full, with 1.2.3's docs.

To check a command, cloudpin starts the CLI's identity lookup with the command's environment. A variable set on the line that makes a program run code (NODE_OPTIONS, PYTHONPATH, BASH_ENV and others, listed and sourced in src/line-code-env.ts) or a PATH pointing at a planted file could run code during the check, in the hook, explain and cloudpin_check. Now:

  • those variables stop the call as "can't tell", naming the variable and never its value, with nothing started;
  • the lookup finds the CLI on the PATH the line started with;
  • a PATH built from $PATH on the line no longer reads as "not installed" and skips the check;
  • env 'A^=1' cli, sudo likewise, and cmd /c "set X=y&& cli" are followed.

Main has more than 1.2.3: an agent's cloudpin switch on such a line is refused, and the rule reads every form November's line reader follows (set -a, Set-Item env:X, +=). 1.2.3's parser doesn't read those forms, and 1.3.0 will.

Owner decisions: every listed variable stays a stop, including HOME and AWS_CONFIG_FILE, because credential_process can run a command from that file. Set them before starting the agent. A person's terminal cloudpin exec is unchanged, since it can't tell a line from their environment. CLAUDE.md's provider rule 3 now names this exception.

Evidence

  • npm run typecheck exit 0; npx vitest run passes on main (4883 before the docs commit), and 2501 on release/1.2.3, with Nightly green there.
  • End to end with printers, one PATH, through the hook, explain and MCP: code ran in 31 cases on the control build and 0 on this one. Re-run by the maintainer's session; the other 5 runs that execute are terminal cases, left by decision.
  • 90 mutations here and 84 on the release branch, each asserted in the diff and restored, with one equivalent survivor on each.
  • npm's cloudpin@1.2.3 integrity equals the release tarball (1.2.2's differs); its attestation verifies, and a wrong-repo control fails.
  • On the owner's real commands, counts only: 0 stops in other projects from the variable list, 1 test line in this repo.

Not tested

No real CLI. Linux and macOS spawns come from this PR's Linux job and Nightly, not a run here. LD_*, DYLD_*, PERL5*, RUBY*, AWS_CONFIG_FILE and the Azure extension folder are from documentation and source.

🤖 Generated with Claude Code

paureis and others added 15 commits November 5, 2026 01:09
The identity lookup gets the call's own environment, so a variable the line set
could make it run what the line chose, before any verdict. Such a call now stops
as "can't tell" without starting the lookup, naming the variable and never its
value. Variables set before the line started stay the user's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A PATH or PATHEXT the line set chose which file the identity lookup started,
and what a shim started by bare name. The lookup now uses the ones the line
started with, so honest PATH lines keep working. A CLI that isn't there stops as
"can't tell" when the line changed PATH, since the command may find one the
lookup can't. This also closes a silent allow: a PATH the line built from
something unknown ($PATH) reached the lookup as no PATH at all, which read as a
CLI not installed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
guard's folding keeps the first spelling in code-unit order, so a line's
$env:path lost to the environment's Path and the CLI read as not installed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cloudpin switch starts the CLIs with its own environment, and the question the
hook asks showed only cloudpin's own variables, so a person could approve a line
whose PATH or NODE_OPTIONS chose what runs. Such a line is now denied, naming the
variable. A person in a terminal runs their own switch as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AZURE_CONFIG_DIR picks the account, so the lookup keeps getting it. A folder the
line chose that holds extensions, or a config file naming them, would have az
import that code during the lookup, so that call stops as "can't tell". Also a
test that kubeconfig exec plugins and helm's plugins start nothing, since the
kubernetes provider only reads the file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A pure move, to leave room in a file at its size limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
env takes any word with an = before the command as a variable, so
env 'A^=1' az group list --subscription other lost the call and the hook allowed
it with no lookup. It is read now, and a name only known when the line runs
stops as "can't tell".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cmd /c "set GH_TOKEN=x&& gh pr list" reached no lookup with that token, so the
hook checked the wrong identity. A set on a cmd line now reaches the calls after
it, and set /a and /p stop as "can't tell".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assert the words of a "can't tell" and of a refusal, which an exception also
denies; a set in quotes; each printing set on its own; explain in shell mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Read as a command, GH folds to gh, so the mutation that kept it survived.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It does what it did on folded names, and the same file then works where an
environment is not folded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… form

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@paureis
paureis merged commit 48cdd0c into main Nov 5, 2026
4 checks passed
@paureis
paureis deleted the fix/line-env-exec branch November 5, 2026 07:03
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