Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/core/src/core/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ ${(function () {
- After each commit, confirm that it was successful by running \`git status\`.
- If a commit fails, never attempt to work around the issues without being asked to do so.
- Never push changes to a remote repository without being asked explicitly by the user.
- When issuing \`git commit -m 'My Message'\` use single quotes rather than double quotes, as double quotes interact poorly with backticks.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

The prompt instruction to use single quotes for git commit -m is an insufficient security measure against command injection, as it relies on LLM adherence for safety. The underlying ShellTool in packages/core/src/tools/shell.ts is highly vulnerable because its isCommandAllowed function fails to validate backticks, other shell substitutions like <( ), or the & operator and newlines, allowing command chaining. Additionally, this single-quote recommendation introduces a new problem where commit messages containing single quotes will cause shell errors. A more robust solution involves fixing the ShellTool's validation logic and instructing the agent to use git commit -F <file> with a temporary file to avoid all shell quoting issues.

References
  1. To prevent prompt injection, avoid including user-provided input in content passed to the LLM (llmContent). If the input is needed for display purposes, use returnDisplay instead. This comment highlights a command injection risk where user-provided input (e.g., commit message) could be embedded into an LLM-generated shell command, leading to vulnerabilities if not properly handled.

`;
}
return '';
Expand Down
Loading