T09 · Insecure Skill Coding Practices
- Location
skills/launchpad/scripts/script.sh:10- Finding
Unescaped User Input Corrupts JSONL Records
- Content
View full analysis
> "$DATA_DIR/data.jsonl" } ``` ### Technical Analysis The `_save_entry` function inserts attacker-controlled input directly into a JSON object without JSON encoding. Although shell quoting prevents this input from being interpreted as shell syntax, it does not make the value safe for JSON. Quotes, backslashes, control characters, and literal newlines can terminate the intended value or introduce additional records. Subsequent commands parse the file using line-oriented `grep` and `cut` operations rather than a JSON parser, which amplifies the integrity issue. Stored terminal control characters may also be replayed when records are listed or searched. ### Attack Path 1. An attacker or untrusted caller invokes `add` with a value containing JSON delimiters or a newline, for example: ```bash scripts/script.sh add $'first"}\n{"ts":"2099-01-01 00:00:00","cmd":"add","val":"forged' ``` 2. `_save_entry` writes the value verbatim to `data.jsonl`. 3. The injected newline creates an additional apparent JSONL record. 4. `list`, `search`, `stats`, or `export` processes the corrupted data and can display or export fabricated information. ### Impact Assessment The vulnerability permits modification of the logical structure and integrity of the application's local record database. It can produce fabricated entries, misleading counts, malformed exports, or terminal-display manipulation. Exploitation is limited to files writable by the account running the skill. It does not grant additional operating-system privileges and no arbitrary shell-command execution path ...[truncated 19 chars]- Remediation
View remediation
> "$DATA_DIR/data.jsonl" ``` Additional hardening should include: - Parse stored records with a JSON-aware tool such as `jq`. - Reject or sanitize unsafe terminal control characters before displaying records. - Set restrictive permissions on the data directory and file, such as directory mode `0700` and file mode `0600`. - Detect and report malformed existing records rather than silently parsing them with `grep` and `cut`. ]]>
