Skip to content

Close Env, Launcher, and Xargs Cluster Gaps in the Write Guard #3347

Closed

Description

@ptr727

The write guard has three environment and launcher gaps that let a mutation or foreign-repository write pass. Copilot raised them on the round-34 promotion pull request. Each is a gap in how the guard reads a command, none is a regression, since the same commands pass the guard on main.

  • set -a, then GIT_DIR=<primary>/.git, then a hard reset: _exported_states knows export, declare -x, and typeset -x, not the shell-wide set -a, nor local -x scopes. The primary-checkout rule can allow the reset.
  • uv run env GH_REPO=<other-owner>/<repo> gh pr comment 5 --body x: after an unknown launcher the _launcher_prefix call passes env_args=False, so the assignment env passes is dropped and the shell's own GH_REPO is used. Run with GH_REPO set to a same-owner repository, the guard exits 0 with no deny, where the same command without uv run is denied.
  • printf 'git config remote.origin.mirror true' | xargs -0I{} bash -c '{}': _xargs_replace_string does not parse the -0I{} option cluster, so {} is read as a fixed body and the config change is missed.

Fix by modelling set -a, reading env assignments after an unknown launcher as real assignments, and parsing option clusters for the replacement string. Each needs a test that fails with the fix reverted.

Activity

  1. added
    bug
    pre-existing
    script
    on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpre-existingscript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions