T09 · Insecure Skill Coding Practices
Warning
- Location
- install.sh:280
- Finding
- Dry-run mode performs model downloads and imports before exiting<![CDATA[ ## Vulnerability Details **File Location**: `install.sh:280-344` **Vulnerability Type**: Dry-run safety violation and unintended state modification **Risk Level**: Medium ### Vulnerable Code ```bash if [ "$WILL_IMPORT" = "yes" ]; then echo "Importing local GGUF into Ollama as: ${IMPORT_MODEL_NAME}" if import_gguf_to_ollama "$LOCAL_GGUF" "$IMPORT_MODEL_NAME"; then MODEL_TO_USE="$IMPORT_MODEL_NAME" echo "Import succeeded." else echo "WARNING: import failed. Falling back to pulling '${MODEL}'." fi fi # ── Ensure model is available in Ollama ────────────────────────────────────── if ! model_exists_in_ollama "$MODEL_TO_USE"; then echo "Pulling Ollama model: ${MODEL_TO_USE}" ollama pull "$MODEL_TO_USE" fi # Normalize for config and API calls MODEL_TO_USE_CANON="$(normalize_model "$MODEL_TO_USE")" echo "Using model: ${MODEL_TO_USE_CANON}" # ── Dry run plan ───────────────────────────────────────────────────────────── if [ "$DRY_RUN" -eq 1 ]; then echo "" echo "DRY RUN: no files or services will be changed." echo "Would modify:" echo " - ${SKILLS_DIR}/ (skill files)" echo " - ${CONFIG_PATH} (OpenClaw config)" echo "Would set memorySearch keys:" echo " - provider: openai" echo " - model: ${MODEL_TO_USE_CANON}" echo " - remote.baseUrl: http://127.0.0.1:11434/v1/" echo " - remote.apiKey: (set)" echo "Would run:" echo " - ${SKILLS_DIR}/enforce.sh --model ${MODEL_TO_USE_CANON} --openclaw-config ${CONFIG_PATH} --base-url http://127.0.0.1:11434/v1/" if [ "$RESTART_GATEWAY" = "yes" ]; then echo " - gateway restart" else echo " - gateway restart skipped (default)" fi if [ "$INSTALL_WATCHDOG" -eq 1 ]; then echo " - watchdog install via launchd (${WATCHDOG_INTERVAL}s)" else echo " - watchdog install skipped (default)" fi if [ "$IMPORT_LOCAL_GGUF" = "no" ]; then echo " - local GGUF scan/import skipped (default)" else echo " - local GGUF import mode: ${IMPORT_LOCAL_ ...[truncated 1769 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions Move dry-run handling before every mutation-capable operation, including `ollama create`, `ollama pull`, directory creation, file copying, configuration writes, service operations, and memory reindexing. Recommended hardening plan: 1. Resolve and validate arguments without changing state. 2. Check whether a model appears to be installed using read-only commands. 3. Calculate whether an import or pull would be required. 4. If `DRY_RUN=1`, print those planned operations and exit. 5. Invoke `ollama create` or `ollama pull` only after the dry-run branch. 6. Add regression tests that compare the Ollama model list and relevant filesystem state before and after a dry run. 7. Clearly distinguish read-only probes from state-changing operations in helper functions. ]]>
