Skip to content

guardrails: local bash_subject copies lack the quoted-value and bare-assignment aborts of the hardened shared version #3372

Closed

Description

@kyle-sexton

Context

Two guardrails hooks carry a local, pre-hardening copy of the telemetry-subject helper:

  • plugins/guardrails/hooks/block-hook-bypass.sh:119-133 (bash_subject, used at line 135)
  • plugins/guardrails/hooks/flag-commit-pr-skill-bypass.sh:107-121 (bash_subject, used at line 123)

The hardened shared version, hook::extract_bash_subject in plugins/guardrails/hooks/hook-utils.sh:1073-1112, aborts to the bare Bash subject when a prefix token contains a quote (a quoted value spans whitespace and cannot be tokenized safely), when the resolved token carries a quote, or when the resolved token is still shaped like a bare or trailing assignment (NAME=value, NAME+=value, subscripted forms). The local copies have none of these aborts: they strip sudo/NAME=* prefixes naively, so a command like TOKEN="a b" curl ... can emit a value fragment (a possible credential) into the telemetry subject where the hardened version emits Bash. This is a privacy fix: telemetry subject output changes for the affected commands, so it needs owner sign-off.

Proposed work

  • Replace both local bash_subject definitions with calls to hook::extract_bash_subject (both files already source hook-utils patterns used elsewhere), or port the quoted-value and bare-assignment aborts verbatim.
  • Extend the hooks' test suites with the hardened version's abort cases (quoted prefix value, trailing bare assignment).
  • Get owner sign-off on the telemetry subject change before landing.

Acceptance criteria

  • TOKEN="a b" curl ... produces subject Bash (not a value fragment) in both hooks' telemetry envelopes.
  • A trailing bare assignment (NAME=secret as the resolved token) produces subject Bash in both hooks.
  • No local bash_subject definition remains that diverges from the shared hardened helper.
  • Owner has signed off on the changed telemetry subject output.

References

  • plugins/guardrails/hooks/block-hook-bypass.sh:119-135
  • plugins/guardrails/hooks/flag-commit-pr-skill-bypass.sh:107-123
  • plugins/guardrails/hooks/hook-utils.sh:1073-1112 (hardened hook::extract_bash_subject)
  • Found by the batch-simplify sweep on branch claude/code-tidying-batch-simplify-s7ljbi; deliberately not fixed there because the sweep was behavior-preserving.

Activity

  1. added
    area: security
    on Aug 26, 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

    area: security

    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