T09 · Insecure Skill Coding Practices
- Location
scripts/script.sh:6- Finding
Locally Stored User Data Is Created Without Restrictive Permissions
- Content
View full analysis
Vulnerability Details
File Location:
scripts/script.sh:6-9, with repeated file writes atscripts/script.sh:124-297
Vulnerability Type: Insecure file and directory permissions
Risk Level: MediumVulnerable Code
bash DATA_DIR="${HOME}/.local/share/quote" mkdir -p "$DATA_DIR" _log() { echo "$(date '+%m-%d %H:%M') $1: $2" >> "$DATA_DIR/history.log"; }A representative input-storage branch is:
bash run) shift if [ $# -eq 0 ]; then echo "Recent run entries:" tail -20 "$DATA_DIR/run.log" 2>/dev/null || echo " No entries yet. Use: quote run <input>" else local input="$*" local ts=$(date '+%Y-%m-%d %H:%M') echo "$ts|$input" >> "$DATA_DIR/run.log" local total=$(wc -l < "$DATA_DIR/run.log") echo " [Quote] run: $input" echo " Saved. Total run entries: $total" _log "run" "$input" fi ;;The same storage pattern is repeated for the
check,convert,analyze,generate,preview,batch,compare,export,config,status, andreportcommands.Technical Analysis
The script stores complete command inputs in files beneath
~/.local/share/quote/, but it neither establishes a restrictive process umask nor explicitly assigns private permissions to the directory and files.Consequently, permissions depend on the invoking environment. With a common
022umask,mkdir -pcan create thequotedirectory with mode0755, while shell redirection can create log and export files with mode0644. If parent-directory traversal is permitted, other local accounts may therefore read the stored records.Each submitted value is written both to a command-specific log and, through
_log, tohistory.log. This duplication increases the number of files from which user-entered content may be disclosed. Export files created by_exportare subject to ...[truncated 1313 chars]- Remediation
View remediation
Remediation Suggestions
-
Establish a private umask before creating any files:
bash umask 077 -
Create and validate the data directory with owner-only access:
bash DATA_DIR="${HOME}/.local/share/quote" mkdir -p -- "$DATA_DIR" chmod 700 -- "$DATA_DIR" -
Restrict existing and newly created data files:
bash find "$DATA_DIR" -maxdepth 1 -type f -exec chmod 600 -- {} + -
Create export files atomically with mode
0600, and avoid following unexpected symbolic links. Where available, use a secure temporary file in the protected directory and rename it after the export is complete. -
Consider removing duplicate plaintext values from
history.log, or log only command names and timestamps when the full input is unnecessary. -
Document that users should not enter credentials or secrets. Provide a retention or deletion command so stored records can be securely managed.
-
Before writing, verify that the data directory is owned by the current user and is not a symbolic link or an unexpectedly shared location.
-
