Skip to content

fix(common-utils): escape single quotes in zz_args eval output - #87

Open
tomgrv wants to merge 2 commits into
developfrom
claude/zz-args-injection-prevention-mbk51n
Open

fix(common-utils): escape single quotes in zz_args eval output#87
tomgrv wants to merge 2 commits into
developfrom
claude/zz-args-injection-prevention-mbk51n

Conversation

@tomgrv

@tomgrv tomgrv commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • zz_args emits var='<value>' assignments that callers wrap in eval $(zz_args ...). Any argument value containing a single quote broke out of the quoting, letting arbitrary shell commands run in the caller's context.
  • Added a zz_esc() helper (escapes ' as '\'') and applied it to every value-emitting code path: flag values (OPTARG), positional - args, and the &, #, + remaining-argument capture modes.

Test plan

  • Manually installed the old and patched _zz_args.sh as zz_args on PATH alongside a minimal caller script using eval $(zz_args ... <<-help ... help), matching real usage in src/gitutils/_git-fix-base.sh and similar scripts.
  • Confirmed the old script lets a crafted argument (main'; touch /tmp/pwned; echo ') execute the injected touch command.
  • Confirmed the patched script blocks the same payload across flag-value, positional (-), &, #, and + capture modes, while normal values (including embedded spaces) still parse correctly.

Generated by Claude Code

claude and others added 2 commits July 18, 2026 08:35
zz_args emits var='<value>' lines that callers pass to eval. A value
containing a single quote broke out of the quoting, letting arbitrary
shell commands run. Added zz_esc() to escape embedded quotes before
they're wrapped in single quotes, applied across all capture modes
(flag values, positional, +, &, #).
@tomgrv
tomgrv marked this pull request as ready for review July 18, 2026 20:53
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.

2 participants