subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
# Use bash to pass the file content directly cmd_update = f"gog sheets update {TARGET_SHEET_ID} '{TARGET_SHEET_NAME}!A1' --values-json \"$(cat /tmp/french_learning_output_data.json)\" --json --input=USER_ENTERED" subprocess.run(cmd_update, shell=True)- Confidence
- 96% confidence
- Finding
- The code executes a shell command with shell=True and embeds command substitution $(cat /tmp/french_learning_output_data.json). Even though the path and sheet identifiers are hardcoded, invoking a shell unnecessarily expands the attack surface: shell metacharacter handling, PATH hijacking of the gog binary, and unintended execution behavior can all turn a data update into arbitrary command execution or unsafe external side effects.
