T09 · Insecure Skill Coding Practices
- Location
scripts/script.sh:6- Finding
Plaintext Data Logs Are Created Without Restrictive Permissions
- Content
View full analysis
Vulnerability Details
File Location:
scripts/script.sh:6-7andscripts/script.sh:130-302
Vulnerability Type: Insecure local storage permissions
Risk Level: MediumVulnerable Code
bash DATA_DIR="${HOME}/.local/share/dataview" mkdir -p "$DATA_DIR"User-controlled content is subsequently appended to files in this directory. A representative write operation is:
bash local input="$*" local ts=$(date '+%Y-%m-%d %H:%M') echo "$ts|$input" >> "$DATA_DIR/ingest.log" local total=$(wc -l < "$DATA_DIR/ingest.log") echo " [Dataview] ingest: $input" echo " Saved. Total ingest entries: $total" _log "ingest" "$input"The same storage pattern is repeated for the other data commands between lines 130 and 302.
Technical Analysis
The script creates
~/.local/share/dataviewand its log files without explicitly setting restrictive permissions. Consequently, access permissions are determined by the invoking process'sumask. Under a common022umask, the directory may be created with mode0755and log files with mode0644, allowing other local users to traverse the directory and read the stored records.Command arguments are retained indefinitely as plaintext. These arguments may contain dataset names, query text, filters, schema information, profile details, or other sensitive operational metadata. The script also records content in
history.log, increasing the number of files in which user input may be exposed.No remote exploitation or privilege escalation was identified. Exploitation requires access through another local account or process that can read files allowed by the resulting permissions.
Attack Path
- A user runs a command such as
dataview queryordataview ingestwith sensitive content. - The script creates the data directory and log files using permissions inherited from the user's
umask. - With a permissive
umask, the generated log ...[truncated 851 chars]
- A user runs a command such as
- Remediation
View remediation
Remediation Suggestions
-
Set a restrictive process umask before creating or writing any storage:
bash umask 077 DATA_DIR="${HOME}/.local/share/dataview" mkdir -p -- "$DATA_DIR" chmod 700 -- "$DATA_DIR" -
Ensure every existing and newly created log file has mode
0600:bash touch -- "$DATA_DIR/history.log" chmod 600 -- "$DATA_DIR/history.log"Apply the same protection to all command logs and exported files.
-
Refuse to write through symbolic links. Before opening a destination, verify that it is either absent or a regular file owned by the current user and is not a symbolic link.
-
Use safer file creation patterns that atomically enforce permissions, rather than relying only on the environment's
umask. -
Add retention and deletion commands so users can remove sensitive history, and document that command arguments are stored locally in plaintext.
-
Avoid recording secrets or complete source-data contents. Where feasible, redact sensitive fields or store only non-sensitive summaries.
-
