Skip to content

fix(hooks): block monk CLI invocations followed by shell separators (#471) - #489

Draft
ZacLou wants to merge 1 commit into
monk-io:mainfrom
ZacLou:fix-block-monk-shell-separators
Draft

ZacLou wants to merge 1 commit into
monk-io:mainfrom
ZacLou:fix-block-monk-shell-separators

Conversation

@ZacLou

@ZacLou ZacLou commented Sep 3, 2026

Copy link
Copy Markdown

Fixes #471.

The fallback regex in �lock-monk.ps1 and �lock-monk.sh treated whitespace/EOL as the only valid trailing boundary. Commands like monk;ls, monk&ls, monk|ls, and monk&&ls were therefore allowed when the monk-agent binary was unavailable and the native fallback ran.

Changes:

  • Extend the trailing boundary to include shell separators (;, &, |, backtick, ), }) and end-of-string in both the PowerShell and POSIX shell fallbacks.
  • Add regression tests for monk;ls, monk&ls, monk|ls, monk&&ls, and �cho x; monk; ls.

Verification:

  • ests/block-monk-windows.ps1 passes locally.

@ZacLou
ZacLou force-pushed the fix-block-monk-shell-separators branch 2 times, most recently from 0cfc107 to 83274fa Compare September 5, 2026 07:43
@ZacLou
ZacLou marked this pull request as draft September 5, 2026 08:37
@ZacLou
ZacLou force-pushed the fix-block-monk-shell-separators branch from 83274fa to edf8cf3 Compare September 16, 2026 10:03
The fallback regex in block-monk.ps1 and block-monk.sh treated
whitespace/EOL as the only valid trailing boundary, so commands like
'monk;ls', 'monk&ls', 'monk|ls', and 'monk&&ls' were allowed when the
monk-agent binary was unavailable. Extend the trailing boundary to
include shell separators (; & |  ) }) and end-of-string.

Fixes monk-io#471.
@ZacLou
ZacLou force-pushed the fix-block-monk-shell-separators branch from edf8cf3 to da81177 Compare September 16, 2026 20:25
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.

[Bug bounty] PreToolUse block-monk fallback regex bypassed by shell separators (monk; / monk& / monk|)

1 participant