T09 · Insecure Skill Coding Practices
- Location
scripts/lifecycle.sh:118- Finding
Arbitrary Python Code Execution Through Stored Knowledge Content
- Content
View full analysis
/dev/null) if [[ -z "$content" ]]; then echo '{"status": "error", "error": "Entry not found"}' return 1 fi local summary summary=$(echo "$content" | head -c "$limit") if [[ ${#content} -gt $limit ]]; then summary="$summary..." fi local key_points key_points=$(echo "$content" | grep -oE '[^.!?]+[.!?]' | head -3 | tr '\n' ' ' || echo "") local dag_summary dag_summary=$(python3 -c " import sys, json content = '''$content''' summary = '''$summary''' key_points = '''$key_points''' dag = { 'd0': content, 'd2': { 'summary': summary, 'key_points': key_points, 'word_count': len(content.split()), 'char_count': len(content) } } print(json.dumps(dag, ensure_ascii=False, indent=2)) " 2>/dev/null) ``` ### Technical Analysis Knowledge-base content, its derived summary, and extracted key points are interpolated directly into source code passed to `python3 -c`. Shell quoting does not make these values safe Python literals. A stored value containing a triple-quote terminator such as `'''` can escape the intended string literal and introduce arbitrary Python statements. Python can then invoke operating-system commands through modules such as `os` or `subprocess`. This is a second-order injection vulnerability: the malicious value is first stored as data and is executed later when the entry is summarized. The existing SQL injection vulnerabilities provide one way to place a specially crafted value into the database. An attacker with another legitimate database-writing path could exploit the same sink. ### Attack Path 1. An attacker causes c ...[truncated 1151 chars]- Remediation
View remediation
