T09 · Insecure Skill Coding Practices
- Location
scripts/log_reminder_response.sh:11- Finding
Python Source Injection Through Unsafely Interpolated Shell Values
- Content
View full analysis
[correction]}" RESPONSE="${2:?Usage: log_reminder_response.sh [correction]}" CORRECTION="${3:-}" TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ") python3 -c " import json entry = { 'ts': '$TIMESTAMP', 'task_id': '$TASK_ID', 'response': '$RESPONSE', 'correction': '$CORRECTION' if '$CORRECTION' else None } print(json.dumps(entry, ensure_ascii=True)) " >> "$FEEDBACK_FILE" ``` The same vulnerable construction is used for date and path values elsewhere: ```bash python3 -c " import json, sys from collections import Counter, defaultdict from datetime import datetime target = '$TARGET_DATE' activities = [] with open('$LOG_FILE') as f: ``` ```bash python3 -c " import json, sys cutoff = '$CUTOFF_DATE' kept = 0 with open('$LOG_FILE') as f: lines = f.readlines() with open('$LOG_FILE', 'w') as f: ``` ### Technical Analysis Shell arguments and environment-derived paths are inserted directly into source code passed to `python3 -c`. Shell quoting around the outer command does not make these values safe inside Python string literals. An attacker who can influence `TASK_ID`, `RESPONSE`, `CORRECTION`, `TARGET_DATE`, or `INTENT_GUARDIAN_DATA_DIR` can include a quote followed by Python syntax. This can terminate the intended literal and inject additional Python expressions or statements. Because the resulting text is executed as Python source, successful exploitation provides arbitrary code execution rather than merely malformed JSON. The response type is documented as a fixed enumeration but is not validated. Path and date inputs are likewis ...[truncated 1004 chars]- Remediation
View remediation
