T09 · Insecure Skill Coding Practices
- Location
scripts/script.sh:6- Finding
Sensitive Health Records Created Without Enforced Access Restrictions
- Content
View full analysis
Vulnerability Details
File Location:
scripts/script.sh, lines 6-9 and representative record-writing logic at lines 133-145
Vulnerability Type: Plaintext sensitive-data storage with ambient filesystem permissions
Risk Level: MediumVulnerable Code
bash DATA_DIR="${HOME}/.local/share/allergy" mkdir -p "$DATA_DIR" _log() { echo "$(date '+%m-%d %H:%M') $1: $2" >> "$DATA_DIR/history.log"; }Representative health-record creation:
bash log) shift if [ $# -eq 0 ]; then echo "Recent log entries:" tail -20 "$DATA_DIR/log.log" 2>/dev/null || echo " No entries yet. Use: allergy log <input>" else local input="$*" local ts=$(date '+%Y-%m-%d %H:%M') echo "$ts|$input" >> "$DATA_DIR/log.log" local total=$(wc -l < "$DATA_DIR/log.log") echo " [Allergy] log: $input" echo " Saved. Total log entries: $total" _log "log" "$input" fiTechnical Analysis
The application stores allergy details, symptoms, goals, reminders, and activity history as plaintext files beneath
~/.local/share/allergy. It creates the storage directory usingmkdir -pand creates files through shell redirection, but it does not establish a restrictiveumask, request mode0700for the directory, or enforce mode0600for record and export files.Consequently, effective permissions depend on the environment from which the script is launched. Under a permissive
umask, the directory can be traversable and the health-record files readable by other local users. Existing files with overly broad permissions also remain uncorrected.The same data is duplicated in
history.log, increasing the number of files through which sensitive information can be exposed.Attack Path
- A user runs a record command and supplies sensitive allergy or symptom information.
- The script creates `~/.loc ...[truncated 1176 chars]
- Remediation
View remediation
Remediation Suggestions
-
Set a restrictive process umask before creating any storage:
bash umask 077 -
Create and verify the data directory with owner-only permissions:
bash install -d -m 700 -- "$DATA_DIR" -
Create record, history, and export files with mode
0600. Correct permissions on existing files after confirming that they are regular files owned by the current user:bash find "$DATA_DIR" -maxdepth 1 -type f -user "$(id -u)" -exec chmod 600 {} + -
Validate that
$HOMEand$DATA_DIRare owned by the expected user and reject unsafe ownership or unexpected symbolic links before writing sensitive records. -
Clearly document that records are stored as plaintext. If the threat model includes administrators, device theft, backup disclosure, or compromise of the user's account, offer encryption at rest using an established operating-system key store or a vetted encryption tool.
-
Apply the same permission controls to every generated JSON, CSV, and text export because those files aggregate sensitive records.
-
