T09 · Insecure Skill Coding Practices
- Location
scripts/script.sh:60- Finding
Unescaped User-Controlled Data in JSON and CSV Exports
- Content
View full analysis
> "$out" printf ' {"type":"%s","time":"%s","value":"%s"}' "$name" "$ts" "$val" >> "$out" done < "$f" ... while IFS='|' read -r ts val; do echo "$name,$ts,$val" >> "$out"; done < "$f" ``` ### Technical Analysis The export implementation inserts log-derived values directly into JSON and CSV documents without format-specific encoding. For JSON, quotation marks, backslashes, control characters, and embedded newlines in `$name`, `$ts`, or `$val` are not escaped. A crafted value can terminate the intended JSON string and inject additional properties or objects, or make the export syntactically invalid. For CSV, fields containing commas, quotation marks, or newlines are not quoted according to CSV rules. Values beginning with spreadsheet formula prefixes such as `=`, `+`, `-`, or `@` also remain unchanged. When such an export is opened in spreadsheet software, the application may interpret the value as a formula rather than plain text. The current entry-writing commands contain an unrelated top-level `local` error, but the vulnerable export remains reachable for existing or manually created log files. The same condition would also become reachable through normal entry creation if that correctness defect is repaired. ### Attack Path 1. An attacker causes a crafted value to be present in a file under `~/.local/share/laundry/`. This could occur through a manually modified or imported log, or through normal entry creation after the top-level `local` defect is corrected. 2. For JSON injection, the value contains JSON metacharacters such as quotes, backslashes, or an object fragment. 3. For CSV injection, the value contains delimiters or begins with a spreadsheet formula pref ...[truncated 1144 chars]- Remediation
View remediation
