T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/fm-screenshot.sh:7
- Finding
- Sensitive location screenshots are written to predictable temporary paths<![CDATA[ ## Vulnerability Details **File Location**: `scripts/fm-screenshot.sh:7-23`; `scripts/fm-list.sh:11-25`; `scripts/fm-locate.sh:12-26`; `scripts/fm-play-sound.sh:50-52` **Vulnerability Type**: Unsafe temporary-file handling and insufficient protection of sensitive data **Risk Level**: Medium ### Vulnerable Code ```bash # scripts/fm-screenshot.sh:7-23 OUTPUT_PATH="${1:-/tmp/findmy.png}" # Set bridge socket path - expand $HOME if present in value PEEKABOO_BRIDGE_SOCKET="${PEEKABOO_BRIDGE_SOCKET:-\$HOME/Library/Application Support/OpenClaw/bridge.sock}" PEEKABOO_BRIDGE_SOCKET="${PEEKABOO_BRIDGE_SOCKET//\$HOME/$HOME}" export PEEKABOO_BRIDGE_SOCKET # Get window ID (--app flag hangs, so we use --window-id) window_id=$(peekaboo window list --app "Find My" --json 2>/dev/null | jq -r '(.data.windows[0].window_id // .windows[0].window_id) // empty') if [ -z "$window_id" ]; then echo "Error: Find My window not found. Is the app open?" >&2 exit 1 fi # Capture using window ID peekaboo image --window-id "$window_id" --path "$OUTPUT_PATH" 2>&1 ``` ```bash # scripts/fm-list.sh:11-25 OUTPUT_DIR="${FM_OUTPUT_DIR:-/tmp}" # Set bridge socket path - expand $HOME if present in value PEEKABOO_BRIDGE_SOCKET="${PEEKABOO_BRIDGE_SOCKET:-\$HOME/Library/Application Support/OpenClaw/bridge.sock}" PEEKABOO_BRIDGE_SOCKET="${PEEKABOO_BRIDGE_SOCKET//\$HOME/$HOME}" export PEEKABOO_BRIDGE_SOCKET # Switch to the requested tab "$SCRIPT_DIR/fm-tab.sh" "$TAB" >/dev/null 2>&1 sleep 0.3 # Capture screenshot timestamp=$(date +%s) output_path="$OUTPUT_DIR/findmy-${TAB}-list-${timestamp}.png" "$SCRIPT_DIR/fm-screenshot.sh" "$output_path" >/dev/null ``` ```bash # scripts/fm-locate.sh:12-26 OUTPUT_DIR="${FM_OUTPUT_DIR:-/tmp}" # Set bridge socket path - expand $HOME if present in value PEEKABOO_BRIDGE_SOCKET="${PEEKABOO_BRIDGE_SOCKET:-\$HOME/Library/Application Support/OpenClaw/bridge.sock}" PEEKABOO_BRIDGE_SOCKET="${PEEKABOO_BRIDGE_SOCKET//\$HOME/$HOME}" export PEEKABOO_BRIDGE_S ...[truncated 2744 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Create a private temporary directory atomically: ```bash umask 077 TEMP_DIR=$(mktemp -d "${TMPDIR:-/tmp}/findmy.XXXXXXXX") trap 'rm -rf -- "$TEMP_DIR"' EXIT OUTPUT_PATH="$TEMP_DIR/screenshot.png" ``` 2. Use `mktemp` for each generated screenshot rather than timestamp-only or fixed names. 3. Enforce restrictive permissions with `umask 077` and verify the generated file has mode `0600`. 4. Reject existing output destinations, symbolic links, directories, and non-regular files before invoking Peekaboo. 5. Canonicalize and validate `FM_OUTPUT_DIR`; require it to be owned by the current user and not writable by untrusted users. 6. Delete screenshots automatically after they have served their purpose unless the user explicitly requests retention. 7. If a user-provided persistent path is supported, clearly warn that it contains sensitive location information and avoid silently overwriting an existing file. ]]>
