Skip to content

Treat unspaced & as a background operator unless redirect-bound - #937

Merged
TheGreatAxios merged 1 commit into
mainfrom
cl-7781b-ampersand-split-fix
Sep 12, 2026
Merged

TheGreatAxios merged 1 commit into
mainfrom
cl-7781b-ampersand-split-fix

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Collaborator

Fixes CL-7781: a permission bypass where & with no trailing space hid a second command inside one approved segment.

Previously isRedirectAmpersand keyed off the character following &, so a &b was treated as a redirect token and stayed one segment — a standing grant for the benign head auto-covered the hidden payload. Now & is redirect-bound only by preceding context (previous non-space char is >/<", e.g. 2>&1, >&2, <&-") or an immediately following > (&>/&>>). Everything else falls through to the existing chain-boundary branch, so a &b splits into two segments while bun run build 2>&1 stays unfragmented.

Tests:

  • splitChainedCommand segment-count table: a &b, a & b -> 2; a &>f, a 2>&1, a >&2, a <&- -> 1; a&&b, a &&b -> 2
  • Gate regression: standing grant for bun test * does not cover bun test x &touch pwn
  • bun run check: green (6990 pass, 0 fail)

Sibling-operator audit (same loop): &&, ||, |, ;, newline need no preceding-context rule — they are unconditionally control operators and can never appear inside a redirect token (redirects are built only from digits, >, <, &, -). The lone & was the only operator with dual redirect/control use. Noted pre-existing quirk (unchanged by this fix, out of scope): |& drops the & but still splits, so nothing hides. Heredoc regions untouched (shell-serial branch owns them).

Related: CL-7781

@linear-code

linear-code Bot commented Sep 12, 2026

Copy link
Copy Markdown

CL-7781

@TheGreatAxios
TheGreatAxios merged commit 0e2d903 into main Sep 12, 2026
9 checks passed
@TheGreatAxios
TheGreatAxios deleted the cl-7781b-ampersand-split-fix branch September 12, 2026 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant