T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/clipboard.sh:67
- Finding
- Clipboard contents are persistently stored in an unprotected plaintext file## Vulnerability Details **File Location**: `scripts/clipboard.sh`, lines 67-83 **Vulnerability Type**: Plaintext storage of potentially sensitive clipboard data **Risk Level**: Medium ### Technical Analysis The `save_clipboard` function reads arbitrary content from the system clipboard and appends it verbatim to `clipboard-history.md`: ```bash save_clipboard() { init_history local content=$(get_clipboard) local timestamp=$(date "+%Y-%m-%d %H:%M:%S") local count=$(grep -c "^## \[" "$HISTORY_FILE" 2>/dev/null || echo "0") local index=$((count + 1)) # Truncate content for display local preview=$(echo "$content" | head -c 50 | tr '\n' ' ') { echo "" echo "## [$index] $timestamp" echo "\`\`\`" echo "$content" echo "\`\`\`" echo "" } >> "$HISTORY_FILE" # Trim old entries if over limit trim_history ``` The history initialization at lines 10-15 also creates the file without explicitly setting restrictive permissions: ```bash init_history() { if [ ! -f "$HISTORY_FILE" ]; then echo "# Clipboard History" > "$HISTORY_FILE" echo "" >> "$HISTORY_FILE" fi } ``` Clipboard data commonly contains passwords, access tokens, private keys, personal messages, and other sensitive material. The script stores this data without encryption, redaction, expiration controls, or an explicit `0600` permission policy. Actual permissions depend on the invoking process's `umask`, and the workspace file may also be collected by backups, synchronization tools, indexing systems, or other agent operations. ### Attack Path 1. A user copies a password, API token, private message, or other secret to the system clipboard. 2. The user or agent invokes `clipboard.sh save`. 3. `get_clipboard` retrieves the secret and `save_clipboard` appends it verbatim to `clipboard-history.md`. 4. The ...[truncated 700 chars]
- Remediation
- ## Remediation Suggestions - Create the history file with mode `0600`, using a restrictive `umask` before creation: ```bash umask 077 if [ ! -e "$HISTORY_FILE" ]; then printf '# Clipboard History\n\n' > "$HISTORY_FILE" fi chmod 600 -- "$HISTORY_FILE" ``` - Verify that an existing history path is a regular file owned by the current user and is not a symbolic link before reading or writing it. - Warn users that clipboard history is persistent and may contain secrets. - Provide an option to disable persistent history or store it only for a configured retention period. - Consider authenticated encryption using a user-controlled key for history stored on disk. - Add optional secret detection and redaction for common API tokens, passwords, private keys, and authentication headers. - Ensure clearing the history follows the project's data-deletion requirements; simple truncation may not constitute secure deletion on modern filesystems.
