T09 · Insecure Skill Coding Practices
- Location
scripts/script.sh:5- Finding
Potential Exposure of Sensitive Financial Records Through Ambient File Permissions
- Content
View full analysis
Vulnerability Details
File Location:
scripts/script.sh, lines 5–9
Vulnerability Type: Sensitive data stored without enforced restrictive permissions
Risk Level: MediumVulnerable Code
bash DATA_DIR="${HOME}/.local/share/bonds" mkdir -p "$DATA_DIR" _log() { echo "$(date '+%m-%d %H:%M') $1: $2" >> "$DATA_DIR/history.log"; } _version() { echo "bonds v2.0.0"; }User-supplied records are also written to command-specific files without enforcing their permissions. Representative code from lines 124–136 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: bonds 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 " [Bonds] run: $input" echo " Saved. Total run entries: $total" _log "run" "$input" fiThe same storage pattern occurs for the other record commands at lines 144–296.
Technical Analysis
The application is intended to store bond holdings and other potentially sensitive financial information under
~/.local/share/bonds. It creates the data directory withmkdir -pand creates log files through shell redirection, but it does not set a restrictiveumaskor explicitly enforce directory and file modes.Consequently, the actual permissions depend on the environment's inherited
umask. With a permissiveumask, the directory or its files may be readable by other local users. In addition,_logduplicates each submitted value inhistory.log, increasing the number of files containing the sensitive information.This is not an unconditional disclosure: exploitation requires another local account to have filesystem traversal and read access resulting from the effective permi ...[truncated 926 chars]
- Remediation
View remediation
Remediation Suggestions
-
Set a restrictive process mask before creating or writing any data:
bash umask 077 -
Create and enforce the data-directory mode explicitly:
bash install -d -m 700 "$DATA_DIR" -
Create data files with mode
600, and correct existing permissions where appropriate:bash touch "$DATA_DIR/history.log" chmod 600 "$DATA_DIR/history.log" -
Apply the same file-mode enforcement to every command-specific log.
-
Avoid duplicating complete sensitive values in
history.log; record only the action type and timestamp unless the duplicate content is required. -
Document the sensitivity and retention policy of the locally stored records.
-
