Skip to content

Fix command injection vulnerability in tool_list_files#3

Open
luojiyin1987 wants to merge 2 commits intoshareAI-lab:mainfrom
luojiyin1987:fix/command-injection-vulnerability
Open

Fix command injection vulnerability in tool_list_files#3
luojiyin1987 wants to merge 2 commits intoshareAI-lab:mainfrom
luojiyin1987:fix/command-injection-vulnerability

Conversation

@luojiyin1987
Copy link

@luojiyin1987 luojiyin1987 commented Feb 17, 2026

Summary

This PR fixes a command injection vulnerability in the tool_list_files() function in /lib/tools.sh. The vulnerability was caused by using string concatenation to build find command arguments, which could allow malicious file patterns containing special characters to execute arbitrary commands.

Changes Made

  • Changed find_args variable from string to array type
  • Updated parameter assignment to use array syntax
  • Changed command execution to use array expansion (${find_args[@]})

Impact

This fix prevents command injection vulnerabilities when the tool_list_files function is used with untrusted input for file patterns.

Testing

  • Verify that the function still works correctly with normal file patterns
  • Test with patterns containing spaces and special characters
  • Ensure all existing tests pass

closed #2

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.

Fix command injection vulnerability in tool_list_files

1 participant