T02 · Agent Memory Poisoning
- Location
scripts/prescribe.sh:42- Finding
Persistent Agent Memory Poisoning Through Unsanitized Diagnosis Input
- Content
View full analysis
&2 exit 1 fi # Validate it's a JSON array if ! echo "$INPUT" | jq -e 'if type == "array" then true else error("not an array") end' >/dev/null 2>&1; then echo "Error: input is not a valid JSON array." >&2 exit 1 fi ``` ```bash # Self-improving-agent integration (opt-in: set CLAWDOC_LEARNINGS=1) if [ "${CLAWDOC_LEARNINGS:-0}" = "1" ] && [ -d ".learnings" ]; then LEARNINGS_FILE=".learnings/LEARNINGS.md" echo "" >&2 echo "[prescribe] .learnings/ directory found — writing to $LEARNINGS_FILE" >&2 # Get existing DR count to generate next ID EXISTING_COUNT=0 if [ -f "$LEARNINGS_FILE" ]; then EXISTING_COUNT=$(grep -c "^### DR-" "$LEARNINGS_FILE" 2>/dev/null || true) EXISTING_COUNT=${EXISTING_COUNT:-0} fi APPENDED=0 UPDATED=0 # Process each finding by index FINDING_INDICES=$(echo "$INPUT" | jq -r 'to_entries[] | .key') for IDX in $FINDING_INDICES; do # Build Pattern-Key for this finding (doctor.) PKEY=$(echo "$INPUT" | jq -r --argjson i "$IDX" '.[$i].pattern | gsub(" "; "_") | gsub("-"; "_") | "doctor." + .') # Compute DR number for this entry DR_NUM=$(( EXISTING_COUNT + IDX + 1 )) if [ "$DR_NUM" -lt 10 ]; then DR_PREFIX="DR-00${DR_NUM}" elif [ "$DR_NUM" -lt 100 ]; then DR_PREFIX="DR-0${DR_NUM}" else DR_PREFIX="DR-${DR_NUM}" fi # Check if this Pattern-Key already exists in LEARNINGS.md ALREADY_EXISTS=0 if [ - ...[truncated 3520 chars]- Remediation
View remediation
