subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
def search_xhs(keyword, num=10): """使用 xhs-cli 搜索""" cmd = f'source ~/.agent-reach-venv/bin/activate && xhs search "{keyword}" --sort popular --json' result = subprocess.run(cmd, shell=True, capture_output=True, text=True) try: data = json.loads(result.stdout)- Confidence
- 98% confidence
- Finding
- The script builds a shell command with an f-string and executes it with shell=True, allowing the user-controlled keyword to alter shell syntax. An attacker can inject additional commands through the search term, leading to arbitrary command execution under the agent's privileges.
