Skip to content

agent-guards: actions-disable-guard: variable values that aliases, exported functions, order or made names change #1518

Backlog

Description

@scuttletoby

Follow-up from the round-1 lenses on #1504 (part of #1094). actions-disable-guard reads a shell variable's written-out value as its value (C='echo hi'; bash -c "$C" runs echo hi). Some shapes break that, and the guard does not see them. Each one below already passes on main without any trap, so none is new in #1504. #1504 only stops the trap and eval forms of them (fixed_names: an alias anywhere, or a trap/eval text that runs a command other than a known program or a function the text defines, keeps every name open).

What is left to decide and fix, in one place:

  1. An alias the script defines and calls directly: shopt -s expand_aliases; alias f='C=$(cat file)'; f; bash -c "$C". The alias body sets C, but the guard does not read alias bodies as commands that set variables.
  2. A function exported by the caller (g(){ C=$(cat file); }; export -f g; bash s.sh), called in the script by a name the script does not define. The same works for a function named after a program (rm, cat), which then replaces it.
  3. A variable used before the script sets it: bash -c "$C"; C='echo hi'. The first line runs whatever C the caller's environment gave. The guard reads values without regard to order.
  4. A name set by a word made at run time: read -r "$n", printf -v "$n" .., declare "$n=..". The guard taints only names that are written out.

Possible direction: treat a name as known only when its one assignment comes before every use at the top level, the text defines no alias, every command word it calls is a builtin, a known program or a function the text defines, and no setter takes a made name. Otherwise, read it as hidden. Each shape needs a refuse row in actions-disable.test.py (an existing table) and a check that the fork's own scripts still pass.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:guards

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions