T09 · Insecure Skill Coding Practices
- Location
scripts/script.sh:86- Finding
Unescaped Template Values Permit Persistent JSONL Data Injection
- Content
View full analysis
Vulnerability Details
File Location:
scripts/script.sh:86-90
Vulnerability Type: Improper output encoding and persistent data injection
Risk Level: Mediumbash cmd_create() { local name="${2:-}" local text="${3:-}" [ -z "$name" ] && die "Usage: $SCRIPT_NAME create <name text>" echo '{"name":"'$2'","text":"'$3'"}' >> $DATA_DIR/templates.jsonl && echo 'Created template: $2' }Technical Analysis
The template name and text are concatenated directly into a JSON object without JSON escaping. An input containing quotation marks, backslashes, control characters, or newlines can terminate the intended JSON string and inject additional properties or complete JSONL records.
The destination path is also unquoted. Although
DATA_DIRis derived fromHOME, whitespace or wildcard characters in that environment-provided path could cause word splitting or pathname expansion.Because the generated data is retained in
~/.local/share/sms/templates.jsonl, the malformed or injected records persist across subsequent invocations of the Skill.Attack Path
- An attacker supplies a crafted template value through the
createcommand. - The value contains JSON syntax or a newline, such as content that closes the
textstring and adds another record. - The shell concatenates the value into the output without JSON encoding.
- The resulting malformed or attacker-structured data is appended to
templates.jsonl. - Later
list,preview, or downstream consumers process or display the injected persistent content.
This does not provide direct shell-command execution in the current implementation because shell metacharacters introduced by parameter expansion are not reparsed as shell syntax.
Impact Assessment
Exploitation occurs with the privileges of the user running the Skill. An attacker who can influence command arguments can corrupt the SMS temp ...[truncated 261 chars]
- An attacker supplies a crafted template value through the
- Remediation
View remediation
Remediation Suggestions
-
Generate JSON with a proper encoder rather than string concatenation. For example:
bash jq -nc --arg name "$name" --arg text "$text" \ '{name: $name, text: $text}' >> "$DATA_DIR/templates.jsonl" -
Quote the destination path in every operation:
bash "$DATA_DIR/templates.jsonl" -
Validate maximum field lengths and reject unexpected control characters if multiline template data is not required.
-
Consider writing through a securely created temporary file followed by an atomic rename when modifying structured data.
-
Correct the handler argument indexing after
shift;cmd_createshould consume its name and text from$1and$2.
-
