Skip to content

guardrails: block-dangerous-git's fail-closed PowerShell branch cannot be narrowed without the global kill switch #2664

Closed

Description

@kyle-sexton

Problem

plugins/guardrails/hooks/block-dangerous-git.sh fail-closes on a PowerShell command it cannot tokenize (:1355-1364), and that branch never consults block_dangerous_git_allow. The only escape is the global kill switch, block_dangerous_git_enabled=false, which disables the guard for every repository the operator works in.

The design is deliberate and documented — :710-723 states it for the --config-env alias path, and :730-732 for the too-long-command path:

Fail-closed by construction: this path never consults the allow-list — an unparsable command cannot prove which forms it carries, so no form token can honestly allow it. Only the kill switch bypasses.

That reasoning holds for a form token like reset-hard: an unparsable command genuinely cannot prove which destructive form it carries. It does not obviously hold for the shape that routed the command to the sink. ps::print_sink_trigger_line (:505-546) already classifies the trigger into four named shapes — special-construct, dynamic-invocation, launcher, unbalanced here-string — and PS_SINK_TRIGGER already carries that classification into telemetry (:1360). An operator who has decided that, in their repository, iex is not a git risk currently has no way to say so short of turning the whole guard off.

The result is a bad trade: the narrow escape is unavailable, so the broad one gets used.

Evidence

Against origin/main (d2d03af6), with block_dangerous_git_allow set to all seven form tokens, Invoke-Expression $cmd on the PowerShell tool still exits 2 with the fail-closed message. Setting block_dangerous_git_enabled=false is the only configuration that lets it through.

Proposed change

Not settled — this issue is to decide, not to prescribe. Two shapes worth weighing:

  1. Let the fail-closed branch consult the allow-list for sink-shape tokens (ps-unparsable-dynamic-invocation, ps-unparsable-launcher, …) drawn from PS_SINK_TRIGGER, distinct from the destructive-form tokens so that no existing block_dangerous_git_allow value silently widens.
  2. Leave the branch as-is and document the kill switch as the intended and only escape, so the current behavior is a recorded decision rather than an omission.

Explicitly out of scope: adding iex or any other trigger to the existing form-token allow-list namespace. Admitting a fail-closed shape through a token that also allows destructive forms weakens the guard in exactly the way the :710-723 comment warns against.

Acceptance criteria

  • A decision is recorded: either the fail-closed PowerShell branch gains a documented, separately-namespaced way to be narrowed, or the kill-switch-only behavior is documented as intentional at the branch.
  • If option 1 is taken, no existing block_dangerous_git_allow value gains new power, and a test pins that an unrelated form token does not open the sink.
  • If option 2 is taken, the block message says so, so the operator is not left inferring that the allow-list should have worked.

Activity

  1. added
    needs-triage
    on Aug 15, 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

    needs-triage

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions