T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/script.sh:6
- Finding
- Persistent sensitive records are created without explicit restrictive permissions<![CDATA[ ## Vulnerability Details **File Location**: `scripts/script.sh`, lines 6-9 **Vulnerability Type**: Plaintext sensitive data with permissions inherited from the ambient umask **Risk Level**: Medium ### Vulnerable Code ```bash DATA_DIR="${HOME}/.local/share/agent-learner" mkdir -p "$DATA_DIR" _log() { echo "$(date '+%m-%d %H:%M') $1: $2" >> "$DATA_DIR/history.log"; } ``` User-provided values are subsequently written to category-specific files using the same permission model. For example: ```bash local input="$*" local ts=$(date '+%Y-%m-%d %H:%M') echo "$ts|$input" >> "$DATA_DIR/prompt.log" ``` ### Technical Analysis The skill persistently records prompts, configurations, evaluations, costs, benchmark results, and other command arguments in plaintext files under `~/.local/share/agent-learner`. Neither the storage directory nor the generated log files are assigned explicit restrictive permissions. `mkdir -p` and shell redirection create resources according to the process's ambient umask. Under a permissive umask, the directory or files may be readable by other local users. This is especially relevant because prompts and configuration records may contain internal instructions, proprietary data, endpoint details, tokens, or other secrets accidentally supplied by a user. The issue affects both the category logs and `history.log`, because `_log` duplicates user-provided content into the history file. No encryption, secret filtering, or permission verification is performed. ### Attack Path 1. The skill runs in an environment with a permissive umask or otherwise permissive permissions on the user's home data directories. 2. A user invokes a data command with sensitive content, such as: ```bash agent-learner prompt "Internal system prompt containing confidential information" ``` 3. The script writes the content to `prompt.log` and duplicates it in `history.log`. 4. Another local account that can traverse the relevant home directories reads the ...[truncated 755 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Set a restrictive umask before creating any persistent data: ```bash umask 077 ``` 2. Explicitly restrict the storage directory: ```bash install -d -m 700 "$DATA_DIR" ``` 3. Create or repair log permissions as mode `600`: ```bash touch "$DATA_DIR/history.log" chmod 600 "$DATA_DIR/history.log" ``` 4. Apply the same permission controls to every category log and export file. Do not rely solely on the caller's umask. 5. Check existing installations and warn if the data directory or any record is accessible to group or other users. 6. Document that users must not submit credentials, API keys, authentication tokens, or other secrets as log values. 7. Consider optional encryption at rest or configurable retention and secure deletion for environments where sensitive prompts are expected. ]]>
