T09 · Insecure Skill Coding Practices
- Location
scripts/script.sh:284- Finding
Plaintext History Log Injection and Terminal Escape Replay
- Content
View full analysis
> "$DATA_DIR/history.log"; } ``` ```bash history) [ -f "$DATA_DIR/history.log" ] && tail -20 "$DATA_DIR/history.log" || echo "No history" ;; ``` ### Technical Analysis The `find` keyword and the first 30 characters of an `explain` formula are passed directly to `_log`. The logging function writes these user-controlled values to `history.log` without removing newlines, carriage returns, ANSI terminal escape sequences, or other control characters. An input containing newline characters can create forged history entries. An input containing ANSI control sequences remains in the persistent log and is later emitted unchanged by `tail` when the `history` command is invoked. A compatible terminal may interpret those bytes as display-control instructions. The history file also stores formula fragments in plaintext. The data directory and file are created using permissions determined by the process umask rather than explicit restrictive modes. Under a permissive or common shared-host configuration, another local account may be able to read logged spreadsheet formulas or business-related search terms. This issue does not provide shell command execution because the logged data is not evaluated as shell syntax. Its practical effects are persistent log corruption, terminal-output manipulation, and potential local information disclosure. ### Attack Path 1. An attacker or untrusted automation supplies a crafted arg ...[truncated 1380 chars]- Remediation
View remediation
> "$DATA_DIR/history.log" } ``` 5. Avoid storing complete user formulas where possible. Store only non-sensitive metadata, redact cell values, or make history logging opt-in. 6. Use `printf` instead of `echo` for predictable behavior across shell implementations. 7. Add tests covering embedded newlines, carriage returns, ANSI escape sequences, Unicode control characters, and permissive umask configurations. ]]>
