T09 · Insecure Skill Coding Practices
- Location
scripts/script.sh:6- Finding
Sensitive Health Records Stored Without Restrictive Permissions
- Content
View full analysis
Vulnerability Details
File Location:
scripts/script.sh, lines 6–9 and representative record creation at lines 130–136
Vulnerability Type: Insecure permissions and plaintext storage of sensitive health information
Risk Level: MediumVulnerable Code
bash DATA_DIR="${HOME}/.local/share/vitamin" mkdir -p "$DATA_DIR" _log() { echo "$(date '+%m-%d %H:%M') $1: $2" >> "$DATA_DIR/history.log"; }Representative record creation:
bash 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 " [Vitamin] log: $input" echo " Saved. Total log entries: $total" _log "log" "$input"The same insecure file-creation pattern is repeated for the other record types and exports.
Technical Analysis
The Skill stores supplement intake, goals, reminders, tracking records, and activity history as plaintext files under
~/.local/share/vitamin/. It creates the directory withmkdir -pand creates files through shell redirection, but it does not establish a restrictiveumaskor explicitly enforce directory and file modes.Consequently, permissions depend on the invoking process's environment. With a common
022umask, newly created files can receive mode0644, making sensitive health records readable by other local users where parent-directory traversal permissions allow it. The code also does not repair pre-existing permissive permissions.This issue does not grant elevated privileges or remote access. Exploitation requires an attacker who already has local filesystem access under another account or through a compromised local process.
Attack Path
- A user invokes the Skill to record supplement intake or other health-related information.
- The script creates
~/.local/share/vitamin/and appends records without setting secure permissions. - The resulting files inherit the process's default ` ...[truncated 822 chars]
- Remediation
View remediation
Remediation Suggestions
-
Set a restrictive process mask before creating any data:
bash umask 077 -
Create and enforce a private data directory:
bash install -d -m 700 "$DATA_DIR" chmod 700 "$DATA_DIR" -
Create files with mode
0600, and correct permissions on existing records:bash touch "$DATA_DIR/history.log" chmod 600 "$DATA_DIR/history.log" find "$DATA_DIR" -maxdepth 1 -type f -exec chmod 600 {} + -
Apply the same restrictions to JSON, CSV, and text exports because they may contain the complete health-record history.
-
Consider optional encryption at rest for environments where other privileged local processes may access user files.
-
Document that the records contain potentially sensitive health information and provide users with secure deletion and retention controls.
-
