Skip to content

fix: quote $ARGUMENTS in shell invocations#19

Open
xiaolai wants to merge 1 commit into
ChrisWiles:mainfrom
xiaolai:fix/nlpm-quote-arguments
Open

fix: quote $ARGUMENTS in shell invocations#19
xiaolai wants to merge 1 commit into
ChrisWiles:mainfrom
xiaolai:fix/nlpm-quote-arguments

Conversation

@xiaolai

@xiaolai xiaolai commented Apr 22, 2026

Copy link
Copy Markdown

Automated audit: This PR was generated by NLPM, a natural language programming linter, running via claude-code-action. Please evaluate the diff on its merits.

Security Finding (Low)

Two commands embed $ARGUMENTS unquoted in shell code blocks:

.claude/commands/pr-review.md

gh pr view $ARGUMENTS
gh pr diff $ARGUMENTS

.claude/commands/code-quality.md

npm run lint -- $ARGUMENTS

When the shell (or AI-generated shell invocation) expands an unquoted variable, any whitespace or metacharacters in the value cause word-splitting. This means $ARGUMENTS containing spaces produces multiple tokens instead of one argument, which can:

  • Bypass the Bash(gh:*) restriction intent (extra tokens are separate arguments)
  • Inject unintended flags into npm run lint

Fix

Wrap the variable in double quotes in both files:

-   - Run `gh pr view $ARGUMENTS` to get PR details
-   - Run `gh pr diff $ARGUMENTS` to see changes
+   - Run `gh pr view "$ARGUMENTS"` to get PR details
+   - Run `gh pr diff "$ARGUMENTS"` to see changes
-   npm run lint -- $ARGUMENTS
+   npm run lint -- "$ARGUMENTS"

This is a minimal, targeted fix with no change to command behavior for well-formed input.

Unquoted \$ARGUMENTS in shell contexts is a word-splitting risk: if the
AI constructs input containing spaces or shell metacharacters, the shell
expands it into multiple tokens rather than treating it as a single
argument, which can bypass tool restrictions or inject extra flags.

- pr-review.md: gh pr view/diff "\$ARGUMENTS"
- code-quality.md: npm run lint -- "\$ARGUMENTS"

Co-Authored-By: Claude Code <noreply@anthropic.com>
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