Skip to content

Read a Double-Quoted Wrapper Body's Run-Time Words as Splittable in the Write Guard #3075

Closed

Description

@ptr727

Context

Found by the local review of the lane closing #3006. The new merge check and the existing commit check share it. It was confirmed with classify probes on constructed commands.

A Double-Quoted Wrapper Body Is Read With Quotes the Outer Shell Already Expanded Through

The outer shell expands a $ word inside a double-quoted -c body before the inner shell reads it. The guard reads the body's inner quotes as if they were written by hand. So a quoted option value there is exempt from the run-time word check, although its expansion can carry the inner shell's own quotes:

  • B="x' --admin '"; sh -c "gh pr merge 5 --squash --body '$B'" is allowed. The inner shell runs gh pr merge 5 --squash --body 'x' --admin ''.
  • B="' -n '"; sh -c "git commit -m '$B'" is allowed through the same exemption on a commit's quoted value.

An unquoted value in the same body, as in bash -c "gh pr merge 5 --squash $A", is denied.

Possible Direction

Carry from _embedded_wrapper_commands whether a body came from double quotes, and read a run-time word inside such a body as never split-free, since the outer shell has already put its text into the body. One change there covers the merge and the commit sites.

Metadata

Metadata

Assignees

No one assigned

    Labels

    introducedReview finding classed introduced per local-strict-review Disposing of FindingsscriptA defect in hub tooling

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions