T02 · Agent Memory Poisoning
- Location
scripts/process-selection.sh:13- Finding
Persistent Agent State Injection Through an Unescaped Filename
- Content
View full analysis
/dev/null | head -1) if [ -z "$ACTUAL_FILE" ]; then echo "❌ 未找到文件:$CHOSEN_FILE" exit 1 fi # Copy to avatar cp "$ACTUAL_FILE" "$AVATAR_DIR/mimi-today.png" # Record preference TIMESTAMP=$(date -u '+%Y-%m-%d %H:%M Asia/Shanghai') cat > "$PREFERENCES_FILE" << EOF { "status": "success", "date": "$TIMESTAMP", "selected": "$CHOSEN_FILE", "avatar_saved": true, "location": "$AVATAR_DIR/mimi-today.png" } EOF ``` ### Technical Analysis The script accepts a user-supplied selection as a filename when it ends in `.jpg`, `.png`, or `.webp`. This extension check does not reject quotation marks, backslashes, control characters, or newline characters, all of which can occur in Unix filenames. After finding a matching file, the script interpolates the filename directly into a JSON-like persistent state file without JSON escaping. A specially crafted filename can therefore terminate the `selected` string, add arbitrary fields or text, or make the document syntactically invalid. The destination is `.openclaw/workspace/.learnings/AI-GIRL-PREFERENCES.md`, which is intended to persist preference information. If an AI agent or another component later loads this file as memory or contextual state, attacker-controll ...[truncated 1779 chars]- Remediation
View remediation
